CMS 3D CMS Logo

DataPointDefinition.cc
Go to the documentation of this file.
1 /*
2  * DataPointDefinition.cc
3  *
4  * Created on: Sep 24, 2012
5  * Author: aspataru
6  */
7 
13 
14 using namespace jsoncollector;
15 
24 
30 
31 //static member implementation
34  const std::string* defaultGroup) {
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 }
49 
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 }
60 
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 }
71 
73  if (!varNames_.empty())
74  return true;
75  return false;
76 }
77 
79  OperationType opType = OPUNKNOWN;
81  opType = OPSUM;
83  opType = OPAVG;
85  opType = OPSAME;
87  opType = OPHISTO;
89  opType = OPCAT;
90  return opType;
91 }
92 
94  std::string const& type,
95  std::string const& operation) {
96  varNames_.push_back(name);
97  typeNames_.push_back(type);
98  opNames_.push_back(operation);
99 }
size
Write out results.
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
void serialize(Json::Value &root) const override
static const std::string PARAM_NAME
Represents a JSON value.
Definition: value.h:99
static bool getDataPointDefinitionFor(std::string &defFilePath, DataPointDefinition *dpd, const std::string *defaultGroup=nullptr)
std::vector< std::string > varNames_
static bool readStringFromFile(std::string const &filename, std::string &content)
Definition: FileIO.cc:28
std::vector< std::string > typeNames_
static const std::string OPERATION
static bool deserialize(JsonSerializable *pObj, std::string &input)
OperationType getOperationFor(unsigned int index) const
void deserialize(Json::Value &root) override
void setDefaultGroup(std::string const &group)
Log< level::Warning, false > LogWarning
std::vector< std::string > opNames_