Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

/*
 *  See header file for a description of this class.
 *
 *  $Date: 2011/02/23 16:55:18 $
 *  $Revision: 1.1 $
 *  \author G. Cerminara - CERN
 */

#include "CondFormats/Common/interface/DropBoxMetadata.h"
#include <algorithm>  // for std::transform

using std::map;
using std::string;

DropBoxMetadata::DropBoxMetadata() {}

DropBoxMetadata::~DropBoxMetadata() {}

void DropBoxMetadata::Parameters::addParameter(const string& key, const string& value) { theParameters[key] = value; }

string DropBoxMetadata::Parameters::getParameter(const string& key) const {
  string ret;
  map<string, string>::const_iterator thePair = theParameters.find(key);
  if (thePair != theParameters.end()) {
    ret = (*thePair).second;
  }
  return ret;
}

const map<string, string>& DropBoxMetadata::Parameters::getParameterMap() const { return theParameters; }

void DropBoxMetadata::addRecordParameters(const string& record, const Parameters& params) {
  recordSet[record] = params;
}

const DropBoxMetadata::Parameters& DropBoxMetadata::getRecordParameters(const string& record) const {
  return recordSet.find(record)->second;
}

bool DropBoxMetadata::knowsRecord(const std::string& record) const {
  if (recordSet.find(record) != recordSet.end())
    return true;

  return false;
}

const std::vector<std::string> DropBoxMetadata::getAllRecords() const {
  std::vector<std::string> records;
  std::transform(recordSet.begin(),
                 recordSet.end(),
                 std::inserter(records, records.end()),
                 [](std::pair<std::string, DropBoxMetadata::Parameters> recordSetEntry) -> std::string {
                   return recordSetEntry.first;
                 });
  return records;
}