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::string const & getDefFilePath () const
 
std::vector< std::string > const & getNames () const
 
OperationType getOperationFor (unsigned int index) const
 
std::vector< std::string > const & getOperations () const
 
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

◆ DataPointDefinition()

jsoncollector::DataPointDefinition::DataPointDefinition ( )
inline

Definition at line 22 of file DataPointDefinition.h.

22 {}

◆ ~DataPointDefinition()

jsoncollector::DataPointDefinition::~DataPointDefinition ( )
inlineoverride

Definition at line 27 of file DataPointDefinition.h.

27 {}

Member Function Documentation

◆ addLegendItem()

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

Definition at line 93 of file DataPointDefinition.cc.

References Skims_PA_cff::name, opNames_, typeNames_, and varNames_.

Referenced by evf::GlobalEvFOutputJSONDef::GlobalEvFOutputJSONDef(), and RawEventFileWriterForBU::RawEventFileWriterForBU().

95  {
96  varNames_.push_back(name);
97  typeNames_.push_back(type);
98  opNames_.push_back(operation);
99 }
std::vector< std::string > varNames_
std::vector< std::string > typeNames_
std::vector< std::string > opNames_

◆ deserialize()

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 defaultGroup_, mps_fire::i, OPERATION, opNames_, PARAM_NAME, TYPE, typeNames_, and varNames_.

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.
static const std::string PARAM_NAME
std::vector< std::string > varNames_
std::vector< std::string > typeNames_
static const std::string OPERATION
std::vector< std::string > opNames_

◆ getDataPointDefinitionFor()

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(), and jsoncollector::FastMonitor::FastMonitor().

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)
Log< level::Warning, false > LogWarning

◆ getDefFilePath() [1/2]

std::string& jsoncollector::DataPointDefinition::getDefFilePath ( )
inline

Definition at line 60 of file DataPointDefinition.h.

References defFilePath_.

◆ getDefFilePath() [2/2]

std::string const& jsoncollector::DataPointDefinition::getDefFilePath ( ) const
inline

Definition at line 61 of file DataPointDefinition.h.

References defFilePath_.

◆ getNames()

std::vector<std::string> const& jsoncollector::DataPointDefinition::getNames ( ) const
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_

◆ getOperationFor()

OperationType DataPointDefinition::getOperationFor ( unsigned int  index) const

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().

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_

◆ getOperations()

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

Definition at line 45 of file DataPointDefinition.h.

References opNames_.

45 { return opNames_; }
std::vector< std::string > opNames_

◆ isPopulated()

bool DataPointDefinition::isPopulated ( ) const

Returns true if the legend_ has elements

Definition at line 72 of file DataPointDefinition.cc.

References varNames_.

72  {
73  if (!varNames_.empty())
74  return true;
75  return false;
76 }
std::vector< std::string > varNames_

◆ serialize()

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 defaultGroup_, relativeConstraints::empty, mps_fire::i, OPERATION, opNames_, PARAM_NAME, TYPE, typeNames_, and varNames_.

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
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_

◆ setDefaultGroup()

void jsoncollector::DataPointDefinition::setDefaultGroup ( std::string const &  group)
inline

Member Data Documentation

◆ ADLER32

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

◆ AVG

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

Definition at line 66 of file DataPointDefinition.h.

Referenced by getOperationFor().

◆ BINARYOR

const std::string DataPointDefinition::BINARYOR = "binaryOr"
static

◆ CAT

const std::string DataPointDefinition::CAT = "cat"
static

◆ DATA

const std::string DataPointDefinition::DATA = "data"
static

Definition at line 76 of file DataPointDefinition.h.

◆ defaultGroup_

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

Definition at line 86 of file DataPointDefinition.h.

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

◆ defFilePath_

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

Definition at line 85 of file DataPointDefinition.h.

Referenced by getDefFilePath().

◆ HISTO

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

Definition at line 68 of file DataPointDefinition.h.

Referenced by getOperationFor().

◆ LEGEND

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

Definition at line 75 of file DataPointDefinition.h.

Referenced by getDataPointDefinitionFor().

◆ MERGE

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

◆ OPERATION

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

Definition at line 78 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

◆ opNames_

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

◆ PARAM_NAME

const std::string DataPointDefinition::PARAM_NAME = "name"
static

Definition at line 77 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

◆ SAME

const std::string DataPointDefinition::SAME = "same"
static

◆ SUM

const std::string DataPointDefinition::SUM = "sum"
static

◆ TYPE

const std::string DataPointDefinition::TYPE = "type"
static

Definition at line 79 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

◆ typeNames_

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

Definition at line 83 of file DataPointDefinition.h.

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

◆ varNames_

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

Definition at line 82 of file DataPointDefinition.h.

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