CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
8 #include "../interface/DataPointDefinition.h"
9 
10 using namespace jsoncollector;
11 using std::string;
12 using std::vector;
13 
14 const string DataPointDefinition::LEGEND = "legend";
15 const string DataPointDefinition::PARAM_NAME = "name";
16 const string DataPointDefinition::OPERATION = "operation";
17 
19 
20 }
21 
22 DataPointDefinition::DataPointDefinition(const vector<LegendItem>& legend) :
23  legend_(legend) {
24 }
25 
27 }
28 
30  for (unsigned int i = 0; i < getLegend().size(); i++) {
31  Json::Value currentDef;
32  currentDef[PARAM_NAME] = getLegendFor(i).getName();
33  currentDef[OPERATION] = getLegendFor(i).getOperation();
34  root[LEGEND].append(currentDef);
35  }
36 }
37 
39  if (root.get(LEGEND, "").isArray()) {
40  unsigned int size = root.get(LEGEND, "").size();
41  for (unsigned int i = 0; i < size; i++) {
42  LegendItem currentLegendItem(
43  root.get(LEGEND, "")[i].get(PARAM_NAME, "").asString(),
44  root.get(LEGEND, "")[i].get(OPERATION, "").asString());
45  legend_.push_back(currentLegendItem);
46  }
47  }
48 }
49 
51  return legend_[index];
52 }
53 
55  if (getLegend().size() > 0)
56  return true;
57  return false;
58 }
Value get(UInt index, const Value &defaultValue) const
int i
Definition: DBlmapReader.cc:9
virtual void deserialize(Json::Value &root)
std::string getName() const
Definition: LegendItem.h:20
Value & append(const Value &value)
Append value to array at the end.
Represents a JSON value.
Definition: value.h:111
UInt size() const
Number of values in array or object.
static const std::string OPERATION
bool isArray() const
std::vector< LegendItem > legend_
std::string getOperation() const
Definition: LegendItem.h:23
virtual void serialize(Json::Value &root) const
static const std::string PARAM_NAME
std::string asString() const
LegendItem getLegendFor(unsigned int index) const
tuple size
Write out results.
string root
initialization
Definition: dbtoconf.py:70
std::vector< LegendItem > getLegend() const