CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/PhysicsTools/MVAComputer/interface/AtomicId.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_MVAComputer_AtomicId_h
00002 #define PhysicsTools_MVAComputer_AtomicId_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     MVAComputer
00006 // Class  :     AtomicID
00007 //
00008 
00009 //
00010 // Author:      Christophe Saout <christophe.saout@cern.ch>
00011 // Created:     Sat Apr 24 15:18 CEST 2007
00012 // $Id: AtomicId.h,v 1.4 2007/12/08 16:11:10 saout Exp $
00013 //
00014 
00015 #include <ostream>
00016 #include <string>
00017 
00018 namespace PhysicsTools {
00019 
00032 class AtomicId {
00033     public:
00034         inline AtomicId() throw() : string(0) {}
00035         inline AtomicId(const AtomicId &orig) throw() : string(orig.string) {}
00037         inline AtomicId(const char *arg) throw() : string(lookup(arg)) {}
00039         inline AtomicId(const std::string &arg) throw() :
00040                 string(lookup(arg.c_str())) {}
00041         inline ~AtomicId() throw() {}
00042 
00043         inline AtomicId &operator = (const AtomicId &orig) throw()
00044         { string = orig.string; return *this; }
00045 
00047         inline operator const char *() const throw()
00048         { return string; }
00049 
00051         inline operator bool() const throw()
00052         { return string != 0; }
00053 
00055         inline operator std::string() const throw()
00056         { return std::string(string); }
00057 
00058         inline bool operator == (const AtomicId &second) const throw() { return string == second.string; }
00059         inline bool operator != (const AtomicId &second) const throw() { return string != second.string; }
00060         inline bool operator <  (const AtomicId &second) const throw() { return string <  second.string; }
00061         inline bool operator <= (const AtomicId &second) const throw() { return string <= second.string; }
00062         inline bool operator >  (const AtomicId &second) const throw() { return string >  second.string; }
00063         inline bool operator >= (const AtomicId &second) const throw() { return string >= second.string; }
00064 
00065     private:
00066         static AtomicId build(const char *arg) throw() { AtomicId q; q.string = arg; return q; }
00067         static const char *lookup(const char *arg) throw();
00068 
00069         const char      *string;
00070 };
00071 
00073 inline std::ostream &operator << (std::ostream &os, const PhysicsTools::AtomicId &id)
00074 { return os << (const char*)id; }
00075 
00076 } // namespace PhysicsTools
00077 
00078 #endif // PhysicsTools_MVAComputer_AtomicId_h