ServiceLocatorServerSplitImplementation.cpp

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #include <fesa-core/Server/ServiceLocatorServerSplitImplementation.h>
00004 
00005 #include <fesa-core/Server/AbstractServerDeviceClass.h>
00006 #include <fesa-core/Server/AbstractServerEquipment.h>
00007 #include <fesa-core/DataStore/GlobalDevice.h>
00008 #include <fesa-core/DataStore/AbstractDeviceFactory.h>
00009 #include <fesa-core/Core/NotificationProducer.h>
00010 #include <fesa-core/Exception/FesaException.h>
00011 
00012 namespace fesa
00013 {
00014 
00015 
00016     ServiceLocatorServerSplitImplementation::ServiceLocatorServerSplitImplementation(const std::string& className) :
00017                     AbstractServiceLocatorImplementation(className)
00018     {
00019 
00020     }
00021 
00022     ServiceLocatorServerSplitImplementation::~ServiceLocatorServerSplitImplementation()
00023     {
00024 
00025     }
00026 
00027     void ServiceLocatorServerSplitImplementation::runClassSpecificInitRT() const
00028     {
00029         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "classSpecificInitRT",
00030                         "Server");
00031     }
00032 
00033     void ServiceLocatorServerSplitImplementation::runClassSpecificInitServer() const
00034     {
00035         AbstractServerDeviceClass* pServerDeviceClass = AbstractServerEquipment::getInstance()->getServerDeviceClass(
00036                         className_);
00037         if (pServerDeviceClass == NULL)
00038         {
00039             throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00040                             "runClassSpecificInitServer");
00041         }
00042         pServerDeviceClass->specificInit();
00043     }
00044 
00045     void ServiceLocatorServerSplitImplementation::runDeployUnitSpecificInitRT() const
00046     {
00047         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "deployUnitSpecificInitRT",
00048                         "Server");
00049     }
00050 
00051     void ServiceLocatorServerSplitImplementation::runDeployUnitSpecificInitServer() const
00052     {
00053         AbstractServerEquipment::getInstance()->specificInit();
00054     }
00055 
00056     void ServiceLocatorServerSplitImplementation::enableEventSource(const std::string& eventSourceName) const
00057     {
00058         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "enableEventSource", "Server");
00059     }
00060 
00061     void ServiceLocatorServerSplitImplementation::disableEventSource(const std::string& eventSourceName) const
00062     {
00063         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "disableEventSource",
00064                         "Server");
00065     }
00066 
00067     void ServiceLocatorServerSplitImplementation::enableRTEvent(const std::string& eventName,const std::string& eventSourceName) const
00068     {
00069         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "enableRTEvent", "Server");
00070     }
00071 
00072     void ServiceLocatorServerSplitImplementation::disableRTEvent(const std::string& eventName,const std::string& eventSourceName) const
00073     {
00074         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "disableRTEvent", "Server");
00075     }
00076 
00077     bool ServiceLocatorServerSplitImplementation::isEventEnabled(const std::string& eventName,const std::string& eventSourceName) const
00078     {
00079         throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "isEventEnable", "Server");
00080         return false;
00081     }
00082 
00083     void ServiceLocatorServerSplitImplementation::synchronizeSettingFields(const MultiplexingContext& context) const
00084     {
00085         AbstractServerDeviceClass* pServerDeviceClass = AbstractServerEquipment::getInstance()->getServerDeviceClass(
00086                         className_);
00087         if (pServerDeviceClass == NULL)
00088         {
00089             throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00090                             "synchronizeSettingFields");
00091         }
00092         GlobalDevice* pGlobalDevice = pServerDeviceClass->getDeviceFactory()->getGlobalDevice();
00093         std::vector<AbstractDevice*> deviceCollection = AbstractServerEquipment::getInstance()->getServerDeviceClass(
00094                         className_)->getDeviceFactory()->getAbstractDeviceCollection();
00095 
00096         // TODO : To remove the const_cast as soon as the FWK deals properly with const parameters using const methods
00097         pGlobalDevice->synchronizeSettingFields(const_cast<MultiplexingContext&>(context));
00098         for (std::vector<AbstractDevice*>::iterator device = deviceCollection.begin(); device != deviceCollection.end(); device++)
00099         {
00100             // TODO : To remove the const_cast as soon as the FWK deals properly with const parameters using const methods
00101             (*device)->synchronizeSettingFields(const_cast<MultiplexingContext&>(context));
00102         }
00103     }
00104 
00105     void ServiceLocatorServerSplitImplementation::triggerPersistency() const
00106     {
00107     NotificationProducer::getInstance()->sendCommandMessage("PersistencyTrigger", className_, "");
00108     }
00109 
00110     AbstractDevice* ServiceLocatorServerSplitImplementation::getDevice(const std::string& deviceName) const
00111     {
00112         AbstractServerDeviceClass* pServerDeviceClass = AbstractServerEquipment::getInstance()->getServerDeviceClass(
00113                         className_);
00114         if (pServerDeviceClass == NULL)
00115         {
00116             throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "getDevice");
00117         }
00118         AbstractDevice* pDevice = pServerDeviceClass->getDeviceFactory()->getDevice(deviceName);
00119         if (pDevice == NULL)
00120         {
00121             throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(), "getDevice");
00122         }
00123         return (pDevice);
00124     }
00125 
00126     AbstractDevice* ServiceLocatorServerSplitImplementation::getGlobalDevice() const
00127     {
00128         AbstractServerDeviceClass* pServerDeviceClass = AbstractServerEquipment::getInstance()->getServerDeviceClass(
00129                         className_);
00130         if (pServerDeviceClass == NULL)
00131         {
00132             throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00133                             "getDeviceCollection");
00134         }
00135         return (pServerDeviceClass->getDeviceFactory()->getGlobalDevice());
00136     }
00137 
00138     const std::vector<AbstractDevice*>& ServiceLocatorServerSplitImplementation::getDeviceCollection() const
00139     {
00140         AbstractServerDeviceClass* pServerDeviceClass = AbstractServerEquipment::getInstance()->getServerDeviceClass(
00141                         className_);
00142         if (pServerDeviceClass == NULL)
00143         {
00144             throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorServiceNotAvailable.c_str(),
00145                             "getDeviceCollection");
00146         }
00147         return (pServerDeviceClass->getDeviceFactory()->getAbstractDeviceCollection());
00148     }
00149 
00150 } //end namespace

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1