HCE project C++ developers source code library  1.1.1
HCE project developer library
 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  void weightToStream(const std::string& input, std::ostream& os) throw (std::exception);
41 protected:
42  std::string logString;
43 };
44 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
47 {
48 public:
49  Poco::SharedPtr<CalculateStrategy> create(const std::string& weightAlgirithm);
50 };
51 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 {
55 public:
56  SphinxWeightCalculator(void) :inherited(), strategy() {}
57  virtual ~SphinxWeightCalculator(void) {}
58 
59  void setStrategy(Poco::SharedPtr<CalculateStrategy> strategy_) {strategy=strategy_;}
60  Poco::SharedPtr<CalculateStrategy>& getStrategy(void) {return strategy;}
61 
62  void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData);
63 private:
64  Poco::SharedPtr<CalculateStrategy> strategy;
65  typedef CalculateStrategy inherited;
66 };
67 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
70 {
71 public:
73  virtual ~CalculateStrategyDefault(void) {}
74 
75  void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData);
76 
78 };
79 //-----------------------------------------------------------------------------
80 //-----------------------------------------------------------------------------
82 {
83 public:
86 
87  void calculate(const std::vector<std::string>& orderFields, SphinxResultData& resultData);
88 
90 };
91 //-----------------------------------------------------------------------------
92 //-----------------------------------------------------------------------------
93 } // namespace sphinx
94 } // namespace HCE
95 
96 #endif // SPHINX_WEIGHT_CALCULATOR_HPP