CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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(0) {}
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() :
39  string(lookup(arg.c_str())) {}
40  inline ~AtomicId() throw() {}
41 
42  inline AtomicId &operator = (const AtomicId &orig) throw()
43  { string = orig.string; return *this; }
44 
46  inline operator const char *() const throw()
47  { return string; }
48 
50  inline operator bool() const throw()
51  { return string != 0; }
52 
54  inline operator std::string() const throw()
55  { return std::string(string); }
56 
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  inline bool operator > (const AtomicId &second) const throw() { return string > second.string; }
62  inline bool operator >= (const AtomicId &second) const throw() { return string >= second.string; }
63 
64  private:
65  static AtomicId build(const char *arg) throw() { AtomicId q; q.string = arg; return q; }
66  static const char *lookup(const char *arg) throw();
67 
68  const char *string;
69 };
70 
72 inline std::ostream &operator << (std::ostream &os, const PhysicsTools::AtomicId &id)
73 { return os << (const char*)id; }
74 
75 } // namespace PhysicsTools
76 
77 #endif // PhysicsTools_MVAComputer_AtomicId_h
bool operator>=(const AtomicId &second) const
Definition: AtomicId.h:62
AtomicId(const AtomicId &orig)
Definition: AtomicId.h:34
const char * string
Definition: AtomicId.h:68
bool operator==(const AtomicId &second) const
Definition: AtomicId.h:57
static const char * lookup(const char *arg)
Definition: AtomicId.cc:65
A arg
Definition: Factorize.h:36
static AtomicId build(const char *arg)
Definition: AtomicId.h:65
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:59
bool operator!=(const AtomicId &second) const
Definition: AtomicId.h:58
std::ostream & operator<<(std::ostream &os, const PhysicsTools::AtomicId &id)
STL streaming operator.
Definition: AtomicId.h:72
bool operator>(const AtomicId &second) const
Definition: AtomicId.h:61
AtomicId & operator=(const AtomicId &orig)
Definition: AtomicId.h:42
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:60
AtomicId(const char *arg)
constructs an AtomicId from a C string
Definition: AtomicId.h:36