OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FacPlace.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 // OpenTrep
7 #include <opentrep/bom/Place.hpp>
10 
11 namespace OPENTREP {
12 
13  FacPlace* FacPlace::_instance = NULL;
14 
15  // //////////////////////////////////////////////////////////////////////
16  FacPlace::FacPlace() {
17  }
18 
19  // //////////////////////////////////////////////////////////////////////
20  FacPlace::FacPlace (const FacPlace&) {
21  }
22 
23  // //////////////////////////////////////////////////////////////////////
25  _instance = NULL;
26  }
27 
28  // //////////////////////////////////////////////////////////////////////
30 
31  if (_instance == NULL) {
32  _instance = new FacPlace();
33  assert (_instance != NULL);
34 
36  }
37  return *_instance;
38  }
39 
40  // //////////////////////////////////////////////////////////////////////
42  Place* oPlace_ptr = NULL;
43 
44  oPlace_ptr = new Place();
45  assert (oPlace_ptr != NULL);
46 
47  // The new object is added to the Bom pool
48  _pool.push_back (oPlace_ptr);
49 
50  return *oPlace_ptr;
51  }
52 
53  // //////////////////////////////////////////////////////////////////////
54  Place& FacPlace::create (const LocationKey& iLocationKey) {
55  Place* oPlace_ptr = NULL;
56 
57  oPlace_ptr = new Place (iLocationKey);
58  assert (oPlace_ptr != NULL);
59 
60  // The new object is added to the Bom pool
61  _pool.push_back (oPlace_ptr);
62 
63  return *oPlace_ptr;
64  }
65 
66  // //////////////////////////////////////////////////////////////////////
67  Place& FacPlace::create (const Location& iLocation) {
68  Place* oPlace_ptr = NULL;
69 
70  oPlace_ptr = new Place (iLocation);
71  assert (oPlace_ptr != NULL);
72 
73  // The new object is added to the Bom pool
74  _pool.push_back (oPlace_ptr);
75 
76  return *oPlace_ptr;
77  }
78 
79  // //////////////////////////////////////////////////////////////////////
80  Place& FacPlace::clone (const Place& iPlace) {
81  Place* oPlace_ptr = NULL;
82 
83  oPlace_ptr = new Place (iPlace);
84  assert (oPlace_ptr != NULL);
85 
86  // The new object is added to the Bom pool
87  _pool.push_back (oPlace_ptr);
88 
89  return *oPlace_ptr;
90  }
91 
92  // //////////////////////////////////////////////////////////////////////
94  Place& ioExtraPlace) {
95  // Link the main Place to the extra Place, and vice versa
96  ioExtraPlace._mainPlace = &ioMainPlace;
97 
98  // Add the extra Place to the main Place internal map (of extra
99  // Place objects)
100  ioMainPlace._extraPlaceList.push_back (&ioExtraPlace);
101  }
102 
103  // //////////////////////////////////////////////////////////////////////
105  Place& ioAlternatePlace) {
106  // Link the main Place to the alternate Place, and vice versa
107  ioAlternatePlace._mainPlace = &ioMainPlace;
108 
109  // Add the alternate Place to the main Place internal map (of
110  // alternate Place objects)
111  ioMainPlace._alternatePlaceList.push_back (&ioAlternatePlace);
112  }
113 
114 }
Class modelling the primary key of a location/POR (point of reference).
Definition: LocationKey.hpp:21
static FacSupervisor & instance()
static FacPlace & instance()
Definition: FacPlace.cpp:29
static void initLinkWithAlternatePlace(Place &, Place &)
Definition: FacPlace.cpp:104
Structure modelling a (geographical) location.
Definition: Location.hpp:24
void registerBomFactory(FacBomAbstract *)
static void initLinkWithExtraPlace(Place &, Place &)
Definition: FacPlace.cpp:93
Place & clone(const Place &)
Definition: FacPlace.cpp:80
Class modelling a place/POR (point of reference).
Definition: Place.hpp:28
virtual ~FacPlace()
Definition: FacPlace.cpp:24
Place & create()
Definition: FacPlace.cpp:41