Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:45:51

0001 /*
0002  * DataPointDefinition.h
0003  *
0004  *  Created on: Sep 24, 2012
0005  *      Author: aspataru
0006  */
0007 
0008 #ifndef DATAPOINTDEFINITION_H_
0009 #define DATAPOINTDEFINITION_H_
0010 
0011 #include "EventFilter/Utilities/interface/JsonMonitorable.h"
0012 #include "EventFilter/Utilities/interface/JsonSerializable.h"
0013 #include <string>
0014 #include <vector>
0015 
0016 namespace jsoncollector {
0017 
0018   class JsonMonConfig;
0019 
0020   class DataPointDefinition : public JsonSerializable {
0021   public:
0022     DataPointDefinition() {}
0023 
0024     //DataPointDefinition(std::string const& prefix) : namePrefix_(prefix) {}
0025     //DataPointDefinition(const std::vector<std::string>& names, const std::vector<std::string>& operations);
0026 
0027     ~DataPointDefinition() override {}
0028 
0029     /**
0030    * JSON serialization procedure for this class
0031    */
0032     void serialize(Json::Value& root) const override;
0033     /**
0034    * JSON deserialization procedure for this class
0035    */
0036     void deserialize(Json::Value& root) override;
0037     /**
0038    * Returns true if the legend_ has elements
0039    */
0040     bool isPopulated() const;
0041     /**
0042    * Returns a LegendItem object ref at the specified index
0043    */
0044     std::vector<std::string> const& getNames() const { return varNames_; }
0045     std::vector<std::string> const& getOperations() const { return opNames_; }
0046 
0047     /**
0048    * Loads a DataPointDefinition from a specified reference
0049    */
0050     static bool getDataPointDefinitionFor(std::string& defFilePath,
0051                                           DataPointDefinition* dpd,
0052                                           const std::string* defaultGroup = nullptr);
0053 
0054     void setDefaultGroup(std::string const& group) { defaultGroup_ = group; }
0055 
0056     void addLegendItem(std::string const& name, std::string const& type, std::string const& operation);
0057 
0058     OperationType getOperationFor(unsigned int index) const;
0059 
0060     std::string& getDefFilePath() { return defFilePath_; }
0061     std::string const& getDefFilePath() const { return defFilePath_; }
0062     //void populateMonConfig(std::vector<JsonMonConfig>& monConfig);
0063 
0064     //known JSON operation names
0065     static const std::string SUM;
0066     static const std::string AVG;
0067     static const std::string SAME;
0068     static const std::string HISTO;
0069     static const std::string CAT;
0070     static const std::string MERGE;
0071     static const std::string BINARYOR;
0072     static const std::string ADLER32;
0073 
0074     // JSON field names
0075     static const std::string LEGEND;
0076     static const std::string DATA;
0077     static const std::string PARAM_NAME;
0078     static const std::string OPERATION;
0079     static const std::string TYPE;
0080 
0081   private:
0082     std::vector<std::string> varNames_;
0083     std::vector<std::string> typeNames_;
0084     std::vector<std::string> opNames_;
0085     std::string defFilePath_;
0086     std::string defaultGroup_;
0087 
0088     //  std::string namePrefix_;
0089   };
0090 }  // namespace jsoncollector
0091 
0092 #endif /* DATAPOINTDEFINITION_H_ */