00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #include <fesa-core/Core/AbstractComponentEquipment.h> 00004 00005 #include <fesa-core/Core/AbstractDeviceClass.h> 00006 #include <fesa-core/Core/AbstractEquipment.h> 00007 00008 00009 namespace fesa 00010 { 00011 00012 AbstractComponentEquipment::AbstractComponentEquipment() 00013 { 00014 } 00015 00016 AbstractComponentEquipment::~AbstractComponentEquipment() 00017 { 00018 for (std::vector<AbstractDeviceClass*>::const_iterator it = abstractDeviceClassCol_.begin(); it 00019 != abstractDeviceClassCol_.end(); ++it) 00020 { 00021 AbstractDeviceClass* pDV = *it; 00022 delete pDV; 00023 } 00024 } 00025 00026 void AbstractComponentEquipment::initialize() 00027 { 00028 // The specific init of the Equipment is called before the init of each DeviceClass 00029 specificInit(); 00030 00031 bool atLeastOneRequiredClass = false; 00032 for (std::vector<AbstractDeviceClass*>::const_iterator it = abstractDeviceClassCol_.begin(); it 00033 != abstractDeviceClassCol_.end(); ++it) 00034 { 00035 (*it)->initialize(); 00036 atLeastOneRequiredClass |= !AbstractEquipment::getInstance()->isClassOptional((*it)->getName()); 00037 } 00038 00039 if (!atLeastOneRequiredClass) 00040 { 00041 throw FesaException(__FILE__, __LINE__, FesaErrorNoRequiredClass.c_str()); 00042 } 00043 } 00044 00045 AbstractDeviceClass* AbstractComponentEquipment::getDeviceClass(const std::string& classname) 00046 { 00047 for (std::vector<AbstractDeviceClass*>::const_iterator it = abstractDeviceClassCol_.begin(); it 00048 != abstractDeviceClassCol_.end(); ++it) 00049 { 00050 if ((*it)->getName() == classname) 00051 { 00052 return *it; 00053 } 00054 } 00055 return NULL; 00056 } 00057 00058 void AbstractComponentEquipment::deregisterDeviceClass(const std::string& className) 00059 { 00060 00061 for (std::vector<AbstractDeviceClass*>::iterator it = abstractDeviceClassCol_.begin(); it 00062 != abstractDeviceClassCol_.end(); ++it) 00063 { 00064 if ((*it)->getName() == className) 00065 { 00066 abstractDeviceClassCol_.erase(it); 00067 break; 00068 } 00069 } 00070 } 00071 00072 } // fesa