test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OId.cc
Go to the documentation of this file.
2 //
3 #include <cstdio>
4 #include <cstring>
5 
6 static const char* OIDFMT = "%04X-%08X";
7 static const size_t OIDSIZ = 14;
8 
10  ora::OId tmp;
11  return tmp.fromString( input );
12 }
13 
15  m_containerId(-1),
16  m_itemId(-1){
17 }
18 
19 ora::OId::OId( const std::pair<int,int>& oidPair ):
20  m_containerId( oidPair.first ),
21  m_itemId( oidPair.second ){
22 }
23 
24 ora::OId::OId( int contId, int itemId ):
25  m_containerId( contId),
26  m_itemId( itemId ){
27 }
28 
29 ora::OId::OId( const OId& rhs ):
30  m_containerId( rhs.m_containerId),
31  m_itemId( rhs.m_itemId ){
32 }
33 
35  m_containerId = rhs.m_containerId;
36  m_itemId = rhs.m_itemId;
37  return *this;
38 }
39 
40 bool ora::OId::operator==( const OId& rhs ) const {
41  if(m_containerId != rhs.m_containerId ) return false;
42  if(m_itemId != rhs.m_itemId ) return false;
43  return true;
44 }
45 
46 bool ora::OId::operator!=( const OId& rhs ) const {
47  return !operator==(rhs);
48 }
49 
51  return m_containerId;
52 }
53 
54 int ora::OId::itemId() const{
55  return m_itemId;
56 }
57 
59  char text[OIDSIZ];
60  ::snprintf(text, OIDSIZ, OIDFMT, m_containerId, m_itemId );
61  return std::string(text);
62 }
63 
65  if(source.size()>OIDSIZ) return false; // constraint relaxed...
66  const char* ptr = source.c_str();
67  if( ::sscanf( ptr, OIDFMT, &m_containerId, &m_itemId )==2 ) return true;
68  return false;
69 }
70 
71 void ora::OId::toOutputStream( std::ostream& os ) const {
72  os << this->toString();
73 }
74 
76  m_containerId = -1;
77  m_itemId = -1;
78 }
79 
80 bool ora::OId::isInvalid() const {
81  return (m_containerId == -1 || m_itemId == -1);
82 }
83 
84 std::pair<int,int> ora::OId::toPair() const {
85  return std::make_pair( m_containerId, m_itemId );
86 }
bool isInvalid() const
Definition: OId.cc:80
Definition: OId.h:8
int m_containerId
Definition: OId.h:46
static bool isOId(const std::string &input)
Definition: OId.cc:9
OId()
Definition: OId.cc:14
bool operator==(const OId &rhs) const
Definition: OId.cc:40
static std::string const input
Definition: EdmProvDump.cc:44
U second(std::pair< T, U > const &p)
std::pair< int, int > toPair() const
Definition: OId.cc:84
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
OId & operator=(const OId &rhs)
Definition: OId.cc:34
int containerId() const
Definition: OId.cc:50
static const size_t OIDSIZ
Definition: OId.cc:7
tuple text
Definition: runonSM.py:42
bool operator!=(const OId &rhs) const
Definition: OId.cc:46
static const char * OIDFMT
Definition: OId.cc:6
int m_itemId
Definition: OId.h:47
std::string toString() const
Definition: OId.cc:58
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void reset()
Definition: OId.cc:75
bool fromString(const std::string &s)
Definition: OId.cc:64
static std::string const source
Definition: EdmProvDump.cc:43
void toOutputStream(std::ostream &os) const
Definition: OId.cc:71
int itemId() const
Definition: OId.cc:54