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
SphinxSearchInterface.hpp
Go to the documentation of this file.
1 
15 #ifndef SPHINX_SEARCH_INTERFACE_HPP
16 #define SPHINX_SEARCH_INTERFACE_HPP
17 
18 #include <iostream>
19 #include <time.h>
20 #include <sys/time.h>
21 
22 namespace HCE
23 {
24 namespace sphinx
25 {
26 class SphinxInputJsonMessage;
27 class SphinxOutputJsonMessage;
28 //-----------------------------------------------------------------------------
29 namespace sphinx_search_const
30 {
31  const bool searchdStart = true;
32  const bool searchdNotStart = false;
33  const bool searchdStop = true;
34  const bool searchdNotStop = false;
35 
36  const int startStopSearchdLimit = 10;
37  const std::string defaultHost = "127.0.0.1";
38  const unsigned int defaultPort = 9312;
39  const unsigned int maxAllowedPort = 10312;
40  const std::string searchdListen = "searchd.listen";
41  const std::string searchdMaxMatches = "searchd.max_matches";
42  const std::string searchdLogName = "searchd.log";
43  const std::string searchdLogFile = "searchd.log";
44  const std::string searchdPidName = "searchd.pid_file";
45  const std::string searchdPidFileName = "searchd";
46  const std::string searchdPidFileExt = "pid";
47  const std::string searchdQueryLogName = "searchd.query_log";
48  const std::string searchdQueryLogFile = "query.log";
49 
50  const std::string searchdGoodStatusFlag = "searchd status";
51 
52  const std::string indexNameField = "index";
53  const std::string sourceNameField = "source";
54  const std::string pathNameField = "path";
55  const std::string xmlpipeCommandNameField = "xmlpipe_command";
56 
57  const std::string branchPropertyFile = "branch.property";
58  const std::string branchConfigFile = "branch.cfg";
59  const std::string sphinxTemplateFile = "sphinx.template";
60  const std::string sphinxPropertyFile = "sphinx.property";
61  const std::string sphinxSchemaFile = "schema.xml";
62  const std::string sphinxConfigName = "sphinx.conf";
63 
64 // const std::string defaultIndexName = "default_index";
65  const std::string defaultBranchName = "default_branch";
66 
67  const std::string defaultHomeDir = ".";
68  const std::string defaultDataDir = "data";
69  const std::string defaultRunDir = "run";
70  const std::string defaultLogDir = "log";
71  const std::string defaultEtcDir = "etc";
72 }
73 //-----------------------------------------------------------------------------
75 {
76 public:
78  virtual ~SphinxSearchInterface(void) {}
79 
80  virtual std::string Process(const std::string& json)=0;
82 
83  void setErrorMsg(const std::string& errorMsg_) {errorMsg=errorMsg_;}
84  std::string getErrorMsg(void) const {return errorMsg;}
85 
86  void setErrorCode(unsigned int errorCode_) {errorCode=errorCode_;}
87  unsigned int getErrorCode(void) const {return errorCode;}
88 
89  void isError(bool isError_) {_isError=isError_;}
90  bool isError(void) const {return _isError;}
91 
92 protected:
93  std::string errorMsg;
94  unsigned int errorCode;
95  bool _isError;
96 
97  bool insensitiveCompare(const std::string& lhs, const std::string& rhs);
98 public:
99  static size_t getTimeInterval(timeval& start, timeval& stop);
100 };
101 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
103 } // end namespace sphinx
104 } // end namespace HCE
105 
106 #endif // SPHINX_SEARCH_INTERFACE_HPP