AbstractDeviceClass.cpp
Go to the documentation of this file.00001
00002
00003 #include <fesa-core/Core/AbstractDeviceClass.h>
00004 #include <fesa-core/Core/AbstractServiceLocatorFactory.h>
00005
00006 namespace fesa
00007 {
00008
00009 AbstractDeviceClass::AbstractDeviceClass(const std::string& fesaClassName, const std::string& version) :
00010 name_(fesaClassName), version_(version), deviceFactory_(NULL), baseClass_(NULL)
00011 {
00012 if(name_.empty() == false)
00013 {
00014 serviceLocator_ = AbstractServiceLocatorFactory::getInstance()->getServiceLocator(name_);
00015 if (serviceLocator_ == 0)
00016 {
00017 throw FesaException(__FILE__, __LINE__, FesaErrorServiceLocatorWasNotCreated.c_str());
00018 }
00019 }
00020 }
00021
00022 AbstractDeviceClass::~AbstractDeviceClass()
00023 {
00024
00025 if (baseClass_ != NULL)
00026 {
00027 delete baseClass_;
00028 baseClass_ = NULL;
00029 }
00030 relatedClassCol_.clear();
00031 }
00032
00033 const AbstractServiceLocator* AbstractDeviceClass::getServiceLocator()
00034 {
00035 return serviceLocator_;
00036 }
00037
00038 void AbstractDeviceClass::addOnDemandEventProducer(const std::string& onDemandEventSourceName, boost::shared_ptr<OnDemandProducer>& producer)
00039 {
00040 OnDemandEventProducerCollection::const_iterator iter = onDemandEventProducerCol_.find(onDemandEventSourceName);
00041
00042 if(iter == onDemandEventProducerCol_.end())
00043 {
00044 onDemandEventProducerCol_.insert(std::make_pair(onDemandEventSourceName,producer));
00045 }
00046 }
00047
00048 boost::shared_ptr<OnDemandProducer> AbstractDeviceClass::getOnDemandEventProducer(const std::string& onDemandEventSourceName) const
00049 {
00050 OnDemandEventProducerCollection::const_iterator iter = onDemandEventProducerCol_.find(onDemandEventSourceName);
00051
00052 if(iter == onDemandEventProducerCol_.end())
00053 {
00054 throw FesaException(__FILE__, __LINE__, FesaErrorOnDemandEventProducerNotFound.c_str(),onDemandEventSourceName.c_str());
00055 }
00056
00057 return iter->second;
00058 }
00059
00060 }
00061