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 // $Id: AtomicId.h,v 1.4 2007/12/08 16:11:10 saout Exp $
13 //
14 
15 #include <ostream>
16 #include <string>
17 
18 namespace PhysicsTools {
19 
32 class AtomicId {
33  public:
34  inline AtomicId() throw() : string(0) {}
35  inline AtomicId(const AtomicId &orig) throw() : string(orig.string) {}
37  inline AtomicId(const char *arg) throw() : string(lookup(arg)) {}
39  inline AtomicId(const std::string &arg) throw() :
40  string(lookup(arg.c_str())) {}
41  inline ~AtomicId() throw() {}
42 
43  inline AtomicId &operator = (const AtomicId &orig) throw()
44  { string = orig.string; return *this; }
45 
47  inline operator const char *() const throw()
48  { return string; }
49 
51  inline operator bool() const throw()
52  { return string != 0; }
53 
55  inline operator std::string() const throw()
56  { return std::string(string); }
57 
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  inline bool operator >= (const AtomicId &second) const throw() { return string >= second.string; }
64 
65  private:
66  static AtomicId build(const char *arg) throw() { AtomicId q; q.string = arg; return q; }
67  static const char *lookup(const char *arg) throw();
68 
69  const char *string;
70 };
71 
73 inline std::ostream &operator << (std::ostream &os, const PhysicsTools::AtomicId &id)
74 { 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:63
AtomicId(const AtomicId &orig)
Definition: AtomicId.h:35
const char * string
Definition: AtomicId.h:69
bool operator==(const AtomicId &second) const
Definition: AtomicId.h:58
static const char * lookup(const char *arg)
Definition: AtomicId.cc:67
A arg
Definition: Factorize.h:36
static AtomicId build(const char *arg)
Definition: AtomicId.h:66
Cheap generic unique keyword identifier class.
Definition: AtomicId.h:32
U second(std::pair< T, U > const &p)
bool operator<(const AtomicId &second) const
Definition: AtomicId.h:60
bool operator!=(const AtomicId &second) const
Definition: AtomicId.h:59
std::ostream & operator<<(std::ostream &os, const PhysicsTools::AtomicId &id)
STL streaming operator.
Definition: AtomicId.h:73
bool operator>(const AtomicId &second) const
Definition: AtomicId.h:62
AtomicId & operator=(const AtomicId &orig)
Definition: AtomicId.h:43
AtomicId(const std::string &arg)
constructs an AtomicId from a STL string
Definition: AtomicId.h:39
bool operator<=(const AtomicId &second) const
Definition: AtomicId.h:61
AtomicId(const char *arg)
constructs an AtomicId from a C string
Definition: AtomicId.h:37