CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AtomicId.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVAComputer_AtomicId_h
2 #define PhysicsTools_MVAComputer_AtomicId_h
3 // -*- C++ -*-
4 //
5 // Package: MVAComputer
6 // Class : AtomicID
7 //
8 
9 //
10 // Author: Christophe Saout <christophe.saout@cern.ch>
11 // Created: Sat Apr 24 15:18 CEST 2007
12 //
13 
14 #include <ostream>
15 #include <string>
16 
17 namespace PhysicsTools {
18 
31  class AtomicId {
32  public:
33  inline AtomicId() throw() : string(nullptr) {}
34  inline AtomicId(const AtomicId &orig) throw() : string(orig.string) {}
36  inline AtomicId(const char *arg) throw() : string(lookup(arg)) {}
38  inline AtomicId(const std::string &arg) throw() : string(lookup(arg.c_str())) {}
39  inline ~AtomicId() throw() {}
40 
41  inline AtomicId &operator=(const AtomicId &orig) throw() {
42  string = orig.string;
43  return *this;
44  }
45 
47  inline operator const char *() const throw() { return string; }
48 
50  inline operator bool() const throw() { return string != nullptr; }
51 
53  inline operator std::string() const throw() { return std::string(string); }
54 
55  inline bool operator==(const AtomicId &second) const throw() { return string == second.string; }
56  inline bool operator!=(const AtomicId &second) const throw() { return string != second.string; }
57  inline bool operator<(const AtomicId &second) const throw() { return string < second.string; }
58  inline bool operator<=(const AtomicId &second) const throw() { return string <= second.string; }
59  inline bool operator>(const AtomicId &second) const throw() { return string > second.string; }
60  inline bool operator>=(const AtomicId &second) const throw() { return string >= second.string; }
61 
62  private:
63  static AtomicId build(const char *arg) throw() {
64  AtomicId q;
65  q.string = arg;
66  return q;
67  }
68  static const char *lookup(const char *arg) throw();
69 
70  const char *string;
71  };
72 
74  inline std::ostream &operator<<(std::ostream &os, const PhysicsTools::AtomicId &id) { return os << (const char *)id; }
75 
76 } // namespace PhysicsTools
77 
78 #endif // PhysicsTools_MVAComputer_AtomicId_h
bool operator>=(const AtomicId &second) const
Definition: AtomicId.h:60
AtomicId(const AtomicId &orig)
Definition: AtomicId.h:34
const char * string
Definition: AtomicId.h:70
bool operator==(const AtomicId &second) const
Definition: AtomicId.h:55
static const char * lookup(const char *arg)
Definition: AtomicId.cc:59
A arg
Definition: Factorize.h:31
static AtomicId build(const char *arg)
Definition: AtomicId.h:63
Cheap generic unique keyword identifier class.
Definition: AtomicId.h:31
U second(std::pair< T, U > const &p)
bool operator<(const AtomicId &second) const
Definition: AtomicId.h:57
bool operator!=(const AtomicId &second) const
Definition: AtomicId.h:56
std::ostream & operator<<(std::ostream &os, const PhysicsTools::AtomicId &id)
STL streaming operator.
Definition: AtomicId.h:74
bool operator>(const AtomicId &second) const
Definition: AtomicId.h:59
AtomicId & operator=(const AtomicId &orig)
Definition: AtomicId.h:41
AtomicId(const std::string &arg)
constructs an AtomicId from a STL string
Definition: AtomicId.h:38
bool operator<=(const AtomicId &second) const
Definition: AtomicId.h:58
AtomicId(const char *arg)
constructs an AtomicId from a C string
Definition: AtomicId.h:36