![]() |
|
|||
File indexing completed on 2024-04-06 12:13:13
0001 #ifndef FWCore_Utilities_TypeIDBase_h 0002 #define FWCore_Utilities_TypeIDBase_h 0003 // -*- C++ -*- 0004 // 0005 // Package: Utilities 0006 // Class : TypeIDBase 0007 // 0008 /**\class TypeIDBase TypeIDBase.h FWCore/Utilities/interface/TypeIDBase.h 0009 0010 Description: Base class for classes used to compare C++ types 0011 0012 Usage: 0013 This class is not meant to be used polymorphically (which is why there is no virtual destructor). 0014 Instead it is used to hold a common methods needed by all type comparing classes. 0015 0016 */ 0017 // 0018 // Original Author: Chris Jones 0019 // Created: Thu Nov 10 14:59:35 EST 2005 0020 // 0021 0022 // system include files 0023 #include <typeinfo> 0024 0025 // user include files 0026 0027 // forward declarations 0028 namespace edm { 0029 class TypeIDBase { 0030 public: 0031 struct Def {}; 0032 0033 constexpr TypeIDBase() noexcept : t_(&(typeid(Def))) {} 0034 0035 constexpr explicit TypeIDBase(const std::type_info& t) noexcept : t_(&t) {} 0036 0037 constexpr explicit TypeIDBase(const std::type_info* t) noexcept : t_(t == nullptr ? &(typeid(Def)) : t) {} 0038 0039 // ---------- const member functions --------------------- 0040 0041 /** Returned C-style string owned by system; do not delete[] it. 0042 This is the (horrible, mangled, platform-dependent) name of 0043 the type. */ 0044 const char* name() const { return t_->name(); } 0045 0046 bool operator<(const TypeIDBase& b) const { return t_->before(*(b.t_)); } 0047 bool operator==(const TypeIDBase& b) const { return (*t_) == *(b.t_); } 0048 0049 protected: 0050 constexpr const std::type_info& typeInfo() const { return *t_; } 0051 0052 private: 0053 //const TypeIDBase& operator=(const TypeIDBase&); // stop default 0054 0055 // ---------- member data -------------------------------- 0056 //NOTE: since the compiler generates the type_info's and they have a lifetime 0057 // good for the entire application, we do not have to delete it 0058 // We also are using a pointer rather than a reference so that operator= will work 0059 const std::type_info* t_; 0060 }; 0061 0062 inline bool operator>(const TypeIDBase& a, const TypeIDBase& b) { return b < a; } 0063 0064 inline bool operator!=(const TypeIDBase& a, const TypeIDBase& b) { return !(a == b); } 0065 0066 } // namespace edm 0067 0068 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |