1.00.17
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
FacBom.hpp
Go to the documentation of this file.
1
#ifndef __STDAIR_FAC_FACBOM_HPP
2
#define __STDAIR_FAC_FACBOM_HPP
3
4
// //////////////////////////////////////////////////////////////////////
5
// Import section
6
// //////////////////////////////////////////////////////////////////////
7
// STL
8
#include <cassert>
9
#include <string>
10
#include <list>
11
// StdAir
12
#include <
stdair/factory/FacAbstract.hpp
>
13
#include <
stdair/service/FacSupervisor.hpp
>
14
#include <
stdair/service/Logger.hpp
>
15
16
namespace
stdair
{
17
21
template
<
typename
BOM>
22
class
FacBom
:
public
FacAbstract
{
23
25
typedef
std::list<BOM*> BomPool_T;
26
typedef
typename
BOM::Key_T Key_T;
27
28
29
public
:
30
// ///////////// Business methods ////////////
37
static
FacBom
&
instance
();
38
42
BOM&
create
();
43
BOM&
create
(
const
Key_T&);
44
BOM&
create
(
const
BOM&);
45
46
protected
:
50
FacBom
() {}
51
52
public
:
56
~FacBom
() {
57
clean
();
58
}
59
63
void
clean
();
64
65
66
private
:
67
// ///////////////////// Attributes //////////////////
71
static
FacBom
*
_instance
;
72
76
BomPool_T _pool;
77
};
78
79
80
// ////////////////////////////////////////////////////////////////////
81
template
<
typename
BOM>
FacBom<BOM>
* FacBom<BOM>::_instance = NULL;
82
83
// ////////////////////////////////////////////////////////////////////
84
template
<
typename
BOM>
FacBom<BOM>
&
FacBom<BOM>::instance
() {
85
if
(_instance == NULL) {
86
_instance =
new
FacBom
();
87
assert (_instance != NULL);
88
89
FacSupervisor::instance
().
registerPersistentBomFactory
(_instance);
90
}
91
return
*_instance;
92
}
93
94
// ////////////////////////////////////////////////////////////////////
95
template
<
typename
BOM>
void
FacBom<BOM>::clean
() {
96
// Destroy all the objects
97
for
(
typename
BomPool_T::iterator itBom = _pool.begin();
98
itBom != _pool.end(); ++itBom) {
99
BOM* currentBom_ptr = *itBom;
100
assert (currentBom_ptr != NULL);
101
delete
currentBom_ptr; currentBom_ptr = NULL;
102
}
103
104
// Empty the pool.
105
_pool.clear();
106
107
// Reset the static instance.
108
_instance = NULL;
109
}
110
111
// ////////////////////////////////////////////////////////////////////
112
template
<
typename
BOM> BOM&
FacBom<BOM>::create
() {
113
Key_T lKey;
114
return
instance
().create (lKey);
115
}
116
117
// ////////////////////////////////////////////////////////////////////
118
template
<
typename
BOM> BOM&
FacBom<BOM>::create
(
const
Key_T& iKey) {
119
BOM* oBom_ptr =
new
BOM (iKey);
120
assert (oBom_ptr != NULL);
121
_pool.push_back (oBom_ptr);
122
return
*oBom_ptr;
123
}
124
125
// ////////////////////////////////////////////////////////////////////
126
template
<
typename
BOM> BOM&
FacBom<BOM>::create
(
const
BOM& iBom) {
127
BOM* oBom_ptr =
new
BOM (iBom);
128
assert (oBom_ptr != NULL);
129
_pool.push_back (oBom_ptr);
130
return
*oBom_ptr;
131
}
132
133
}
134
#endif
// __STDAIR_FAC_FACBOM_HPP
FacAbstract.hpp
FacSupervisor.hpp
Logger.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::_instance
FacBom< BOM > * FacBom< BOM >::_instance
Definition
FacBom.hpp:81
stdair::FacAbstract::FacAbstract
FacAbstract()
Definition
FacAbstract.hpp:18
stdair::FacBom
Base class for Factory layer.
Definition
FacBom.hpp:22
stdair::FacBom::clean
void clean()
Definition
FacBom.hpp:95
stdair::FacBom::~FacBom
~FacBom()
Definition
FacBom.hpp:56
stdair::FacBom::FacBom
FacBom()
Definition
FacBom.hpp:50
stdair::FacBom::create
BOM & create()
Definition
FacBom.hpp:112
stdair::FacBom::instance
static FacBom & instance()
Definition
FacBom.hpp:84
stdair::FacSupervisor::registerPersistentBomFactory
void registerPersistentBomFactory(FacAbstract *)
Definition
FacSupervisor.cpp:34
stdair::FacSupervisor::instance
static FacSupervisor & instance()
Definition
FacSupervisor.cpp:18
Generated for StdAir by
1.13.2