Property.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef PROPERTY_H_
00004 #define PROPERTY_H_
00005 
00006 #include <fesa-core/Server/AbstractServerAction.h>
00007 #include <fesa-core/Core/FesaDefs.h>
00008 
00009 #include <vector>
00010 #include <string>
00011 
00012 class rdaData;
00013 
00014 namespace fesa
00015 {
00016 
00017 class SubscriptionParameter;
00018 class AbstractDevice;
00019 class MultiplexingContext;
00020 class FesaStream;
00021 
00027 class Property
00028 {
00029   public:
00030 
00041     Property(const std::string& name, bool isGlobal, bool isOnChange, bool isSubscribable, PropertyType type,
00042              bool multiplexed, int32_t priorityOffset, const std::string& notificationThreadKey,
00043              AbstractServerAction* getServerAction, AbstractServerAction* setServerAction, const std::string& className);
00044 
00048     virtual ~Property();
00049 
00062     template<typename PropDataType, typename PropFilterType>
00063     void get(AbstractDevice& device, const std::string& cyleSelector, const PropFilterType& filter,
00064              const PropDataType& value);
00076     template<typename PropDataType>
00077     void get(AbstractDevice& device, const std::string& cyleSelector, const PropDataType& value);
00078 
00087     template<typename PropDataType, typename PropFilterType>
00088     void set(AbstractDevice& dev, const std::string& cyleSelector, const PropDataType& data,
00089              const PropFilterType& filter);
00090 
00098     template<typename PropDataType>
00099     void set(AbstractDevice& dev, const std::string& cyleSelector, const PropDataType& data);
00100 
00108     void validateParameters(AbstractDevice& dev, const std::string& cycleSelector, bool hasFilter,
00109                             RequestType reqType);
00117     int64_t getDataTimestamp(AbstractDevice& device, MultiplexingContext& context,
00118                                const rdaData& filter);
00119 
00120     /************************* get methods ******************************/
00125     std::string& getName();
00126 
00131     PropertyType getType();
00132 
00137     int32_t getPriorityOffset();
00138 
00143     bool isGlobal();
00144 
00149     bool isOnChange();
00150 
00154     bool isMultiplexed();
00155 
00159     bool isSubscribable();
00160 
00165     virtual void printConfig(FesaStream* configStream);
00166 
00172     virtual void printState(FesaStream* fesaStream, double elapsedTime);
00173 
00178     //            void reportErrorToSubscribers(std::string Message);
00179 
00180 
00181     const std::string& getNotificationThreadKey();
00182 
00183     const std::string& getClassName();
00184 
00185 
00186   protected:
00187     // teh following classes access the protected get/set method using rdaData Object
00188     friend class AbstractSubscriptionFilter;
00189     friend class SubscriptionFilter;
00190     friend class FesaDeviceServer;
00191 
00201     void get(AbstractDevice& device, MultiplexingContext& context, const rdaData& filter,
00202              rdaData& value, RequestType reqType);
00203 
00212     void get(AbstractDevice& device, const std::string& cycleSelector, const rdaData& filter, rdaData& value,
00213              RequestType reqType);
00214 
00223     void set(AbstractDevice& device, const std::string& cycleSelector, const rdaData& filter,
00224              const rdaData& value);
00225 
00234     void
00235     validateCycleSelector(AbstractDevice& device, const std::string& cycleSelector, RequestType reqType);
00236 
00240     std::string name_;
00241 
00245     bool isGlobal_;
00246 
00250     bool isOnChange_;
00251 
00255     bool isSubscribable_;
00256 
00260     PropertyType type_;
00261 
00265     bool multiplexed_;
00266 
00270     int32_t priorityOffset_;
00274     std::vector<SubscriptionParameter*> subscribers_;
00275 
00281     std::string notificationThreadKey_;
00282 
00286     AbstractServerAction* getServerAction_;
00287 
00291     AbstractServerAction* setServerAction_;
00292 
00296     bool needFilter();
00297 
00301     std::string className_;
00302 
00303 
00304 
00305 };
00306 
00307 inline bool Property::isGlobal()
00308 {
00309     return isGlobal_;
00310 }
00311 
00312 inline bool Property::isOnChange()
00313 {
00314     return isOnChange_;
00315 }
00316 
00317 inline bool Property::isSubscribable()
00318 {
00319     return isSubscribable_;
00320 }
00321 
00322 inline bool Property::isMultiplexed ()
00323 {
00324     return multiplexed_;
00325 }
00326 
00327 inline PropertyType Property::getType()
00328 {
00329     return type_;
00330 }
00331 
00332 inline int32_t Property::getPriorityOffset()
00333 {
00334     return priorityOffset_;
00335 }
00336 
00337 inline bool Property::needFilter()
00338 {
00339     if (getServerAction_)
00340         return getServerAction_->needFilter();
00341     else
00342         return setServerAction_->needFilter();
00343 
00344 }
00345 
00346 inline std::string& Property::getName()
00347 {
00348     return name_;
00349 }
00350 
00351 template<typename PropDataType, typename PropFilterType>
00352 void Property::get(AbstractDevice& device, const std::string& cycleSelector, const PropFilterType& filter,
00353                    const PropDataType& value)
00354 {
00355     this->get(device, cycleSelector, *(filter.getRdaData()), *(value.getRdaData()));
00356 }
00357 
00358 template<typename PropDataType, typename PropFilterType>
00359 void Property::set(AbstractDevice& device, const std::string& cycleSelector, const PropDataType& value,
00360                    const PropFilterType& filter)
00361 {
00362     this->set(device, cycleSelector, (*value.getRdaData()), *(filter.getRdaData()));
00363 }
00364 
00365 template<typename PropDataType>
00366 void Property::get(AbstractDevice& device, const std::string& cycleSelector, const PropDataType& value)
00367 {
00368     rdaData dummyRDA;
00369     this->get(device, cycleSelector, dummyRDA, *(value.getRdaData()));
00370 }
00371 
00372 template<typename PropDataType>
00373 void Property::set(AbstractDevice& device, const std::string& cycleSelector, const PropDataType& value)
00374 {
00375     rdaData dummyRDA;
00376     this->set(device, cycleSelector, (*value.getRdaData()), dummyRDA);
00377 }
00378 
00379 } // fesa
00380 
00381 #endif // PROPERTY_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1