CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
jsoncollector::DataPointDefinition Class Reference

#include <DataPointDefinition.h>

Inheritance diagram for jsoncollector::DataPointDefinition:
jsoncollector::JsonSerializable

Public Member Functions

void addLegendItem (std::string const &name, std::string const &type, std::string const &operation)
 
 DataPointDefinition ()
 
void deserialize (Json::Value &root) override
 
std::string & getDefFilePath ()
 
std::vector< std::string > const & getNames ()
 
OperationType getOperationFor (unsigned int index)
 
std::vector< std::string > const & getOperations ()
 
bool isPopulated () const
 
void serialize (Json::Value &root) const override
 
void setDefaultGroup (std::string const &group)
 
 ~DataPointDefinition () override
 
- Public Member Functions inherited from jsoncollector::JsonSerializable
virtual ~JsonSerializable ()
 

Static Public Member Functions

static bool getDataPointDefinitionFor (std::string &defFilePath, DataPointDefinition *dpd, const std::string *defaultGroup=nullptr)
 

Static Public Attributes

static const std::string ADLER32 = "adler32"
 
static const std::string AVG = "avg"
 
static const std::string BINARYOR = "binaryOr"
 
static const std::string CAT = "cat"
 
static const std::string DATA = "data"
 
static const std::string HISTO = "histo"
 
static const std::string LEGEND = "legend"
 
static const std::string MERGE = "merge"
 
static const std::string OPERATION = "operation"
 
static const std::string PARAM_NAME = "name"
 
static const std::string SAME = "same"
 
static const std::string SUM = "sum"
 
static const std::string TYPE = "type"
 

Private Attributes

std::string defaultGroup_
 
std::string defFilePath_
 
std::vector< std::string > opNames_
 
std::vector< std::string > typeNames_
 
std::vector< std::string > varNames_
 

Detailed Description

Definition at line 20 of file DataPointDefinition.h.

Constructor & Destructor Documentation

jsoncollector::DataPointDefinition::DataPointDefinition ( )
inline

Definition at line 23 of file DataPointDefinition.h.

23 {}
jsoncollector::DataPointDefinition::~DataPointDefinition ( )
inlineoverride

Definition at line 28 of file DataPointDefinition.h.

References deserialize(), isPopulated(), and serialize().

28 {}

Member Function Documentation

void DataPointDefinition::addLegendItem ( std::string const &  name,
std::string const &  type,
std::string const &  operation 
)

Definition at line 91 of file DataPointDefinition.cc.

References opNames_, typeNames_, and varNames_.

Referenced by evf::RecoEventOutputModuleForFU< Consumer >::initRun(), RawEventFileWriterForBU::RawEventFileWriterForBU(), and setDefaultGroup().

92 {
93  varNames_.push_back(name);
94  typeNames_.push_back(type);
95  opNames_.push_back(operation);
96 }
type
Definition: HCALResponse.h:21
std::vector< std::string > varNames_
std::vector< std::string > typeNames_
std::vector< std::string > opNames_
void DataPointDefinition::deserialize ( Json::Value root)
overridevirtual

JSON deserialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 60 of file DataPointDefinition.cc.

References Json::Value::asString(), defaultGroup_, Json::Value::get(), mps_fire::i, Json::Value::isArray(), OPERATION, opNames_, PARAM_NAME, Json::Value::size(), findQualityFiles::size, TYPE, typeNames_, and varNames_.

Referenced by ~DataPointDefinition().

61 {
62  if (root.get(defaultGroup_, "").isArray()) {
63  unsigned int size = root.get(defaultGroup_, "").size();
64  for (unsigned int i = 0; i < size; i++) {
65  varNames_.push_back(root.get(defaultGroup_, "")[i].get(PARAM_NAME, "").asString());
66  opNames_.push_back(root.get(defaultGroup_, "")[i].get(OPERATION, "").asString());
67  typeNames_.push_back(root.get(defaultGroup_, "")[i].get(TYPE, "").asString());
68  }
69  }
70 }
size
Write out results.
Value get(UInt index, const Value &defaultValue) const
static const std::string PARAM_NAME
UInt size() const
Number of values in array or object.
bool isArray() const
std::vector< std::string > varNames_
std::vector< std::string > typeNames_
static const std::string OPERATION
std::string asString() const
std::vector< std::string > opNames_
bool DataPointDefinition::getDataPointDefinitionFor ( std::string &  defFilePath,
DataPointDefinition dpd,
const std::string *  defaultGroup = nullptr 
)
static

Loads a DataPointDefinition from a specified reference

Definition at line 33 of file DataPointDefinition.cc.

References jsoncollector::JSONSerializer::deserialize(), LEGEND, jsoncollector::FileIO::readStringFromFile(), setDefaultGroup(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by jsoncollector::FastMonitor::addFastPathDefinition(), jsoncollector::FastMonitor::FastMonitor(), and getOperations().

34 {
35  std::string dpdString;
36  bool readOK = FileIO::readStringFromFile(defFilePath, dpdString);
37  // data point definition is missing!
38  if (!readOK) {
39  edm::LogWarning("DataPointDefinition") << "Cannot read from JSON definition path -: " << defFilePath;
40  return false;
41  }
42  if (!defaultGroup) dpd->setDefaultGroup(LEGEND);
43  else dpd->setDefaultGroup(*defaultGroup);
44  JSONSerializer::deserialize(dpd, dpdString);
45  return true;
46 }
static bool readStringFromFile(std::string const &filename, std::string &content)
Definition: FileIO.cc:29
static bool deserialize(JsonSerializable *pObj, std::string &input)
void setDefaultGroup(std::string const &group)
std::string& jsoncollector::DataPointDefinition::getDefFilePath ( )
inline

Definition at line 59 of file DataPointDefinition.h.

References defFilePath_.

std::vector<std::string> const& jsoncollector::DataPointDefinition::getNames ( )
inline

Returns a LegendItem object ref at the specified index

Definition at line 45 of file DataPointDefinition.h.

References varNames_.

Referenced by jsoncollector::FastMonitor::commit(), evf::EvFDaqDirector::getNFilesFromEoLS(), and FedRawDataInputSource::grabNextJsonFile().

45 {return varNames_;}
std::vector< std::string > varNames_
OperationType DataPointDefinition::getOperationFor ( unsigned int  index)

Definition at line 80 of file DataPointDefinition.cc.

References AVG, CAT, HISTO, jsoncollector::OPAVG, jsoncollector::OPCAT, jsoncollector::OPHISTO, opNames_, jsoncollector::OPSAME, jsoncollector::OPSUM, jsoncollector::OPUNKNOWN, SAME, and SUM.

Referenced by jsoncollector::FastMonitor::commit(), and setDefaultGroup().

81 {
82  OperationType opType=OPUNKNOWN;
83  if (opNames_.at(index)== DataPointDefinition::SUM) opType=OPSUM;
84  if (opNames_.at(index)== DataPointDefinition::AVG) opType=OPAVG;
87  if (opNames_.at(index)== DataPointDefinition::CAT) opType=OPCAT;
88  return opType;
89 }
std::vector< std::string > opNames_
std::vector<std::string> const& jsoncollector::DataPointDefinition::getOperations ( )
inline
bool DataPointDefinition::isPopulated ( ) const

Returns true if the legend_ has elements

Definition at line 72 of file DataPointDefinition.cc.

References varNames_.

Referenced by ~DataPointDefinition().

73 {
74  if (!varNames_.empty())
75  return true;
76  return false;
77 }
std::vector< std::string > varNames_
void DataPointDefinition::serialize ( Json::Value root) const
overridevirtual

JSON serialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 48 of file DataPointDefinition.cc.

References Json::Value::append(), defaultGroup_, relativeConstraints::empty, mps_fire::i, OPERATION, opNames_, PARAM_NAME, TYPE, typeNames_, and varNames_.

Referenced by ~DataPointDefinition().

49 {
50  for (unsigned int i = 0; i < varNames_.size(); i++) {
51  Json::Value currentDef;
52  currentDef[PARAM_NAME] = varNames_[i];
53  currentDef[OPERATION] = opNames_[i];
54  if (!typeNames_[i].empty()) //only if it was found
55  currentDef[TYPE] = typeNames_[i];
56  root[defaultGroup_].append(currentDef);
57  }
58 }
static const std::string PARAM_NAME
Value & append(const Value &value)
Append value to array at the end.
Represents a JSON value.
Definition: value.h:111
std::vector< std::string > varNames_
std::vector< std::string > typeNames_
static const std::string OPERATION
std::vector< std::string > opNames_
void jsoncollector::DataPointDefinition::setDefaultGroup ( std::string const &  group)
inline

Member Data Documentation

const std::string DataPointDefinition::ADLER32 = "adler32"
static
const std::string DataPointDefinition::AVG = "avg"
static

Definition at line 64 of file DataPointDefinition.h.

Referenced by getOperationFor().

const std::string DataPointDefinition::BINARYOR = "binaryOr"
static
const std::string DataPointDefinition::CAT = "cat"
static
const std::string DataPointDefinition::DATA = "data"
static

Definition at line 74 of file DataPointDefinition.h.

std::string jsoncollector::DataPointDefinition::defaultGroup_
private

Definition at line 84 of file DataPointDefinition.h.

Referenced by deserialize(), serialize(), and setDefaultGroup().

std::string jsoncollector::DataPointDefinition::defFilePath_
private

Definition at line 83 of file DataPointDefinition.h.

Referenced by getDefFilePath().

const std::string DataPointDefinition::HISTO = "histo"
static

Definition at line 66 of file DataPointDefinition.h.

Referenced by getOperationFor().

const std::string DataPointDefinition::LEGEND = "legend"
static

Definition at line 73 of file DataPointDefinition.h.

Referenced by getDataPointDefinitionFor().

const std::string DataPointDefinition::MERGE = "merge"
static
const std::string DataPointDefinition::OPERATION = "operation"
static

Definition at line 76 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

std::vector<std::string> jsoncollector::DataPointDefinition::opNames_
private
const std::string DataPointDefinition::PARAM_NAME = "name"
static

Definition at line 75 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

const std::string DataPointDefinition::SAME = "same"
static
const std::string DataPointDefinition::SUM = "sum"
static
const std::string DataPointDefinition::TYPE = "type"
static

Definition at line 77 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

std::vector<std::string> jsoncollector::DataPointDefinition::typeNames_
private

Definition at line 81 of file DataPointDefinition.h.

Referenced by addLegendItem(), deserialize(), and serialize().

std::vector<std::string> jsoncollector::DataPointDefinition::varNames_
private

Definition at line 80 of file DataPointDefinition.h.

Referenced by addLegendItem(), deserialize(), getNames(), isPopulated(), and serialize().