00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #ifndef ABSTRACT_EQUIPMENT_H_ 00004 #define ABSTRACT_EQUIPMENT_H_ 00005 00006 #include <fesa-core/Core/FesaDefs.h> 00007 #include <fesa-core/Utilities/ProcessConfiguration.h> 00008 00009 #include <map> 00010 #include <string> 00011 #include <boost/shared_ptr.hpp> 00012 00013 namespace fesa 00014 { 00015 00016 class AbstractComponentEquipment; 00017 class Diagnostics; 00018 00024 class AbstractEquipment 00025 { 00026 public: 00027 00032 AbstractComponentEquipment* getServerComponent(); 00033 00038 AbstractComponentEquipment* getRTComponent(); 00039 00044 inline const ProcessConfiguration* getProcessConfiguration(); 00045 00050 const boost::shared_ptr<Diagnostics>& getDiagnostics() const; 00051 00056 virtual void initialize() = 0; 00057 00065 static AbstractEquipment* getInstance(); 00066 00070 void start(); 00071 00076 const std::string& getEquipmentName(); 00077 00082 const FesaProcessType& getProcessType(); 00083 00088 std::string getProcessTypeAsString(); 00089 00094 const std::string& getFesaVersion(); 00095 00100 const std::string& getVersion(); 00101 00106 const std::string& getFesaBuildDate(); 00107 00112 const std::string& getHostName(); 00113 00118 const std::string getDeviceDataFileName(); 00119 00125 const std::string getPersistencyFileName(const std::string& className); 00126 00127 00133 const std::string getNotificationFileName(); 00134 00139 bool getTimingSimulationMode(); 00140 00144 void setClassOptional (const std::string& className,bool optional); 00145 00149 bool isClassOptional (const std::string &className); 00150 00154 bool isInitialized (); 00155 00156 protected: 00157 00167 AbstractEquipment(const std::string& equipmentName, FesaProcessType processType, const boost::shared_ptr<ProcessConfiguration>& configuration, const boost::shared_ptr<Diagnostics>& diagnostics); 00168 00169 //Default constructor only used for unit-tests 00170 AbstractEquipment() 00171 { 00172 } 00173 00177 virtual ~AbstractEquipment(); 00178 00182 std::string equipmentName_; 00183 00187 FesaProcessType processType_; 00188 00192 AbstractComponentEquipment* theRTEquipmentComponent_; 00193 00197 AbstractComponentEquipment* theServerEquipmentComponent_; 00198 00204 std::map<std::string,bool> optionalClasses_; 00205 00206 /* 00207 * \brief version of the used fesa-framework (e.g 1.2.3) 00208 */ 00209 std::string fesaVersion_; 00210 00211 /* 00212 * \brief version of this equipment (deploy-unit version e.g. 4.5.6) 00213 */ 00214 std::string version_; 00215 00216 /* 00217 * \brief Equipment compilation date and time 00218 */ 00219 std::string madeAt_; 00220 00221 /* 00222 * \brief This flag indicates if the Equipment has been already initialized 00223 */ 00224 bool initialized_; 00225 00229 static AbstractEquipment* instance_; 00230 00231 private: 00232 00236 std::string hostName_; 00237 boost::shared_ptr<ProcessConfiguration> configuration_; 00238 boost::shared_ptr<Diagnostics> diagnostics_; 00239 }; 00240 00241 //------------------ inline methods ------------------ 00242 00243 inline AbstractComponentEquipment* AbstractEquipment::getServerComponent() 00244 { 00245 return theServerEquipmentComponent_; 00246 } 00247 00248 inline AbstractComponentEquipment* AbstractEquipment::getRTComponent() 00249 { 00250 return theRTEquipmentComponent_; 00251 } 00252 00253 inline AbstractEquipment* AbstractEquipment::getInstance() 00254 { 00255 return instance_; 00256 } 00257 00258 inline const std::string& AbstractEquipment::getEquipmentName() 00259 { 00260 return equipmentName_; 00261 } 00262 00263 inline const FesaProcessType& AbstractEquipment::getProcessType() 00264 { 00265 return processType_; 00266 } 00267 00268 inline const std::string& AbstractEquipment::getHostName() 00269 { 00270 return hostName_; 00271 } 00272 00273 inline const ProcessConfiguration* AbstractEquipment::getProcessConfiguration() 00274 { 00275 return configuration_.get(); 00276 } 00277 00278 inline bool AbstractEquipment::getTimingSimulationMode() 00279 { 00280 return configuration_->isInTimingSimulationMode(); 00281 } 00282 00283 inline const std::string& AbstractEquipment::getFesaVersion() 00284 { 00285 return fesaVersion_; 00286 } 00287 00288 inline const std::string& AbstractEquipment::getVersion() 00289 { 00290 return version_; 00291 } 00292 00293 inline const std::string& AbstractEquipment::getFesaBuildDate() 00294 { 00295 return madeAt_; 00296 } 00297 00298 inline bool AbstractEquipment::isInitialized () 00299 { 00300 return initialized_; 00301 } 00302 00303 } // fesa 00304 00305 #endif // ABSTRACT_EQUIPMENT_H_