Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPBSSequence.hh
Go to the documentation of this file.
1 #ifndef __JDB__JPBSSEQUENCE__
2 #define __JDB__JPBSSEQUENCE__
3 
4 #include <vector>
5 #include <algorithm>
6 #include <iterator>
7 
8 #include "JMath/JMath.hh"
9 
10 #include "JDB/JPBS_t.hh"
11 
12 
13 /**
14  * \author mdejong
15  */
16 namespace JDATABASE {}
17 namespace JPP { using namespace JDATABASE; }
18 
19 namespace JDATABASE {
20 
21  using JMATH::JMath;
22 
23 
24  /**
25  * Auxiliary data structure for a sequence of %PBS values.
26  *
27  * A sequence of %PBS values corresponds to the integration chain of a product,\n
28  * starting from the lowest integration level to the highest integration level.
29  */
30  struct JPBSSequence :
31  public std::vector<JPBS_t>
32  {
33  /**
34  * Default constructor.
35  */
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param pbs %PBS
44  */
45  JPBSSequence(const JPBS_t& pbs) :
46  std::vector<JPBS_t>(1, pbs)
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param input %PBS data
54  */
55  JPBSSequence(const std::initializer_list<JPBS_t>& input) :
56  std::vector<JPBS_t>(input)
57  {}
58 
59 
60  /**
61  * Chain %PBS sequence.
62  *
63  * \param pbs %PBS
64  * \param input %PBS sequence
65  * \return %PBS sequence
66  */
67  friend inline JPBSSequence operator+(const JPBSSequence& pbs, const JPBSSequence& input)
68  {
69  using namespace std;
70 
71  JPBSSequence buffer(pbs);
72 
73  copy(input.begin(), input.end(), back_inserter(buffer));
74 
75  return buffer;
76  }
77  };
78 
79 
80  /**
81  * Auxiliary data structure for set of %PBS sequences.
82  */
83  struct JPBSSequences :
84  public std::vector<JPBSSequence>,
85  public JMath<JPBSSequences>
86  {
87  /**
88  * Default constructor.
89  */
91  {}
92 
93 
94  /**
95  * Constructor.
96  *
97  * \param input %PBS sequence
98  */
99  JPBSSequences(const JPBSSequence& input) :
100  std::vector<JPBSSequence>(1, input)
101  {}
102 
103 
104  /**
105  * Constructor.
106  *
107  * \param input %PBS sequence data
108  */
109  JPBSSequences(const std::initializer_list<JPBSSequences>& input)
110  {
111  using namespace std;
112 
113  for (std::initializer_list<JPBSSequences>::const_iterator i = input.begin(); i != input.end(); ++i) {
114  copy(i->begin(), i->end(), back_inserter(*this));
115  }
116  }
117 
118 
119  /**
120  * Add %PBS sequences.
121  *
122  * \param input %PBS sequences
123  * \return this %PBS sequences
124  */
126  {
127  for (JPBSSequences::const_iterator i = input.begin(); i != input.end(); ++i) {
128  this->push_back(*i);
129  }
130 
131  return *this;
132  }
133 
134 
135  /**
136  * Add %PBS to %PBS sequences.
137  *
138  * \param pbs %PBS
139  * \param input %PBS sequences
140  * \return %PBS sequences
141  */
142  friend inline JPBSSequences operator+(const JPBS_t& pbs, const JPBSSequences& input)
143  {
144  JPBSSequences buffer;
145 
146  for (JPBSSequences::const_iterator i = input.begin(); i != input.end(); ++i) {
147  buffer.push_back(pbs + *i);
148  }
149 
150  return buffer;
151  }
152  };
153 
154 
155  namespace PBS {
156 
157  /**
158  * %PBS sequences for detection unit.
159  */
162  };
163 
164  /**
165  * %PBS sequences for optical module.
166  */
167  static const JPBSSequences DOM_SEQUENCES = {
169  };
170 
171  /**
172  * %PBS sequences for base module.
173  */
174  static const JPBSSequences BASE_SEQUENCES = {
176  PBS::BASE_CONTAINER + PBS::DETECTION_UNIT_SEQUENCES
177  };
178 
179  /**
180  * %PBS sequences for central-logic board.
181  */
182  static const JPBSSequences CLB_SEQUENCES = {
185  };
186 
187  /**
188  * %PBS sequences for PMT.
189  */
190  static const JPBSSequences PMT_SEQUENCES = {
192  };
193 
194  /**
195  * %PBS sequences for AHRS.
196  */
197  static const JPBSSequences AHRS_SEQUENCES = {
199  };
200 
201  /**
202  * %PBS sequences for acoystic sensor.
203  */
206  };
207 
208  /**
209  * %PBS sequences for hydrophone.
210  */
213  };
214  }
215 
216 
217  /**
218  * Auxiliary class to get %PBS sequences as a function of %PBS.
219  */
221  public std::map<JPBS_t, JPBSSequences>
222  {
223  /**
224  * Default constructor.
225  */
227  {
229  (*this)[PBS::DOM] = PBS::DOM_SEQUENCES;
230  (*this)[PBS::BASE] = PBS::BASE_SEQUENCES;
231  (*this)[PBS::CLB] = PBS::CLB_SEQUENCES;
232  (*this)[PBS::PMT] = PBS::PMT_SEQUENCES;
233  (*this)[PBS::AHRS] = PBS::AHRS_SEQUENCES;
236  }
237 
238 
239  /**
240  * Get %PBS sequences for the given %PBS.
241  *
242  * \param pbs %PBS
243  * \return %PBS sequences
244  */
245  JPBSSequences operator()(const JPBS_t& pbs) const
246  {
247  const_iterator p = this->find(pbs);
248 
249  if (p != this->end()) {
250 
251  return p->second;
252 
253  } else {
254 
255  JPBSSequence buffer;
256 
257  for (JPBS_t i = pbs; !i.empty(); i.pop_back()) {
258  buffer.push_back(i);
259  }
260 
261  return buffer;
262  }
263  }
264  };
265 
266 
267  /**
268  * Function object to get %PBS sequences as a function of %PBS.
269  */
271 }
272 
273 #endif
274 
static const JPBSSequences DOM_SEQUENCES
PBS sequences for optical module.
static const JPBS_t BASE(3, 2)
PBS of detection unit base
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:110
static JGetPBSSequences getPBSSequences
Function object to get PBS sequences as a function of PBS.
friend JPBSSequences operator+(const JPBS_t &pbs, const JPBSSequences &input)
Add PBS to PBS sequences.
static const JPBS_t DOM(3, 4)
PBS of optical module
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
static const JPBSSequences PMT_SEQUENCES
PBS sequences for PMT.
static const JPBSSequences ACOUSTIC_SENSOR_SEQUENCES
PBS sequences for acoystic sensor.
JPBSSequences()
Default constructor.
Definition: JPBSSequence.hh:90
JGetPBSSequences()
Default constructor.
static const JPBSSequences HYDROPHONE_SEQUENCES
PBS sequences for hydrophone.
JPBSSequence()
Default constructor.
Definition: JPBSSequence.hh:36
static const JPBS_t CLB(3, 4, 3, 2)
PBS of central-logic board
friend JPBSSequence operator+(const JPBSSequence &pbs, const JPBSSequence &input)
Chain PBS sequence.
Definition: JPBSSequence.hh:67
Auxiliary class to get PBS sequences as a function of PBS.
static const JPBS_t ACOUSTIC_SENSOR(3, 4, 3, 6, 2)
PBS of piezo sensor
JPBSSequences(const JPBSSequence &input)
Constructor.
Definition: JPBSSequence.hh:99
JPBSSequence(const std::initializer_list< JPBS_t > &input)
Constructor.
Definition: JPBSSequence.hh:55
Auxiliary data structure for a sequence of PBS values.
Definition: JPBSSequence.hh:30
JPBSSequence(const JPBS_t &pbs)
Constructor.
Definition: JPBSSequence.hh:45
static const JPBS_t BASE_CONTAINER(3, 2, 2)
PBS of detection unit base container
Auxiliary data structure for set of PBS sequences.
Definition: JPBSSequence.hh:83
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
JPBSSequences & add(const JPBSSequences &input)
Add PBS sequences.
JPBSSequences operator()(const JPBS_t &pbs) const
Get PBS sequences for the given PBS.
static const JPBS_t DETECTION_UNIT(3)
PBS of detection unit
static const JPBSSequences AHRS_SEQUENCES
PBS sequences for AHRS.
static const JPBS_t HYDROPHONE(4, 5)
PBS of hydrophone
static const JPBSSequences BASE_SEQUENCES
PBS sequences for base module.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
Base class for data structures with artithmetic capabilities.
Product breakdown structure (PBS).
Definition: JPBS_t.hh:25
static const JPBSSequences DETECTION_UNIT_SEQUENCES
PBS sequences for detection unit.
set_variable DETECTOR
JPBSSequences(const std::initializer_list< JPBSSequences > &input)
Constructor.
static const JPBS_t AHRS(3, 4, 3, 4)
PBS of compass