Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JDATABASE::JPBS_t Struct Reference

Product breakdown structure (PBS). More...

#include <JPBS_t.hh>

Inheritance diagram for JDATABASE::JPBS_t:
std::vector< int > JDATABASE::JUPI_t JDETECTOR::JHVCalibration_t JDETECTOR::JPMTThresholdCalibration_t

Public Member Functions

 JPBS_t ()
 Default constructor.
 
 JPBS_t (const int i0, const int i1=-1, const int i2=-1, const int i3=-1, const int i4=-1, const int i5=-1, const int i6=-1, const int i7=-1, const int i8=-1, const int i9=-1)
 Constructor.
 
 JPBS_t (const std::string &input)
 Constructor.
 
const JPBS_tgetPBS () const
 Get PBS.
 
bool is_valid () const
 Check validity.
 
 ClassDefNV (JPBS_t, 1)
 

Static Public Attributes

static const char DOT = '.'
 Separator between PBS values.
 

Friends

bool operator== (const JPBS_t &first, const JPBS_t &second)
 Equality operator.
 
bool operator< (const JPBS_t &first, const JPBS_t &second)
 Less-than operator.
 
std::istream & operator>> (std::istream &in, JPBS_t &object)
 Read PBS from input stream.
 
std::ostream & operator<< (std::ostream &out, const JPBS_t &object)
 Write PBS to output stream.
 

Detailed Description

Product breakdown structure (PBS).

The PBS consists of one (or more) integer value(s), separated by JPBS_t::DOT.
The corresponding ASCII format reads "<int>[.<int>]*".

Definition at line 27 of file JPBS_t.hh.

Constructor & Destructor Documentation

◆ JPBS_t() [1/3]

JDATABASE::JPBS_t::JPBS_t ( )
inline

Default constructor.

Definition at line 39 of file JPBS_t.hh.

40 {}

◆ JPBS_t() [2/3]

JDATABASE::JPBS_t::JPBS_t ( const int i0,
const int i1 = -1,
const int i2 = -1,
const int i3 = -1,
const int i4 = -1,
const int i5 = -1,
const int i6 = -1,
const int i7 = -1,
const int i8 = -1,
const int i9 = -1 )
inline

Constructor.

Note that the parsing of arguments terminates at the first occurrence of a negative value.

Parameters
i0PBS number
i1PBS number
i2PBS number
i3PBS number
i4PBS number
i5PBS number
i6PBS number
i7PBS number
i8PBS number
i9PBS number

Definition at line 59 of file JPBS_t.hh.

69 {
70 if (i0 >= 0) { push_back(i0); } else { return; }
71 if (i1 >= 0) { push_back(i1); } else { return; }
72 if (i2 >= 0) { push_back(i2); } else { return; }
73 if (i3 >= 0) { push_back(i3); } else { return; }
74 if (i4 >= 0) { push_back(i4); } else { return; }
75 if (i5 >= 0) { push_back(i5); } else { return; }
76 if (i6 >= 0) { push_back(i6); } else { return; }
77 if (i7 >= 0) { push_back(i7); } else { return; }
78 if (i8 >= 0) { push_back(i8); } else { return; }
79 if (i9 >= 0) { push_back(i9); } else { return; }
80 }

◆ JPBS_t() [3/3]

JDATABASE::JPBS_t::JPBS_t ( const std::string & input)
inline

Constructor.

Parameters
inputinput text

Definition at line 88 of file JPBS_t.hh.

89 {
90 std::istringstream is(input);
91
92 is >> *this;
93 }

Member Function Documentation

◆ getPBS()

const JPBS_t & JDATABASE::JPBS_t::getPBS ( ) const
inline

Get PBS.

Returns
PBS

Definition at line 101 of file JPBS_t.hh.

102 {
103 return static_cast<const JPBS_t&>(*this);
104 }
JPBS_t()
Default constructor.
Definition JPBS_t.hh:39

◆ is_valid()

bool JDATABASE::JPBS_t::is_valid ( ) const
inline

Check validity.

Returns
true if valid; else false

Definition at line 112 of file JPBS_t.hh.

113 {
114 return !this->empty();
115 }

◆ ClassDefNV()

JDATABASE::JPBS_t::ClassDefNV ( JPBS_t ,
1  )

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const JPBS_t & first,
const JPBS_t & second )
friend

Equality operator.

Parameters
firstfirst PBS
secondsecond PBS
Returns
true if PBS is equal; else false

Definition at line 125 of file JPBS_t.hh.

126 {
127 if (first.size() == second.size()) {
128
129 for (const_iterator p = first.begin(), q = second.begin(); p != first.end(); ++p, ++q) {
130 if (*p != *q) {
131 return false;
132 }
133 }
134
135 return true;
136 }
137
138 return false;
139 }

◆ operator<

bool operator< ( const JPBS_t & first,
const JPBS_t & second )
friend

Less-than operator.

Parameters
firstfirst PBS
secondsecond PBS
Returns
true if first PBS higher in hierarchy; else false

Definition at line 149 of file JPBS_t.hh.

150 {
151 for (const_iterator p = first.begin(), q = second.begin(); p != first.end() && q != second.end(); ++p, ++q) {
152 if (*p != *q) {
153 return *p < *q;
154 }
155 }
156
157 return first.size() < second.size();
158 }

◆ operator>>

std::istream & operator>> ( std::istream & in,
JPBS_t & object )
friend

Read PBS from input stream.

Parameters
ininput stream
objectPBS
Returns
input stream

Definition at line 168 of file JPBS_t.hh.

169 {
170 using namespace std;
171
172 object.clear();
173
174 int pbs;
175
176 if (in >> pbs) {
177
178 object.push_back(pbs);
179
180 while (in.peek() == (int) JPBS_t::DOT) {
181 if (in.ignore() && in >> pbs)
182 object.push_back(pbs);
183 else
184 in.setstate(ios::failbit);
185 }
186
187 } else {
188
189 in.setstate(ios::failbit);
190 }
191
192 return in;
193 }
static const char DOT
Separator between PBS values.
Definition JPBS_t.hh:33

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JPBS_t & object )
friend

Write PBS to output stream.

Parameters
outoutput stream
objectPBS
Returns
output stream

Definition at line 203 of file JPBS_t.hh.

204 {
205 using namespace std;
206 using namespace JPP;
207
208 ostringstream os;
209
210 if (!object.empty()) {
211
212 const_iterator i = object.begin();
213
214 os << *i;
215
216 while (++i != object.end()) {
217 os << JPBS_t::DOT << *i;
218 }
219 }
220
221 return out << os.str();
222 }
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

Member Data Documentation

◆ DOT

const char JDATABASE::JPBS_t::DOT = '.'
static

Separator between PBS values.

Definition at line 33 of file JPBS_t.hh.


The documentation for this struct was generated from the following file: