Midge
v3.9.2
Data Processing Framework
library
utility
initializer.hh
Go to the documentation of this file.
1
#ifndef _midge_initializer_hh_
2
#define _midge_initializer_hh_
3
4
#include <cstddef>
5
6
7
namespace
midge
8
{
9
10
template
<
class
x_type >
11
class
initializer
12
{
13
public
:
14
initializer
();
15
~initializer
();
16
17
private
:
18
static
x_type*
f_instance
;
19
static
int
f_count
;
20
21
public
:
22
static
char
f_data
[
sizeof
(x_type) ];
23
};
24
25
template
<
class
x_type >
26
char
initializer< x_type >::f_data
[
sizeof
(x_type) ] =
27
{ };
28
29
template
<
class
x_type >
30
int
initializer< x_type >::f_count
= 0;
31
32
template
<
class
x_type >
33
x_type*
initializer< x_type >::f_instance
= NULL;
34
35
template
<
class
x_type >
36
initializer< x_type >::initializer
()
37
{
38
if
( 0 ==
f_count
++ )
39
{
40
f_instance
=
new
( (x_type*) (&f_data) ) x_type();
41
}
42
}
43
template
<
class
x_type >
44
initializer< x_type >::~initializer
()
45
{
46
if
( 0 == --
f_count
)
47
{
48
f_instance
->~x_type();
49
}
50
}
51
52
}
53
54
#endif
midge::initializer::~initializer
~initializer()
Definition:
initializer.hh:44
midge
Definition:
_buffer.hh:11
midge::initializer
Definition:
initializer.hh:11
midge::initializer::initializer
initializer()
Definition:
initializer.hh:36
midge::initializer::f_data
static char f_data[sizeof(x_type)]
Definition:
initializer.hh:22
midge::initializer::f_instance
static x_type * f_instance
Definition:
initializer.hh:18
midge::initializer::f_count
static int f_count
Definition:
initializer.hh:19
Generated by
1.8.13