Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:58

0001 
0002 /*
0003  *  See header file for a description of this class.
0004  *
0005  *  $Date: 2011/02/23 16:55:18 $
0006  *  $Revision: 1.1 $
0007  *  \author G. Cerminara - CERN
0008  */
0009 
0010 #include "CondFormats/Common/interface/DropBoxMetadata.h"
0011 #include <algorithm>  // for std::transform
0012 
0013 using std::map;
0014 using std::string;
0015 
0016 DropBoxMetadata::DropBoxMetadata() {}
0017 
0018 DropBoxMetadata::~DropBoxMetadata() {}
0019 
0020 void DropBoxMetadata::Parameters::addParameter(const string& key, const string& value) { theParameters[key] = value; }
0021 
0022 string DropBoxMetadata::Parameters::getParameter(const string& key) const {
0023   string ret;
0024   map<string, string>::const_iterator thePair = theParameters.find(key);
0025   if (thePair != theParameters.end()) {
0026     ret = (*thePair).second;
0027   }
0028   return ret;
0029 }
0030 
0031 const map<string, string>& DropBoxMetadata::Parameters::getParameterMap() const { return theParameters; }
0032 
0033 void DropBoxMetadata::addRecordParameters(const string& record, const Parameters& params) {
0034   recordSet[record] = params;
0035 }
0036 
0037 const DropBoxMetadata::Parameters& DropBoxMetadata::getRecordParameters(const string& record) const {
0038   return recordSet.find(record)->second;
0039 }
0040 
0041 bool DropBoxMetadata::knowsRecord(const std::string& record) const {
0042   if (recordSet.find(record) != recordSet.end())
0043     return true;
0044 
0045   return false;
0046 }
0047 
0048 const std::vector<std::string> DropBoxMetadata::getAllRecords() const {
0049   std::vector<std::string> records;
0050   std::transform(recordSet.begin(),
0051                  recordSet.end(),
0052                  std::inserter(records, records.end()),
0053                  [](std::pair<std::string, DropBoxMetadata::Parameters> recordSetEntry) -> std::string {
0054                    return recordSetEntry.first;
0055                  });
0056   return records;
0057 }