CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
virtual void deserialize (Json::Value &root)
 
std::string & getDefFilePath ()
 
std::vector< std::string > const & getNames ()
 
OperationType getOperationFor (unsigned int index)
 
std::vector< std::string > const & getOperations ()
 
bool isPopulated () const
 
virtual void serialize (Json::Value &root) const
 
void setDefaultGroup (std::string const &group)
 
virtual ~DataPointDefinition ()
 
- 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 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 {}
virtual jsoncollector::DataPointDefinition::~DataPointDefinition ( )
inlinevirtual

Definition at line 28 of file DataPointDefinition.h.

28 {}

Member Function Documentation

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

Definition at line 90 of file DataPointDefinition.cc.

References opNames_, typeNames_, and varNames_.

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

91 {
92  varNames_.push_back(name);
93  typeNames_.push_back(type);
94  opNames_.push_back(operation);
95 }
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)
virtual

JSON deserialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 59 of file DataPointDefinition.cc.

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

60 {
61  if (root.get(defaultGroup_, "").isArray()) {
62  unsigned int size = root.get(defaultGroup_, "").size();
63  for (unsigned int i = 0; i < size; i++) {
64  varNames_.push_back(root.get(defaultGroup_, "")[i].get(PARAM_NAME, "").asString());
65  opNames_.push_back(root.get(defaultGroup_, "")[i].get(OPERATION, "").asString());
66  typeNames_.push_back(root.get(defaultGroup_, "")[i].get(TYPE, "").asString());
67  }
68  }
69 }
Value get(UInt index, const Value &defaultValue) const
int i
Definition: DBlmapReader.cc:9
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
tuple size
Write out results.
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(), and jsoncollector::FastMonitor::FastMonitor().

33 {
34  std::string dpdString;
35  bool readOK = FileIO::readStringFromFile(defFilePath, dpdString);
36  // data point definition is missing!
37  if (!readOK) {
38  edm::LogWarning("DataPointDefinition") << "Cannot read from JSON definition path -: " << defFilePath;
39  return false;
40  }
41  if (!defaultGroup) dpd->setDefaultGroup(LEGEND);
42  else dpd->setDefaultGroup(*defaultGroup);
43  JSONSerializer::deserialize(dpd, dpdString);
44  return true;
45 }
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(), and FedRawDataInputSource::grabNextJsonFile().

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

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

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

Definition at line 46 of file DataPointDefinition.h.

References opNames_.

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

Returns true if the legend_ has elements

Definition at line 71 of file DataPointDefinition.cc.

References varNames_.

72 {
73  if (varNames_.size() > 0)
74  return true;
75  return false;
76 }
std::vector< std::string > varNames_
void DataPointDefinition::serialize ( Json::Value root) const
virtual

JSON serialization procedure for this class

Implements jsoncollector::JsonSerializable.

Definition at line 47 of file DataPointDefinition.cc.

References Json::Value::append(), defaultGroup_, i, OPERATION, opNames_, PARAM_NAME, findQualityFiles::size, TYPE, typeNames_, and varNames_.

48 {
49  for (unsigned int i = 0; i < varNames_.size(); i++) {
50  Json::Value currentDef;
51  currentDef[PARAM_NAME] = varNames_[i];
52  currentDef[OPERATION] = opNames_[i];
53  if (typeNames_[i].size()) //only if it was found
54  currentDef[TYPE] = typeNames_[i];
55  root[defaultGroup_].append(currentDef);
56  }
57 }
int i
Definition: DBlmapReader.cc:9
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
tuple size
Write out results.
std::vector< std::string > opNames_
void jsoncollector::DataPointDefinition::setDefaultGroup ( std::string const &  group)
inline

Member Data Documentation

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

Definition at line 69 of file DataPointDefinition.h.

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

Definition at line 67 of file DataPointDefinition.h.

Referenced by getOperationFor().

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

Definition at line 73 of file DataPointDefinition.h.

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

Definition at line 83 of file DataPointDefinition.h.

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

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

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

Referenced by getDataPointDefinitionFor().

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

Definition at line 68 of file DataPointDefinition.h.

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

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

Referenced by deserialize(), and serialize().

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

Definition at line 65 of file DataPointDefinition.h.

Referenced by getOperationFor().

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

Definition at line 63 of file DataPointDefinition.h.

Referenced by getOperationFor().

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

Definition at line 76 of file DataPointDefinition.h.

Referenced by deserialize(), and serialize().

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

Definition at line 80 of file DataPointDefinition.h.

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

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

Definition at line 79 of file DataPointDefinition.h.

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