OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
FacSupervisor.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// OpenTREP
10
11namespace OPENTREP {
12
13 FacSupervisor* FacSupervisor::_instance = NULL;
14
15 // //////////////////////////////////////////////////////////////////////
17 _facXapianDB (NULL), _logger (NULL) {
18 }
19
20 // //////////////////////////////////////////////////////////////////////
22 if (_instance == NULL) {
23 _instance = new FacSupervisor();
24 }
25 assert (_instance != NULL);
26 return *_instance;
27 }
28
29 // //////////////////////////////////////////////////////////////////////
31 registerBomFactory (FacBomAbstract* ioFacBomAbstract_ptr) {
32 _bomPool.push_back (ioFacBomAbstract_ptr);
33 }
34
35 // //////////////////////////////////////////////////////////////////////
37 registerServiceFactory (FacServiceAbstract* ioFacServiceAbstract_ptr) {
38 _svcPool.push_back (ioFacServiceAbstract_ptr);
39 }
40
41 // //////////////////////////////////////////////////////////////////////
43 _facXapianDB = ioFacXapianDB_ptr;
44 }
45
46 // //////////////////////////////////////////////////////////////////////
48 _logger = ioLogger_ptr;
49 }
50
51 // //////////////////////////////////////////////////////////////////////
53 // For the underlying instance, if existing
55
56 // For the instance level
61 }
62
63 // //////////////////////////////////////////////////////////////////////
65 for (BomFactoryPool_T::const_iterator itFactory = _bomPool.begin();
66 itFactory != _bomPool.end(); itFactory++) {
67 const FacBomAbstract* currentFactory_ptr = *itFactory;
68 assert (currentFactory_ptr != NULL);
69
70 delete currentFactory_ptr; currentFactory_ptr = NULL;
71 }
72
73 // Now that all the objects have been deleted, empty the underlying pool
74 _bomPool.clear();
75 }
76
77 // //////////////////////////////////////////////////////////////////////
79 for (ServiceFactoryPool_T::const_iterator itFactory = _svcPool.begin();
80 itFactory != _svcPool.end(); itFactory++) {
81 const FacServiceAbstract* currentFactory_ptr = *itFactory;
82 assert (currentFactory_ptr != NULL);
83
84 delete currentFactory_ptr; currentFactory_ptr = NULL;
85 }
86
87 // Now that all the objects have been deleted, empty the underlying pool
88 _svcPool.clear();
89 }
90
91 // //////////////////////////////////////////////////////////////////////
93 delete _facXapianDB; _facXapianDB = NULL;
94 }
95
96 // //////////////////////////////////////////////////////////////////////
98 delete _logger; _logger = NULL;
99 }
100
101 // //////////////////////////////////////////////////////////////////////
103 if (_instance != NULL) {
104 _instance->cleanBomLayer();
105 _instance->cleanServiceLayer();
106 _instance->cleanFacXapianDB();
107 _instance->cleanLoggerService();
108 }
109 delete _instance; _instance = NULL;
110 }
111
112}
static FacSupervisor & instance()
void registerXapianDBFactory(FacXapianDB *)
void registerBomFactory(FacBomAbstract *)
void registerServiceFactory(FacServiceAbstract *)
void registerLoggerService(Logger *)
Factory for a Xapian WritableDatabase object.