OpenTREP Logo  0.07.4
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OPENTREP_ServiceContext.hpp
Go to the documentation of this file.
1 #ifndef __OPENTREP_SVC_OPENTREPSERVICECONTEXT_HPP
2 #define __OPENTREP_SVC_OPENTREPSERVICECONTEXT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <string>
9 // OpenTrep
11 #include <opentrep/DBType.hpp>
14 
15 // Forward declarations
16 namespace soci {
17  class session;
18 }
19 
20 namespace OPENTREP {
21 
22  // Forward declarations
23  class World;
24 
30  public:
31  // /////////////////// Getters //////////////////////
35  World* getWorld() const {
36  return _world;
37  }
38 
42  World& getWorldHandler() const;
43 
47  const PORFilePath_T& getPORFilePath() const {
48  return _porFilePath;
49  }
50 
55  return _travelDBFilePath;
56  }
57 
61  const DBType& getSQLDBType() const {
62  return _sqlDBType;
63  }
64 
69  return _sqlDBConnectionString;
70  }
71 
76  return _deploymentNumber;
77  }
78 
83  return _shouldIndexNonIATAPOR;
84  }
85 
90  return _shouldIndexPORInXapian;
91  }
92 
97  return _shouldAddPORInSQLDB;
98  }
99 
104  return _transliterator;
105  }
106 
107  public:
108  // ////////////////// Setters /////////////////////
112  void setWorld (World& ioWorld) {
113  _world = &ioWorld;
114  }
115 
119  void setPORFilePath (const std::string& iPORFilePath) {
120  _porFilePath = PORFilePath_T (iPORFilePath);
121  }
122 
126  void setTravelDBFilePath (const std::string& iTravelDBFilePath) {
127  _travelDBFilePathPrefix = TravelDBFilePath_T (iTravelDBFilePath);
128  updateXapianAndSQLDBConnectionWithDeploymentNumber();
129  }
130 
134  void setSQLDBType (const DBType& iDBType) {
135  _sqlDBType = iDBType;
136  }
137 
141  void setSQLDBConnectionString (const std::string& iSQLDBConnStr) {
142  _sqlDBConnectionStringWPfxDBName = SQLDBConnectionString_T (iSQLDBConnStr);
143  updateXapianAndSQLDBConnectionWithDeploymentNumber();
144  }
145 
149  void setDeploymentNumber (const DeploymentNumber_T& iDeploymentNumber) {
150  _deploymentNumber = iDeploymentNumber;
151  updateXapianAndSQLDBConnectionWithDeploymentNumber();
152  }
153 
157  void setShouldIncludeAllPORFlag (const shouldIndexNonIATAPOR_T& iShouldIndexNonIATAPOR) {
158  _shouldIndexNonIATAPOR = iShouldIndexNonIATAPOR;
159  }
160 
164  void setShouldIndexPORInXapianFlag (const shouldIndexPORInXapian_T& iShouldIndexPORInXapian) {
165  _shouldIndexPORInXapian = iShouldIndexPORInXapian;
166  }
167 
171  void setShouldAddPORInSQLDB (const shouldAddPORInSQLDB_T& iShouldAddPORInSQLDB) {
172  _shouldAddPORInSQLDB = iShouldAddPORInSQLDB;
173  }
174 
178  void setTransliterator (const OTransliterator& iTransliterator) {
179  _transliterator = iTransliterator;
180  }
181 
182 
183  public:
184  // ///////// Display Methods //////////
188  const std::string shortDisplay() const;
189 
193  const std::string display() const;
194 
195 
196  private:
197  // /////// Construction / initialisation ////////
207  const DBType&, const SQLDBConnectionString_T&,
208  const DeploymentNumber_T&);
209 
224  const DBType&, const SQLDBConnectionString_T&,
225  const DeploymentNumber_T&,
228  const shouldAddPORInSQLDB_T&);
229 
249  void updateXapianAndSQLDBConnectionWithDeploymentNumber();
250 
255 
260 
264  virtual ~OPENTREP_ServiceContext();
265 
266 
267  private:
268  // ////////////// Attributes ///////////////
272  World* _world;
273 
277  PORFilePath_T _porFilePath;
278 
305  DeploymentNumber_T _deploymentNumber;
306 
310  TravelDBFilePath_T _travelDBFilePathPrefix;
311 
315  TravelDBFilePath_T _travelDBFilePath;
316 
320  DBType _sqlDBType;
321 
335  SQLDBConnectionString_T _sqlDBConnectionStringWPfxDBName;
336 
352  SQLDBConnectionString_T _sqlDBConnectionString;
353 
380  shouldIndexNonIATAPOR_T _shouldIndexNonIATAPOR;
381 
385  shouldIndexPORInXapian_T _shouldIndexPORInXapian;
386 
390  shouldAddPORInSQLDB_T _shouldAddPORInSQLDB;
391 
395  OTransliterator _transliterator;
396  };
397 
398 }
399 #endif // __OPENTREP_SVC_OPENTREPSERVICECONTEXT_HPP
const shouldIndexNonIATAPOR_T & getShouldIncludeAllPORFlag() const
void setSQLDBConnectionString(const std::string &iSQLDBConnStr)
void setTransliterator(const OTransliterator &iTransliterator)
const TravelDBFilePath_T & getTravelDBFilePath() const
const PORFilePath_T & getPORFilePath() const
Class holding the context of the OpenTrep services.
void setShouldIncludeAllPORFlag(const shouldIndexNonIATAPOR_T &iShouldIndexNonIATAPOR)
void setTravelDBFilePath(const std::string &iTravelDBFilePath)
bool shouldIndexNonIATAPOR_T
const OTransliterator & getTransliterator() const
const shouldAddPORInSQLDB_T & getShouldAddPORInSQLDB() const
const SQLDBConnectionString_T & getSQLDBConnectionString() const
void setPORFilePath(const std::string &iPORFilePath)
void setShouldAddPORInSQLDB(const shouldAddPORInSQLDB_T &iShouldAddPORInSQLDB)
const shouldIndexPORInXapian_T & getShouldIndexPORInXapianFlag() const
Enumeration of database types.
Definition: DBType.hpp:17
bool shouldAddPORInSQLDB_T
Factory for an OPENTREP_ServiceContext object.
bool shouldIndexPORInXapian_T
void setShouldIndexPORInXapianFlag(const shouldIndexPORInXapian_T &iShouldIndexPORInXapian)
const DeploymentNumber_T & getDeploymentNumber() const
void setSQLDBType(const DBType &iDBType)
void setDeploymentNumber(const DeploymentNumber_T &iDeploymentNumber)
unsigned short DeploymentNumber_T