00001 #include "EventFilter/Modules/interface/ShmOutputModuleRegistry.h" 00002 #include "EventFilter/Modules/src/FUShmOutputModule.h" 00003 00004 #include <iostream> 00005 00006 namespace evf{ 00007 00008 ShmOutputModuleRegistry::ShmOutputModuleRegistry(const edm::ParameterSet &ps){ 00009 } 00010 00011 void ShmOutputModuleRegistry::registerModule(std::string &name, OutputModule *op) 00012 { 00013 clm_.insert(std::pair<std::string, OutputModule*>(name,op)); 00014 } 00015 00016 00017 OutputModule* ShmOutputModuleRegistry::get(std::string &name) 00018 { 00019 OutputModule* retval = 0; 00020 idct it= clm_.find(name); 00021 if(it!=clm_.end()) 00022 retval = (it->second); 00023 return retval; 00024 } 00025 void ShmOutputModuleRegistry::dumpRegistry(){ 00026 idct it= clm_.begin(); 00027 while(it!=clm_.end()){ 00028 std::cout << "name " << it->first << "add " 00029 << (unsigned long)(it->second) << std::endl; 00030 it++; 00031 } 00032 } 00033 std::vector<edm::FUShmOutputModule *> ShmOutputModuleRegistry::getShmOutputModules() 00034 { 00035 std::vector<edm::FUShmOutputModule *> outputs; 00036 idct it= clm_.begin(); 00037 while(it!=clm_.end()){ 00038 edm::FUShmOutputModule * sho = dynamic_cast<edm::FUShmOutputModule *> ((*it).second); 00039 if (sho!=NULL) { 00040 outputs.push_back(sho); 00041 } 00042 it++; 00043 } 00044 return outputs; 00045 } 00046 void ShmOutputModuleRegistry::clear() 00047 { 00048 clm_.clear(); 00049 shmOutputsWithDatasets_.clear(); 00050 listOfDatasets_.clear(); 00051 } 00052 00053 void ShmOutputModuleRegistry::updateDatasetInfo() 00054 { 00055 shmOutputsWithDatasets_.clear(); 00056 listOfDatasets_.clear(); 00057 std::vector<edm::FUShmOutputModule *> outputs = getShmOutputModules(); 00058 for (unsigned int i=0;i<outputs.size();i++) { 00059 edm::FUShmOutputModule * output = outputs[i]; 00060 if (output->getStreamId().size()) { 00061 std::vector<std::string> datasets = output->getDatasetNames(); 00062 listOfDatasets_.insert(listOfDatasets_.end(),datasets.begin(),datasets.end()); 00063 if (datasets.size()) 00064 shmOutputsWithDatasets_.push_back(output); 00065 } 00066 } 00067 } 00068 std::string ShmOutputModuleRegistry::getDatasetCSV() 00069 { 00070 std::string datasetNameString; 00071 for (unsigned int i=0;i<listOfDatasets_.size();i++) { 00072 if (i) 00073 datasetNameString+=","; 00074 datasetNameString+=listOfDatasets_[i]; 00075 } 00076 return datasetNameString; 00077 } 00078 00079 void ShmOutputModuleRegistry::insertStreamAndDatasetInfo(edm::ParameterSet & streams, edm::ParameterSet & datasets) 00080 { 00081 idct it= clm_.begin(); 00082 while(it!=clm_.end()){ 00083 edm::FUShmOutputModule * sho = dynamic_cast<edm::FUShmOutputModule *> ((*it).second); 00084 if (sho!=NULL) { 00085 sho->insertStreamAndDatasetInfo(streams,datasets); 00086 } 00087 it++; 00088 } 00089 } 00090 00091 } //end namespace evf