ServiceLocator.h
Go to the documentation of this file.00001
00002
00003 #ifndef SERVICE_LOCATOR_H_
00004 #define SERVICE_LOCATOR_H_
00005
00006 #include <fesa-core/Core/AbstractServiceLocator.h>
00007 #include <fesa-core/Core/AbstractServiceLocatorImplementation.h>
00008 #include <fesa-core/RealTime/AbstractRTEquipment.h>
00009 #include <fesa-core/Server/AbstractServerEquipment.h>
00010
00011 #include <string>
00012
00013 namespace fesa
00014 {
00015
00020 template<typename GlobalDeviceType, typename DomainStoreType, typename DeviceType>
00021 class ServiceLocator : public AbstractServiceLocator
00022 {
00023 public:
00024 ServiceLocator(AbstractServiceLocatorImplementation* abstractImplementation);
00025 virtual ~ServiceLocator();
00026 DeviceType* getDevice(const std::string& deviceName) const;
00027 const std::vector<DeviceType*>& getDeviceCollection();
00028 GlobalDeviceType* getGlobalDevice() const;
00029 };
00030
00037 template<typename GlobalDeviceType, typename DomainStoreType, typename DeviceType>
00038 DeviceType* ServiceLocator<GlobalDeviceType, DomainStoreType, DeviceType>::getDevice(const std::string& deviceName) const
00039 {
00040 return (static_cast<DeviceType*>(pImplementation_->getDevice(deviceName)));
00041 }
00042
00048 template<typename GlobalDeviceType, typename DomainStoreType, typename DeviceType>
00049 const std::vector<DeviceType*>& ServiceLocator<GlobalDeviceType, DomainStoreType, DeviceType>::getDeviceCollection()
00050 {
00051 return (reinterpret_cast<std::vector<DeviceType*>& >(const_cast<std::vector<AbstractDevice*>&>(pImplementation_->getDeviceCollection())));
00052 }
00053
00054
00060 template<typename GlobalDeviceType, typename DomainStoreType, typename DeviceType>
00061 GlobalDeviceType* ServiceLocator<GlobalDeviceType, DomainStoreType, DeviceType>::getGlobalDevice() const
00062 {
00063 return (static_cast<GlobalDeviceType*>(pImplementation_->getGlobalDevice()));
00064 }
00065
00066 template<typename GlobalDeviceType, typename DomainStoreType, typename DeviceType>
00067 ServiceLocator<GlobalDeviceType, DomainStoreType, DeviceType>::ServiceLocator(AbstractServiceLocatorImplementation* abstractImplementation) : AbstractServiceLocator(abstractImplementation)
00068 {
00069
00070 }
00071
00072 template<typename GlobalDeviceType, typename DomainStoreType, typename DeviceType>
00073 ServiceLocator<GlobalDeviceType, DomainStoreType, DeviceType>::~ServiceLocator()
00074 {
00075 }
00076
00077 }
00078
00079 #endif // SERVICE_LOCATOR_H_