1.00.13
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
FacCloneBom.hpp
Go to the documentation of this file.
1
#ifndef __STDAIR_FAC_FACCLONEBOM_HPP
2
#define __STDAIR_FAC_FACCLONEBOM_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
FacCloneBom
:
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
FacCloneBom
&
instance
();
38
42
BOM&
clone
(
const
BOM&);
43
44
protected
:
48
FacCloneBom
() {}
49
50
public
:
54
~FacCloneBom
() {
55
clean
();
56
}
57
61
void
clean
();
62
63
64
private
:
65
// ///////////////////// Attributes //////////////////
69
static
FacCloneBom
* _instance;
70
74
BomPool_T _pool;
75
};
76
77
78
// ////////////////////////////////////////////////////////////////////
79
template
<
typename
BOM> FacCloneBom<BOM>* FacCloneBom<BOM>::_instance = NULL;
80
81
// ////////////////////////////////////////////////////////////////////
82
template
<
typename
BOM>
FacCloneBom<BOM>
&
FacCloneBom<BOM>::instance
() {
83
if
(_instance == NULL) {
84
_instance =
new
FacCloneBom
();
85
assert (_instance != NULL);
86
87
FacSupervisor::instance
().
registerCloneBomFactory
(_instance);
88
}
89
return
*_instance;
90
}
91
92
// ////////////////////////////////////////////////////////////////////
93
template
<
typename
BOM>
void
FacCloneBom<BOM>::clean
() {
94
// Destroy all the objects
95
for
(
typename
BomPool_T::iterator itBom = _pool.begin();
96
itBom != _pool.end(); ++itBom) {
97
BOM* currentBom_ptr = *itBom;
98
assert (currentBom_ptr != NULL);
99
delete
currentBom_ptr; currentBom_ptr = NULL;
100
}
101
102
// Empty the pool.
103
_pool.clear();
104
105
// Reset the static instance.
106
_instance = NULL;
107
}
108
109
// ////////////////////////////////////////////////////////////////////
110
template
<
typename
BOM> BOM&
FacCloneBom<BOM>::clone
(
const
BOM& iBom) {
111
BOM* oBom_ptr =
new
BOM (iBom);
112
assert (oBom_ptr != NULL);
113
_pool.push_back (oBom_ptr);
114
return
*oBom_ptr;
115
}
116
117
}
118
#endif
// __STDAIR_FAC_FACCLONEBOM_HPP
FacAbstract.hpp
FacSupervisor.hpp
Logger.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::FacAbstract
Definition
FacAbstract.hpp:10
stdair::FacCloneBom
Base class for Factory layer.
Definition
FacCloneBom.hpp:22
stdair::FacCloneBom::clean
void clean()
Definition
FacCloneBom.hpp:93
stdair::FacCloneBom::~FacCloneBom
~FacCloneBom()
Definition
FacCloneBom.hpp:54
stdair::FacCloneBom::instance
static FacCloneBom & instance()
Definition
FacCloneBom.hpp:82
stdair::FacCloneBom::FacCloneBom
FacCloneBom()
Definition
FacCloneBom.hpp:48
stdair::FacCloneBom::clone
BOM & clone(const BOM &)
Definition
FacCloneBom.hpp:110
stdair::FacSupervisor::registerCloneBomFactory
void registerCloneBomFactory(FacAbstract *)
Definition
FacSupervisor.cpp:39
stdair::FacSupervisor::instance
static FacSupervisor & instance()
Definition
FacSupervisor.cpp:18
Generated for StdAir by
1.10.0