0.08.01
C++ Open Travel Request Parsing Library
Toggle main menu visibility
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
7
#include <
opentrep/bom/GenericBom.hpp
>
8
#include <
opentrep/bom/World.hpp
>
9
#include <
opentrep/bom/Place.hpp
>
10
#include <
opentrep/bom/PlaceList.hpp
>
11
#include <
opentrep/factory/FacSupervisor.hpp
>
12
#include <
opentrep/factory/FacBomAbstract.hpp
>
13
#include <
opentrep/factory/FacWorld.hpp
>
14
#include <
opentrep/service/Logger.hpp
>
15
16
namespace
OPENTREP
{
17
18
FacWorld
* FacWorld::_instance = NULL;
19
20
// //////////////////////////////////////////////////////////////////////
21
FacWorld::~FacWorld
() {
22
_instance = NULL;
23
}
24
25
// //////////////////////////////////////////////////////////////////////
26
FacWorld&
FacWorld::instance
() {
27
28
if
(_instance == NULL) {
29
_instance =
new
FacWorld();
30
assert (_instance != NULL);
31
32
FacSupervisor::instance
().
registerBomFactory
(_instance);
33
}
34
return
*_instance;
35
}
36
37
// //////////////////////////////////////////////////////////////////////
38
World
&
FacWorld::create
() {
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
}
FacBomAbstract.hpp
FacSupervisor.hpp
FacWorld.hpp
GenericBom.hpp
Logger.hpp
OPENTREP_LOG_ERROR
#define OPENTREP_LOG_ERROR(iToBeLogged)
Definition
Logger.hpp:24
PlaceList.hpp
Place.hpp
World.hpp
OPENTREP::FacBomAbstract::_pool
BomPool_T _pool
Definition
FacBomAbstract.hpp:53
OPENTREP::FacSupervisor::instance
static FacSupervisor & instance()
Definition
FacSupervisor.cpp:21
OPENTREP::FacSupervisor::registerBomFactory
void registerBomFactory(FacBomAbstract *)
Definition
FacSupervisor.cpp:31
OPENTREP::FacWorld
Definition
FacWorld.hpp:17
OPENTREP::FacWorld::clone
World & clone(const World &)
Definition
FacWorld.cpp:90
OPENTREP::FacWorld::instance
static FacWorld & instance()
Definition
FacWorld.cpp:26
OPENTREP::FacWorld::create
World & create()
Definition
FacWorld.cpp:38
OPENTREP::FacWorld::linkPlaceToWorld
static void linkPlaceToWorld(const bool iNeedsGeneric, World &, Place &)
Definition
FacWorld.cpp:51
OPENTREP::FacWorld::~FacWorld
virtual ~FacWorld()
Definition
FacWorld.cpp:21
OPENTREP::Place
Class modelling a place/POR (point of reference).
Definition
Place.hpp:29
OPENTREP::Place::describeShortKey
std::string describeShortKey() const
Definition
Place.hpp:1060
OPENTREP::Place::getDocID
const XapianDocID_T & getDocID() const
Definition
Place.hpp:474
OPENTREP::World
Definition
World.hpp:20
OPENTREP::World::describeKey
std::string describeKey() const
Definition
World.cpp:34
OPENTREP
Definition
BasChronometer.cpp:10
OPENTREP::GenericBom_T
std::pair< BomType::EN_BomType, BomAbstract * > GenericBom_T
Definition
GenericBom.hpp:19
OPENTREP::XapianDocID_T
unsigned int XapianDocID_T
Definition
OPENTREP_Types.hpp:650
OPENTREP::BomType::PLACE
@ PLACE
Definition
BomType.hpp:17
Generated on
for OpenTREP by
1.17.0