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
5
#include <
opentrep/factory/FacBomAbstract.hpp
>
6
#include <
opentrep/factory/FacServiceAbstract.hpp
>
7
#include <
opentrep/factory/FacXapianDB.hpp
>
8
#include <
opentrep/factory/FacSupervisor.hpp
>
9
#include <
opentrep/service/Logger.hpp
>
10
11
namespace
OPENTREP
{
12
13
FacSupervisor
* FacSupervisor::_instance = NULL;
14
15
// //////////////////////////////////////////////////////////////////////
16
FacSupervisor::FacSupervisor
() :
17
_facXapianDB (NULL), _logger (NULL) {
18
}
19
20
// //////////////////////////////////////////////////////////////////////
21
FacSupervisor
&
FacSupervisor::instance
() {
22
if
(_instance == NULL) {
23
_instance =
new
FacSupervisor
();
24
}
25
assert (_instance != NULL);
26
return
*_instance;
27
}
28
29
// //////////////////////////////////////////////////////////////////////
30
void
FacSupervisor::
31
registerBomFactory
(
FacBomAbstract
* ioFacBomAbstract_ptr) {
32
_bomPool.push_back (ioFacBomAbstract_ptr);
33
}
34
35
// //////////////////////////////////////////////////////////////////////
36
void
FacSupervisor::
37
registerServiceFactory
(
FacServiceAbstract
* ioFacServiceAbstract_ptr) {
38
_svcPool.push_back (ioFacServiceAbstract_ptr);
39
}
40
41
// //////////////////////////////////////////////////////////////////////
42
void
FacSupervisor::registerXapianDBFactory
(
FacXapianDB
* ioFacXapianDB_ptr) {
43
_facXapianDB = ioFacXapianDB_ptr;
44
}
45
46
// //////////////////////////////////////////////////////////////////////
47
void
FacSupervisor::registerLoggerService
(
Logger
* ioLogger_ptr) {
48
_logger = ioLogger_ptr;
49
}
50
51
// //////////////////////////////////////////////////////////////////////
52
FacSupervisor::~FacSupervisor
() {
53
// For the underlying instance, if existing
54
cleanFactory
();
55
56
// For the instance level
57
cleanBomLayer
();
58
cleanServiceLayer
();
59
cleanFacXapianDB
();
60
cleanLoggerService
();
61
}
62
63
// //////////////////////////////////////////////////////////////////////
64
void
FacSupervisor::cleanBomLayer
() {
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
// //////////////////////////////////////////////////////////////////////
78
void
FacSupervisor::cleanServiceLayer
() {
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
// //////////////////////////////////////////////////////////////////////
92
void
FacSupervisor::cleanFacXapianDB
() {
93
delete
_facXapianDB; _facXapianDB = NULL;
94
}
95
96
// //////////////////////////////////////////////////////////////////////
97
void
FacSupervisor::cleanLoggerService
() {
98
delete
_logger; _logger = NULL;
99
}
100
101
// //////////////////////////////////////////////////////////////////////
102
void
FacSupervisor::cleanFactory
() {
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
}
FacBomAbstract.hpp
FacServiceAbstract.hpp
FacSupervisor.hpp
FacXapianDB.hpp
Logger.hpp
OPENTREP::FacBomAbstract
Definition
FacBomAbstract.hpp:17
OPENTREP::FacServiceAbstract
Definition
FacServiceAbstract.hpp:16
OPENTREP::FacSupervisor
Definition
FacSupervisor.hpp:21
OPENTREP::FacSupervisor::cleanFactory
static void cleanFactory()
Definition
FacSupervisor.cpp:102
OPENTREP::FacSupervisor::cleanServiceLayer
void cleanServiceLayer()
Definition
FacSupervisor.cpp:78
OPENTREP::FacSupervisor::~FacSupervisor
~FacSupervisor()
Definition
FacSupervisor.cpp:52
OPENTREP::FacSupervisor::instance
static FacSupervisor & instance()
Definition
FacSupervisor.cpp:21
OPENTREP::FacSupervisor::registerXapianDBFactory
void registerXapianDBFactory(FacXapianDB *)
Definition
FacSupervisor.cpp:42
OPENTREP::FacSupervisor::registerBomFactory
void registerBomFactory(FacBomAbstract *)
Definition
FacSupervisor.cpp:31
OPENTREP::FacSupervisor::cleanBomLayer
void cleanBomLayer()
Definition
FacSupervisor.cpp:64
OPENTREP::FacSupervisor::cleanFacXapianDB
void cleanFacXapianDB()
Definition
FacSupervisor.cpp:92
OPENTREP::FacSupervisor::cleanLoggerService
void cleanLoggerService()
Definition
FacSupervisor.cpp:97
OPENTREP::FacSupervisor::registerServiceFactory
void registerServiceFactory(FacServiceAbstract *)
Definition
FacSupervisor.cpp:37
OPENTREP::FacSupervisor::FacSupervisor
FacSupervisor()
Definition
FacSupervisor.cpp:16
OPENTREP::FacSupervisor::registerLoggerService
void registerLoggerService(Logger *)
Definition
FacSupervisor.cpp:47
OPENTREP::FacXapianDB
Factory for a Xapian WritableDatabase object.
Definition
FacXapianDB.hpp:22
OPENTREP::Logger
Definition
Logger.hpp:49
OPENTREP
Definition
BasChronometer.cpp:10
Generated on Mon May 5 2025 00:00:00 for OpenTREP by
1.13.2