00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #ifndef ABSTRACT_SERVER_DEVICE_CLASS_H_ 00004 #define ABSTRACT_SERVER_DEVICE_CLASS_H_ 00005 00006 #include <fesa-core/Server/AbstractServerAction.h> 00007 #include <fesa-core/Core/AbstractDeviceClass.h> 00008 00009 #include <string> 00010 #include <vector> 00011 #include <map> 00012 00013 namespace fesa 00014 { 00015 00016 class Property; 00017 class AbstractServerActionFactory; 00018 class FesaStream; 00019 00025 struct PropertyInfo 00026 { 00030 std::string name_; 00031 00035 bool isGlobal_; 00036 00040 bool isOnChange_; 00041 00045 bool isSubscribable_; 00046 00050 int32_t priorityOffset_; 00051 00055 ServerActionConfig setActionProperty_; 00056 00060 ServerActionConfig getActionProperty_; 00061 00066 bool multiplexed_; 00067 00071 PropertyType type_; 00072 00076 std::string notificationThreadKey_; 00077 00081 std::string className_; 00082 }; 00083 00089 class AbstractServerDeviceClass : public AbstractDeviceClass 00090 { 00091 public: 00092 00096 AbstractServerDeviceClass(const std::string& name, const std::string& version); 00097 00101 virtual ~AbstractServerDeviceClass(); 00102 00107 void initialize(); 00108 00113 Property* getProperty(const std::string& propertyName); 00114 00115 // /*! 00116 // * \brief This method looks for the class passed as a parameter recursively 00117 // * in the related classes 00118 // * \return a reference to the AbstractServerDeviceClass which name is passed as a parameter 00119 // * or NULL if the class is not found 00120 // */ 00121 // AbstractServerDeviceClass* getRelatedServerDeviceClass(std::string deviceClassName); 00122 00124 AbstractServerActionFactory* getActionFactory(); 00125 00130 void reportErrorToSubscribers(std::string Message); 00131 00136 virtual void printConfig(FesaStream* configStream); 00137 00143 virtual void printState(FesaStream* fesaStream, double elapsedTime); 00144 00145 protected: 00146 00151 virtual std::vector<PropertyInfo*>* fillProperties() = 0; 00152 00156 virtual std::map<std::string, std::vector<std::string> >* fillActions() = 0; 00157 00161 AbstractServerActionFactory* actionFactory_; 00162 00166 std::map<std::string, Property*> propertiesCol_; 00167 00168 private: 00169 00173 void configurePropertiesActions(); 00174 00175 }; 00176 00177 /*************************************************************************/ 00178 00179 inline AbstractServerActionFactory* AbstractServerDeviceClass::getActionFactory() 00180 { 00181 return actionFactory_; 00182 } 00183 00184 } // fesa 00185 00186 #endif // ABSTRACT_SERVER_DEVICE_CLASS_H_