hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CalculatorNodeExecution.hpp
Go to the documentation of this file.
1 
14 #ifndef CALCULATOR_NODE_EXECUTION_HPP
15 #define CALCULATOR_NODE_EXECUTION_HPP
16 
17 #include <Poco/SharedPtr.h>
18 
19 #include "DRCECommonList.hpp"
20 #include "Dictionary.hpp"
21 #include "ResourceUsageManager.hpp"
22 
23 namespace HCE
24 {
25 namespace handlers
26 {
27 //-----------------------------------------------------------------------------
28 class CalculatorAlgorithmData : public Dictionary <std::string, double>
29 {
30  static const char DELIMITER = ',';
31 public:
32  explicit CalculatorAlgorithmData(unsigned int order_=0);
36 
39 
40  void setOrder(unsigned int order_) {order=order_;}
41  unsigned int getOrder(void) const {return order;}
42 private:
43  unsigned int order;
44 
45  typedef Dictionary <std::string, double> inherited;
46 };
47 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 class CalculatorNodeResourceData : public Dictionary <std::string, double>
50 {
51 public:
52  explicit CalculatorNodeResourceData(const std::string& identity_="");
56 
59 
60  void setIdentity(const std::string& identity_) {identity=identity_;}
61  std::string getIdentity(void) const {return identity;}
62 private:
63  std::string identity;
64 
65  typedef Dictionary <std::string, double> inherited;
66 };
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 {
73 public:
74  enum class Types
75  {
76  caDefault=0
77  };
78 
80  virtual ~CalculatorAlgorithm(void) {}
81 
82  virtual std::string calculate(const CalculatorAlgorithmData& algorithmData, NodeResourceDataList& nodeDataList, ResourceUsageManager& resourceUsageManager) = 0;
83  virtual std::vector<double> getListWeights(const CalculatorAlgorithmData& algorithmData, ResourceUsageCollection& collection)=0;
84 };
85 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
88 {
89 public:
91  virtual ~CalculatorAlgorithmDefault(void) {}
92 
93  std::string calculate(const CalculatorAlgorithmData& algorithmData, NodeResourceDataList& nodeDataList, ResourceUsageManager& resourceUsageManager);
94  std::vector<double> getListWeights(const CalculatorAlgorithmData& algorithmData, ResourceUsageCollection& collectionr);
95 private:
96  typedef CalculatorAlgorithm inherited;
97 };
98 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
102 {
103 public:
104  explicit CalculatorNodeExecution(CalculatorAlgorithm::Types type=CalculatorAlgorithm::Types::caDefault);
105  virtual ~CalculatorNodeExecution(void) {}
106 
107  std::string calculate(const CalculatorAlgorithmData& algorithmData, NodeResourceDataList& nodeDataList, ResourceUsageManager& resourceUsageManager);
108  std::vector<double> getListWeights(const CalculatorAlgorithmData& algorithmData, ResourceUsageCollection& collection);
109 
110 private:
111  Poco::SharedPtr<CalculatorAlgorithm> createAlgorithm(CalculatorAlgorithm::Types type);
112 private:
113  Poco::SharedPtr<CalculatorAlgorithm> algorithm;
114 };
115 //-----------------------------------------------------------------------------
116 //-----------------------------------------------------------------------------
117 } // end namespace handlers
118 } // end namespace HCE
119 
120 #endif // CALCULATOR_NODE_EXECUTION_HPP