Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
JDATABASE::JUPI_t Struct Reference

Universal product identifier (UPI). More...

#include <JUPI_t.hh>

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

Public Member Functions

 JUPI_t ()
 Default constructor. More...
 
 JUPI_t (const JPBS_t &pbs)
 Constructor. More...
 
 JUPI_t (const JPBS_t &pbs, const std::string &variant, const int version, const int number)
 Constructor. More...
 
 JUPI_t (const std::string &upi)
 Constructor. More...
 
const JUPI_tgetUPI () const
 Get UPI. More...
 
const std::string & getVariant () const
 Get variant. More...
 
int getVersion () const
 Get version. More...
 
int getNumber () const
 Get serial number. More...
 
std::string toString () const
 Convert UPI. More...
 
 ClassDefNV (JUPI_t, 1)
 
const JPBS_tgetPBS () const
 Get PBS. More...
 
bool is_valid () const
 Check validity. More...
 
 ClassDefNV (JPBS_t, 1)
 

Static Public Attributes

static const char SEPARATOR = '/'
 Separator between PBS, variant and version. More...
 
static const int DEFAULT_VERSION = -1
 Default version. More...
 
static const int DEFAULT_NUMBER = -1
 Default number. More...
 
static const char DOT = '.'
 Separator between PBS values. More...
 

Protected Attributes

std::string variant
 
int version
 
int number
 

Friends

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

Detailed Description

Universal product identifier (UPI).

The UPI consists of a PBS, variant, version and serial number.
The corresponding ASCII format reads "<int>[.<int>]*/<variant>/<int>.<int>".
The version and serial number are not subject to I/O in case their value is default.

Definition at line 30 of file JUPI_t.hh.

Constructor & Destructor Documentation

◆ JUPI_t() [1/4]

JDATABASE::JUPI_t::JUPI_t ( )
inline

Default constructor.

Definition at line 44 of file JUPI_t.hh.

44  :
45  JPBS_t (),
46  variant(),
49  {}
JPBS_t()
Default constructor.
Definition: JPBS_t.hh:39
std::string variant
Definition: JUPI_t.hh:279
static const int DEFAULT_VERSION
Default version.
Definition: JUPI_t.hh:38
static const int DEFAULT_NUMBER
Default number.
Definition: JUPI_t.hh:39

◆ JUPI_t() [2/4]

JDATABASE::JUPI_t::JUPI_t ( const JPBS_t pbs)
inline

Constructor.

Parameters
pbsPBS

Definition at line 57 of file JUPI_t.hh.

57  :
58  JPBS_t (pbs),
59  variant(),
62  {}

◆ JUPI_t() [3/4]

JDATABASE::JUPI_t::JUPI_t ( const JPBS_t pbs,
const std::string &  variant,
const int  version,
const int  number 
)
inline

Constructor.

Parameters
pbsPBS
variantvariant
versionversion
numberserial number

Definition at line 73 of file JUPI_t.hh.

76  :
77  JPBS_t (pbs),
80  number (number)
81  {}

◆ JUPI_t() [4/4]

JDATABASE::JUPI_t::JUPI_t ( const std::string &  upi)
inline

Constructor.

Parameters
upiUPI

Definition at line 89 of file JUPI_t.hh.

90  {
91  std::istringstream(upi) >> *this;
92  }

Member Function Documentation

◆ getUPI()

const JUPI_t& JDATABASE::JUPI_t::getUPI ( ) const
inline

Get UPI.

Returns
UPI

Definition at line 100 of file JUPI_t.hh.

101  {
102  return static_cast<const JUPI_t&>(*this);
103  }
Universal product identifier (UPI).
Definition: JUPI_t.hh:32

◆ getVariant()

const std::string& JDATABASE::JUPI_t::getVariant ( ) const
inline

Get variant.

Returns
variant

Definition at line 111 of file JUPI_t.hh.

112  {
113  return variant;
114  }

◆ getVersion()

int JDATABASE::JUPI_t::getVersion ( ) const
inline

Get version.

Returns
version

Definition at line 122 of file JUPI_t.hh.

123  {
124  return version;
125  }

◆ getNumber()

int JDATABASE::JUPI_t::getNumber ( ) const
inline

Get serial number.

Returns
serial number

Definition at line 133 of file JUPI_t.hh.

134  {
135  return number;
136  }

◆ toString()

std::string JDATABASE::JUPI_t::toString ( ) const
inline

Convert UPI.

Returns
UPI

Definition at line 144 of file JUPI_t.hh.

145  {
146  std::ostringstream os;
147 
148  os << *this;
149 
150  return os.str();
151  }

◆ ClassDefNV() [1/2]

JDATABASE::JUPI_t::ClassDefNV ( JUPI_t  ,
 
)

◆ getPBS()

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

Get PBS.

Returns
PBS

Definition at line 101 of file JPBS_t.hh.

102  {
103  return static_cast<const JPBS_t&>(*this);
104  }
Product breakdown structure (PBS).
Definition: JPBS_t.hh:29

◆ is_valid()

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

Check validity.

Returns
true if valid; else false

Definition at line 112 of file JPBS_t.hh.

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

◆ ClassDefNV() [2/2]

JDATABASE::JPBS_t::ClassDefNV ( JPBS_t  ,
 
)
inherited

Friends And Related Function Documentation

◆ operator==

bool operator== ( const JUPI_t first,
const JUPI_t second 
)
friend

Equality.

Parameters
firstfirst UPI
secondsecond UPI
Returns
true if UPIs are equals; else false

Definition at line 161 of file JUPI_t.hh.

162  {
163  return (first.getPBS() == second.getPBS() &&
164  first.getVariant() == second.getVariant() &&
165  first.getVersion() == second.getVersion() &&
166  first.getNumber() == second.getNumber());
167  }
const JPBS_t & getPBS() const
Get PBS.
Definition: JPBS_t.hh:101
const std::string & getVariant() const
Get variant.
Definition: JUPI_t.hh:111
int getVersion() const
Get version.
Definition: JUPI_t.hh:122
int getNumber() const
Get serial number.
Definition: JUPI_t.hh:133

◆ operator<

bool operator< ( const JUPI_t first,
const JUPI_t second 
)
friend

Less-than operator.

Parameters
firstfirst UPI
secondsecond UPI
Returns
true if first UPI less than second UPI; else false

Definition at line 177 of file JUPI_t.hh.

178  {
179  if (first.getPBS() == second.getPBS()) {
180 
181  if (first.getVariant() == second.getVariant()) {
182 
183  if (first.getVersion() == second.getVersion())
184  return first.getNumber() < second.getNumber();
185  else
186  return first.getVersion() < second.getVersion();
187 
188  } else {
189 
190  return first.getVariant() < second.getVariant();
191  }
192 
193  } else {
194 
195  return first.getPBS() < second.getPBS();
196  }
197  }

◆ operator>>

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

Read UPI from input stream.

Parameters
ininput stream
objectUPI
Returns
input stream

Definition at line 207 of file JUPI_t.hh.

208  {
209  using namespace std;
210 
211  object = JUPI_t();
212 
213  if (in.peek() != (int) SEPARATOR) {
214  in >> static_cast<JPBS_t&>(object);
215  }
216 
217  if (in.get() == (int) SEPARATOR) {
218 
219  if (in.peek() == (int) SEPARATOR)
220  in.ignore();
221  else
222  getline(in, object.variant, SEPARATOR);
223 
224  if (in.peek() == (int) DOT) {
225 
226  in.ignore();
227 
228  object.version = DEFAULT_VERSION;
229  object.number = DEFAULT_NUMBER;
230 
231  return in;
232 
233  } else if (in >> object.version &&
234  in.get() == (int) DOT &&
235  in >> object.number) {
236 
237  return in;
238  }
239  }
240 
241  in.setstate(ios::failbit);
242 
243  return in;
244  }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
Definition: JSTDTypes.hh:14
static const char DOT
Separator between PBS values.
Definition: JPBS_t.hh:33
static const char SEPARATOR
Separator between PBS, variant and version.
Definition: JUPI_t.hh:36
JUPI_t()
Default constructor.
Definition: JUPI_t.hh:44

◆ operator<<

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

Write UPI to output stream.

Parameters
outoutput stream
objectUPI
Returns
output stream

Definition at line 254 of file JUPI_t.hh.

255  {
256  using namespace std;
257 
258  ostringstream os; // allow for width formatting
259 
260  os << object.getPBS() << JUPI_t::SEPARATOR
261  << object.getVariant() << JUPI_t::SEPARATOR;
262 
263  if (object.getVersion() != DEFAULT_VERSION) {
264  os << object.getVersion();
265  }
266 
267  os << JUPI_t::DOT;
268 
269  if (object.getNumber() != DEFAULT_NUMBER) {
270  os << object.getNumber();
271  }
272 
273  return out << os.str();
274  }

Member Data Documentation

◆ SEPARATOR

const char JDATABASE::JUPI_t::SEPARATOR = '/'
static

Separator between PBS, variant and version.

Definition at line 36 of file JUPI_t.hh.

◆ DEFAULT_VERSION

const int JDATABASE::JUPI_t::DEFAULT_VERSION = -1
static

Default version.

Definition at line 38 of file JUPI_t.hh.

◆ DEFAULT_NUMBER

const int JDATABASE::JUPI_t::DEFAULT_NUMBER = -1
static

Default number.

Definition at line 39 of file JUPI_t.hh.

◆ variant

std::string JDATABASE::JUPI_t::variant
protected

Definition at line 279 of file JUPI_t.hh.

◆ version

int JDATABASE::JUPI_t::version
protected

Definition at line 280 of file JUPI_t.hh.

◆ number

int JDATABASE::JUPI_t::number
protected

Definition at line 281 of file JUPI_t.hh.

◆ DOT

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

Separator between PBS values.

Definition at line 33 of file JPBS_t.hh.


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