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 22 of file DataPointDefinition.h.

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

Definition at line 27 of file DataPointDefinition.h.

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

27 {}

Member Function Documentation

void DataPointDefinition::addLegendItem ( std::string const &  name,
std::string const &  type,
std::string const &  operation 
)
void DataPointDefinition::deserialize ( Json::Value root)
overridevirtual

JSON deserialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 61 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 32 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)
43  dpd->setDefaultGroup(LEGEND);
44  else
45  dpd->setDefaultGroup(*defaultGroup);
46  JSONSerializer::deserialize(dpd, dpdString);
47  return true;
48 }
static bool readStringFromFile(std::string const &filename, std::string &content)
Definition: FileIO.cc:28
static bool deserialize(JsonSerializable *pObj, std::string &input)
void setDefaultGroup(std::string const &group)
std::string& jsoncollector::DataPointDefinition::getDefFilePath ( )
inline

Definition at line 60 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 44 of file DataPointDefinition.h.

References varNames_.

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

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

Definition at line 78 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().

78  {
79  OperationType opType = OPUNKNOWN;
81  opType = OPSUM;
83  opType = OPAVG;
85  opType = OPSAME;
87  opType = OPHISTO;
89  opType = OPCAT;
90  return opType;
91 }
std::vector< std::string > opNames_
std::vector<std::string> const& jsoncollector::DataPointDefinition::getOperations ( )
inline

Definition at line 45 of file DataPointDefinition.h.

References getDataPointDefinitionFor(), opNames_, and AlCaHLTBitMon_QueryRunRegistry::string.

45 { return opNames_; }
std::vector< std::string > opNames_
bool DataPointDefinition::isPopulated ( ) const

Returns true if the legend_ has elements

Definition at line 72 of file DataPointDefinition.cc.

References varNames_.

Referenced by ~DataPointDefinition().

72  {
73  if (!varNames_.empty())
74  return true;
75  return false;
76 }
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 50 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().

50  {
51  for (unsigned int i = 0; i < varNames_.size(); i++) {
52  Json::Value currentDef;
53  currentDef[PARAM_NAME] = varNames_[i];
54  currentDef[OPERATION] = opNames_[i];
55  if (!typeNames_[i].empty()) //only if it was found
56  currentDef[TYPE] = typeNames_[i];
57  root[defaultGroup_].append(currentDef);
58  }
59 }
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:99
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 65 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 75 of file DataPointDefinition.h.

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

Definition at line 85 of file DataPointDefinition.h.

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

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

Definition at line 84 of file DataPointDefinition.h.

Referenced by getDefFilePath().

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

Definition at line 67 of file DataPointDefinition.h.

Referenced by getOperationFor().

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

Definition at line 74 of file DataPointDefinition.h.

Referenced by getDataPointDefinitionFor().

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

Definition at line 77 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 76 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 78 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

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

Definition at line 82 of file DataPointDefinition.h.

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

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

Definition at line 81 of file DataPointDefinition.h.

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