00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #include <fesa-core/Synchronization/AbstractMultiplexingManager.h> 00004 00005 #include <fesa-core/Synchronization/AbstractMultiplexingDataManager.h> 00006 #include <fesa-core/Synchronization/CycleDescriptor.h> 00007 00008 00009 namespace fesa 00010 { 00011 00012 std::map<std::string, AbstractMultiplexingManager*> AbstractMultiplexingManager::managersCol_; 00013 00014 00015 AbstractMultiplexingManager::AbstractMultiplexingManager(const std::string& name, 00016 CycleDescriptor* timingDescriptor) : 00017 name_(name), timingDescriptor_(timingDescriptor) 00018 { 00019 00020 managersCol_.insert(std::make_pair(name, this)); 00021 } 00022 00023 AbstractMultiplexingManager::~AbstractMultiplexingManager() 00024 { 00025 managersCol_.erase(name_); 00026 if (managersCol_.size() == 0) 00027 { 00028 managersCol_.clear(); 00029 } 00030 } 00031 00032 AbstractMultiplexingManager* AbstractMultiplexingManager::getMultiplexingManager(const std::string& name) 00033 { 00034 std::map<std::string, AbstractMultiplexingManager*>::iterator itr; 00035 itr = AbstractMultiplexingManager::managersCol_.find(name); 00036 if (itr == AbstractMultiplexingManager::managersCol_.end()) 00037 { 00038 return NULL; 00039 } 00040 else 00041 { 00042 return itr->second; 00043 } 00044 } 00045 00046 int32_t AbstractMultiplexingManager::getMemorySizeToAllocate() 00047 { 00048 int32_t muxManagersSize_ = 0; 00049 for (std::map<std::string, AbstractMultiplexingManager*>::iterator itr = managersCol_.begin(); itr 00050 != managersCol_.end(); ++itr) 00051 { 00052 AbstractMultiplexingManager* pAbstractMultiplexingManager = (itr->second); 00053 AbstractMultiplexingDataManager* pCycleDataManager = 00054 pAbstractMultiplexingManager->getMultiplexingDataManager(); 00055 if (pCycleDataManager) 00056 { 00057 00058 muxManagersSize_ += pCycleDataManager->computeMemorySize(); 00059 } 00060 } 00061 return muxManagersSize_; 00062 } 00063 00064 void AbstractMultiplexingManager::mapMemory(char* p) 00065 { 00066 for (std::map<std::string, AbstractMultiplexingManager*>::iterator itr = managersCol_.begin(); itr 00067 != managersCol_.end(); ++itr) 00068 { 00069 AbstractMultiplexingManager * pAbstractMultiplexingManager = (itr->second); 00070 AbstractMultiplexingDataManager* pCycleDataManager = 00071 pAbstractMultiplexingManager->getMultiplexingDataManager(); 00072 if (pCycleDataManager) 00073 { 00074 pCycleDataManager->mapMemory(p); 00075 p += pCycleDataManager->computeMemorySize(); 00076 } 00077 } 00078 } 00079 00080 int32_t AbstractMultiplexingManager::getDepth() 00081 { 00082 return static_cast<int32_t>(timingDescriptor_->getCycleIdsCol().size()); 00083 } 00084 00085 } // fesa 00086