ATLAS Offline Software
Public Member Functions | List of all members
SCT_SerialNumber Class Reference

#include <SCT_SerialNumber.h>

Collaboration diagram for SCT_SerialNumber:

Public Member Functions

 SCT_SerialNumber ()
 Default constructor produces an invalid serial number. More...
 
 SCT_SerialNumber (const std::string &snString)
 Construct from string of the full number. More...
 
 SCT_SerialNumber (const unsigned long long fullSerialNumber)
 Construct from full number (unsigned), which has to be a long long. More...
 
 SCT_SerialNumber (const long long fullSerialNumber)
 Construct from full number (signed), which has to be a long long. More...
 
 SCT_SerialNumber (const unsigned int truncatedSerialNumber)
 Construct from unsigned int, which can only hold the truncated serial number. More...
 
 SCT_SerialNumber (const int truncatedSerialNumber)
 Construct from int, which can only hold the truncated serial number. More...
 

conversions to other forms

unsigned int m_truncatedNumber
 The truncated number holds the integer part after the '20220' of the serial number. More...
 
std::string str () const
 Full serial number as a string
More...
 
unsigned int to_uint () const
 Truncated serial number as unsigned int. More...
 
unsigned long long to_ulonglong () const
 Full serial number as long long. More...
 
 operator unsigned int () const
 Overload cast to uint. More...
 
bool isWellFormed () const
 Cursory check on whether the serial number is well formed N.B. More...
 
bool is_valid () const
 Until a better test is made, is_valid returns only whether its well formed. More...
 

Detailed Description

SCT_SerialNumber is a class to hold a serial number and provide check on validity, and conversions between the different formats. In general, an SCT serial number is a unique 14 digit code assigned to each module and found on the module as a bar code. It always starts with 20220

Definition at line 22 of file SCT_SerialNumber.h.

Constructor & Destructor Documentation

◆ SCT_SerialNumber() [1/6]

SCT_SerialNumber::SCT_SerialNumber ( )

Default constructor produces an invalid serial number.

Definition at line 17 of file SCT_SerialNumber.cxx.

17  : m_truncatedNumber(0){
18  //nop
19 }

◆ SCT_SerialNumber() [2/6]

SCT_SerialNumber::SCT_SerialNumber ( const std::string &  snString)

Construct from string of the full number.

Definition at line 21 of file SCT_SerialNumber.cxx.

21  {
22  if (snString.substr(0,5)==std::string("20220")){
23  m_truncatedNumber=std::stoi(snString.substr(5));
24  } else {
26  }
27 }

◆ SCT_SerialNumber() [3/6]

SCT_SerialNumber::SCT_SerialNumber ( const unsigned long long  fullSerialNumber)

Construct from full number (unsigned), which has to be a long long.

Definition at line 29 of file SCT_SerialNumber.cxx.

29  {
30  if (fullSerialNumber > 20220000000000LL){
31  m_truncatedNumber=static_cast<unsigned int>(fullSerialNumber - 20220000000000LL);
32  } else {
34  }
35 }

◆ SCT_SerialNumber() [4/6]

SCT_SerialNumber::SCT_SerialNumber ( const long long  fullSerialNumber)

Construct from full number (signed), which has to be a long long.

Definition at line 37 of file SCT_SerialNumber.cxx.

37  {
38  if (fullSerialNumber > 20220000000000LL){
39  m_truncatedNumber=static_cast<unsigned int>(fullSerialNumber - 20220000000000LL);
40  } else {
42  }
43 }

◆ SCT_SerialNumber() [5/6]

SCT_SerialNumber::SCT_SerialNumber ( const unsigned int  truncatedSerialNumber)

Construct from unsigned int, which can only hold the truncated serial number.

Definition at line 46 of file SCT_SerialNumber.cxx.

46  {
47  m_truncatedNumber=truncatedSerialNumber;
48 }

◆ SCT_SerialNumber() [6/6]

SCT_SerialNumber::SCT_SerialNumber ( const int  truncatedSerialNumber)

Construct from int, which can only hold the truncated serial number.

Definition at line 50 of file SCT_SerialNumber.cxx.

50  {
51  m_truncatedNumber=static_cast<unsigned int>(truncatedSerialNumber);
52 }

Member Function Documentation

◆ is_valid()

bool SCT_SerialNumber::is_valid ( ) const
inline

Until a better test is made, is_valid returns only whether its well formed.

Definition at line 72 of file SCT_SerialNumber.h.

72 { return isWellFormed(); }

◆ isWellFormed()

bool SCT_SerialNumber::isWellFormed ( ) const

Cursory check on whether the serial number is well formed N.B.

this is deliberately not an 'is_valid' method since a check on validity would require more comprehensive validation.

Definition at line 81 of file SCT_SerialNumber.cxx.

81  {
82  return m_truncatedNumber!=0;
83 }

◆ operator unsigned int()

SCT_SerialNumber::operator unsigned int ( ) const

Overload cast to uint.

Definition at line 76 of file SCT_SerialNumber.cxx.

76  {
77  return to_uint();
78 }

◆ str()

std::string SCT_SerialNumber::str ( ) const

Full serial number as a string

Definition at line 56 of file SCT_SerialNumber.cxx.

56  {
57  if (m_truncatedNumber){
58  std::ostringstream os;
59  os<<"20220"<<std::setfill('0')<<std::setw(9)<<m_truncatedNumber;
60  return os.str();
61  } else {
62  return std::string("0");
63  }
64 }

◆ to_uint()

unsigned int SCT_SerialNumber::to_uint ( ) const

Truncated serial number as unsigned int.

Definition at line 67 of file SCT_SerialNumber.cxx.

67  {
68  return m_truncatedNumber;
69 }

◆ to_ulonglong()

unsigned long long SCT_SerialNumber::to_ulonglong ( ) const

Full serial number as long long.

Definition at line 72 of file SCT_SerialNumber.cxx.

72  {
73  return m_truncatedNumber?(20220000000000LL + m_truncatedNumber):0LL;
74 }

Member Data Documentation

◆ m_truncatedNumber

unsigned int SCT_SerialNumber::m_truncatedNumber
private

The truncated number holds the integer part after the '20220' of the serial number.

Definition at line 76 of file SCT_SerialNumber.h.


The documentation for this class was generated from the following files:
SCT_SerialNumber::to_uint
unsigned int to_uint() const
Truncated serial number as unsigned int.
Definition: SCT_SerialNumber.cxx:67
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SCT_SerialNumber::m_truncatedNumber
unsigned int m_truncatedNumber
The truncated number holds the integer part after the '20220' of the serial number.
Definition: SCT_SerialNumber.h:76
SCT_SerialNumber::isWellFormed
bool isWellFormed() const
Cursory check on whether the serial number is well formed N.B.
Definition: SCT_SerialNumber.cxx:81