File indexing completed on 2024-04-06 12:23:37
0001 #ifndef PhysicsTools_MVAComputer_AtomicId_h
0002 #define PhysicsTools_MVAComputer_AtomicId_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <ostream>
0015 #include <string>
0016
0017 namespace PhysicsTools {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class AtomicId {
0032 public:
0033 inline AtomicId() throw() : string(nullptr) {}
0034 inline AtomicId(const AtomicId &orig) throw() : string(orig.string) {}
0035
0036 inline AtomicId(const char *arg) throw() : string(lookup(arg)) {}
0037
0038 inline AtomicId(const std::string &arg) throw() : string(lookup(arg.c_str())) {}
0039 inline ~AtomicId() throw() {}
0040
0041 inline AtomicId &operator=(const AtomicId &orig) throw() {
0042 string = orig.string;
0043 return *this;
0044 }
0045
0046
0047 inline operator const char *() const throw() { return string; }
0048
0049
0050 inline operator bool() const throw() { return string != nullptr; }
0051
0052
0053 inline operator std::string() const throw() { return std::string(string); }
0054
0055 inline bool operator==(const AtomicId &second) const throw() { return string == second.string; }
0056 inline bool operator!=(const AtomicId &second) const throw() { return string != second.string; }
0057 inline bool operator<(const AtomicId &second) const throw() { return string < second.string; }
0058 inline bool operator<=(const AtomicId &second) const throw() { return string <= second.string; }
0059 inline bool operator>(const AtomicId &second) const throw() { return string > second.string; }
0060 inline bool operator>=(const AtomicId &second) const throw() { return string >= second.string; }
0061
0062 private:
0063 static AtomicId build(const char *arg) throw() {
0064 AtomicId q;
0065 q.string = arg;
0066 return q;
0067 }
0068 static const char *lookup(const char *arg) throw();
0069
0070 const char *string;
0071 };
0072
0073
0074 inline std::ostream &operator<<(std::ostream &os, const PhysicsTools::AtomicId &id) { return os << (const char *)id; }
0075
0076 }
0077
0078 #endif