hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxWeightCalculator.hpp
Go to the documentation of this file.
1 
14 #ifndef SPHINX_WEIGHT_CALCULATOR_HPP
15 #define SPHINX_WEIGHT_CALCULATOR_HPP
16 
17 #include <Poco/SharedPtr.h>
18 
19 #include "SphinxResultData.hpp"
20 
21 namespace HCE
22 {
23 namespace sphinx
24 {
25 //-----------------------------------------------------------------------------
27 {
28 public:
30  {
32  };
33 public:
35  virtual ~CalculateStrategy(void) {}
36 
37  virtual void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData)=0;
38 
39  std::string getLogString(void) const {return logString;}
40 
41 protected:
42  static void weightToStream(const std::string& input, std::ostream& os) throw (std::exception);
43 
44  std::string logString;
45 };
46 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
49 {
50 public:
51  static Poco::SharedPtr<CalculateStrategy> create(const std::string& weightAlgirithm);
52 };
53 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
56 {
57 public:
58  SphinxWeightCalculator(void) :inherited(), strategy() {}
59  virtual ~SphinxWeightCalculator(void) {}
60 
61  void setStrategy(Poco::SharedPtr<CalculateStrategy> strategy_) {strategy=strategy_;}
62  Poco::SharedPtr<CalculateStrategy>& getStrategy(void) {return strategy;}
63 
64  void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData);
65 private:
66  Poco::SharedPtr<CalculateStrategy> strategy;
67  typedef CalculateStrategy inherited;
68 };
69 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 {
73 public:
75  virtual ~CalculateStrategyDefault(void) {}
76 
77  void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData);
78 
80 };
81 //-----------------------------------------------------------------------------
82 //-----------------------------------------------------------------------------
84 {
85 public:
88 
89  void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData);
90 
92 };
93 //-----------------------------------------------------------------------------
94 //-----------------------------------------------------------------------------
95 } // namespace sphinx
96 } // namespace HCE
97 
98 #endif // SPHINX_WEIGHT_CALCULATOR_HPP