8 #include "../interface/ObjectMerger.h"
9 #include "../interface/Operations.h"
10 #include "../interface/Utils.h"
11 #include "../interface/FileIO.h"
12 #include "../interface/JSONSerializer.h"
16 using namespace jsoncollector;
19 using std::stringstream;
24 string& outcomeMessage,
bool onlyHistos) {
26 vector<vector<string> > mergedData;
39 =
"JSON files and DEFINITION do not have the same number of elements in vectors!";
45 for (
unsigned int nMetric = 0; nMetric
46 < objectsToMerge.at(0)->getData().size(); nMetric++) {
48 vector<string> metricVector;
49 for (
unsigned int nObj = 0; nObj < objectsToMerge.size(); nObj++)
50 metricVector.push_back(objectsToMerge.at(nObj)->getData()[nMetric]);
51 mergedData.push_back(metricVector);
55 vector<string> outputValues;
56 for (
unsigned int i = 0;
i < mergedData.size();
i++) {
64 strVal = mergedData[
i][mergedData[
i].size() - 1];
72 outputValues.push_back(strVal);
94 string definition = objectsToMerge[0]->getDefinition();
109 cout <<
"Cannot read from JSON definition path: " << defFilePath
123 vector<string> tokens;
124 std::istringstream ss(olCSV);
127 getline(ss, field,
',');
128 tokens.push_back(field);
133 for (
unsigned int i = 0;
i < tokens.size();
i++) {
135 int index = atoi(tokens[
i].c_str());
151 string opResultString =
"N/A";
158 opResultString = ss.str();
165 opResultString = ss.str();
184 cout <<
"Operation " << operationName <<
" is NOT DEFINED!" << endl;
187 return opResultString;
193 for (
unsigned int i = 0;
i < objectsToMerge.size() - 1;
i++) {
195 if (objectsToMerge[
i]->getDefinition().compare(
196 objectsToMerge.at(
i + 1)->getDefinition()) != 0) {
197 outcomeMessage =
"JSON files have inconsistent definitions!";
201 if (objectsToMerge[
i]->
getData().size()
202 != objectsToMerge.at(
i + 1)->getData().size()) {
204 =
"JSON files have inconsistent number of elements in the data vector!";
static std::vector< double > vectorStringToDouble(const std::vector< std::string > &stringVector)
static bool readStringFromFile(std::string &filename, std::string &content)
static const std::string CAT
static const std::string AVG
static std::string histo(const std::vector< std::string > &)
static const std::string SAME
static const std::string HISTO
void addToData(std::string data)
static double sum(std::vector< double >)
void setDefinition(std::string definition)
std::string getOperation() const
static std::string applyOperation(const std::vector< std::string > &dataVector, std::string operationName)
static bool matchExactly(std::string s1, std::string s2)
static double avg(std::vector< double >)
static const std::string SUM
static DataPoint * csvToJson(std::string &olCSV, DataPointDefinition *dpd, std::string defPath)
static bool checkConsistency(const std::vector< DataPoint * > &objectsToMerge, std::string &outcomeMessage)
static DataPoint * merge(const std::vector< DataPoint * > &objectsToMerge, std::string &outcomeMessage, bool onlyHistos)
static bool deserialize(JsonSerializable *pObj, std::string &input)
static std::string cat(const std::vector< std::string > &)
static void intArrayToString(std::vector< int > &theVector, std::string &theString)
static void bumpIndex(std::vector< int > &theVector, unsigned int index)
static bool getDataPointDefinitionFor(std::string defFilePath, DataPointDefinition &def)
LegendItem getLegendFor(unsigned int index) const
static std::string const source
static std::string same(const std::vector< std::string > &)
std::vector< LegendItem > getLegend() const