OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
FacWorld.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// C
5#include <assert.h>
6// OPENTREP
15
16namespace OPENTREP {
17
18 FacWorld* FacWorld::_instance = NULL;
19
20 // //////////////////////////////////////////////////////////////////////
22 _instance = NULL;
23 }
24
25 // //////////////////////////////////////////////////////////////////////
26 FacWorld& FacWorld::instance () {
27
28 if (_instance == NULL) {
29 _instance = new FacWorld();
30 assert (_instance != NULL);
31
33 }
34 return *_instance;
35 }
36
37 // //////////////////////////////////////////////////////////////////////
39 World* oWorld_ptr = NULL;
40
41 oWorld_ptr = new World ();
42 assert (oWorld_ptr != NULL);
43
44 // The new object is added to the Bom pool
45 _pool.push_back (oWorld_ptr);
46
47 return *oWorld_ptr;
48 }
49
50 // //////////////////////////////////////////////////////////////////////
51 void FacWorld::linkPlaceToWorld (const bool iNeedsGeneric,
52 World& ioWorld, Place& ioPlace) {
53 // Link the World to the Place, and vice versa
54 ioPlace._world = &ioWorld;
55
56 // Retrieve the Xapian document ID of the Place object
57 const XapianDocID_T& lDocID = ioPlace.getDocID();
58
59 // Build a generic BOM object
60 const GenericBom_T lGenericBom (BomType::PLACE, &ioPlace);
61
62 if (iNeedsGeneric == true) {
63 // Add the Place pointer to the dedicated list within the World object
64 const bool insertSucceeded = ioWorld._genericBomList.
65 insert (GenericBomList_T::value_type (lDocID, lGenericBom)).second;
66 if (insertSucceeded == false) {
67 OPENTREP_LOG_ERROR ("Insertion failed for " << ioWorld.describeKey()
68 << " and " << ioPlace.describeShortKey());
69 assert (insertSucceeded == true);
70 }
71
72 // Add the Place pointer to the dedicated list within the World object
73 /*
74 const bool insertSucceeded2 = ioWorld._placeDirectList.
75 insert (PlaceDirectList_T::value_type (lPlaceID, &ioPlace)).second;
76 if (insertSucceeded2 == false) {
77 OPENTREP_LOG_ERROR ("Insertion failed for " << ioWorld.describeKey()
78 << " and " << ioPlace.describeShortKey());
79 assert (insertSucceeded2 == true);
80 }
81 */
82
83 }
84
85 // Add the Place pointer to the dedicated list within the World object
86 ioWorld._placeOrderedList.push_back (&ioPlace);
87 }
88
89 // //////////////////////////////////////////////////////////////////////
90 World& FacWorld::clone (const World& iWorld) {
91 World* oWorld_ptr = NULL;
92
93 oWorld_ptr = new World (iWorld);
94 assert (oWorld_ptr != NULL);
95
96 // The new object is added to the Bom pool
97 _pool.push_back (oWorld_ptr);
98
99 return *oWorld_ptr;
100 }
101
102}
#define OPENTREP_LOG_ERROR(iToBeLogged)
Definition Logger.hpp:24
static FacSupervisor & instance()
void registerBomFactory(FacBomAbstract *)
World & clone(const World &)
Definition FacWorld.cpp:90
static FacWorld & instance()
Definition FacWorld.cpp:26
static void linkPlaceToWorld(const bool iNeedsGeneric, World &, Place &)
Definition FacWorld.cpp:51
virtual ~FacWorld()
Definition FacWorld.cpp:21
Class modelling a place/POR (point of reference).
Definition Place.hpp:29
std::string describeShortKey() const
Definition Place.hpp:1060
const XapianDocID_T & getDocID() const
Definition Place.hpp:474
std::string describeKey() const
Definition World.cpp:34
std::pair< BomType::EN_BomType, BomAbstract * > GenericBom_T
unsigned int XapianDocID_T