g4tools
5.4.0
g4tools
tools
sg
states
Go to the documentation of this file.
1
// Copyright (C) 2010, Guy Barrand. All rights reserved.
2
// See the file tools.license for terms.
3
4
#ifndef tools_sg_states
5
#define tools_sg_states
6
7
#include "
state
"
8
9
//#define TOOLS_SG_STATES_CUR
10
11
namespace
tools
{
12
namespace
sg {
13
14
class
states
{
15
public
:
16
#ifdef TOOLS_SG_STATES_CUR
17
states
(
unsigned
int
a_ww,
unsigned
int
a_wh)
18
:
m_states
(8)
19
,
m_state
(&(
m_states
[0]))
20
,m_cur_state(0)
21
{
22
m_state
->
m_ww
= a_ww;
23
m_state
->
m_wh
= a_wh;
24
}
25
#else
26
states
(
unsigned
int
a_ww,
unsigned
int
a_wh):
m_states
() {
27
m_state
.
m_ww
= a_ww;
28
m_state
.
m_wh
= a_wh;
29
}
30
#endif
31
virtual
~states
(){}
32
protected
:
33
#ifdef TOOLS_SG_STATES_CUR
34
states
(
const
states
& a_from)
35
:
m_states
(a_from.
m_states
)
36
,
m_state
(&(
m_states
[a_from.m_cur_state]))
37
,m_cur_state(a_from.m_cur_state)
38
,
m_saved_state
(a_from.
m_saved_state
)
39
{}
40
states
&
operator=
(
const
states
& a_from){
41
m_states
= a_from.m_states;
42
m_state
= &(
m_states
[a_from.m_cur_state]);
43
m_cur_state = a_from.m_cur_state;
44
m_saved_state
= a_from.m_saved_state;
45
return
*
this
;
46
}
47
#else
48
states
(
const
states
& a_from)
49
:
m_states
(a_from.
m_states
)
50
,
m_state
(a_from.
m_state
)
51
,
m_saved_state
(a_from.
m_saved_state
)
52
{}
53
states
&
operator=
(
const
states
& a_from){
54
m_states
= a_from.
m_states
;
55
m_state
= a_from.
m_state
;
56
m_saved_state
= a_from.
m_saved_state
;
57
return
*
this
;
58
}
59
#endif
60
public
:
61
#ifdef TOOLS_SG_STATES_CUR
62
const
sg::state
&
state
()
const
{
return
*
m_state
;}
63
sg::state
&
state
() {
return
*
m_state
;}
64
void
pop_state
() {
65
m_state
= &(
m_states
[m_cur_state]);
66
m_cur_state--;
67
}
68
void
push_state
() {
69
if
((m_cur_state+1)>=(
int
)
m_states
.size()) {
70
m_states
.resize(
m_states
.size()+5);
71
}
72
m_cur_state++;
73
m_states
[m_cur_state] = *
m_state
;
74
}
75
#else
76
const
sg::state
&
state
()
const
{
return
m_state
;}
77
sg::state
&
state
() {
return
m_state
;}
78
void
pop_state
() {
79
//if(!m_states.size()) return; //throw.
80
m_state
=
m_states
.back();
81
m_states
.pop_back();
82
}
83
void
push_state
() {
m_states
.push_back(
m_state
);}
84
#endif
85
86
void
save_state
(
const
sg::state
& a_state) {
m_saved_state
= a_state;}
87
const
sg::state
&
saved_state
()
const
{
return
m_saved_state
;}
88
sg::state
&
saved_state
() {
return
m_saved_state
;}
89
protected
:
90
std::vector<sg::state>
m_states
;
91
#ifdef TOOLS_SG_STATES_CUR
92
sg::state
*
m_state
;
93
int
m_cur_state;
94
#else
95
sg::state
m_state
;
96
#endif
97
sg::state
m_saved_state
;
98
};
99
100
}}
101
102
#endif
tools::sg::states::m_saved_state
sg::state m_saved_state
Definition:
states:97
tools::sg::states::pop_state
void pop_state()
Definition:
states:78
tools::sg::states::push_state
void push_state()
Definition:
states:83
tools::sg::state
Definition:
state:25
tools::sg::states::saved_state
sg::state & saved_state()
Definition:
states:88
tools::sg::states::m_state
sg::state m_state
Definition:
states:95
tools::sg::states
Definition:
states:14
tools::sg::state::m_wh
unsigned int m_wh
Definition:
state:242
tools::sg::states::m_states
std::vector< sg::state > m_states
Definition:
states:90
tools::sg::states::states
states(unsigned int a_ww, unsigned int a_wh)
Definition:
states:26
tools
inlined C code : ///////////////////////////////////
Definition:
aida_ntuple:26
tools::sg::states::state
sg::state & state()
Definition:
states:77
tools::sg::state::m_ww
unsigned int m_ww
Definition:
state:241
tools::sg::states::save_state
void save_state(const sg::state &a_state)
Definition:
states:86
tools::sg::states::~states
virtual ~states()
Definition:
states:31
tools::sg::states::state
const sg::state & state() const
Definition:
states:76
state
tools::sg::states::states
states(const states &a_from)
Definition:
states:48
tools::sg::states::operator=
states & operator=(const states &a_from)
Definition:
states:53
tools::sg::states::saved_state
const sg::state & saved_state() const
Definition:
states:87
Generated by
1.8.20