CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/FWCore/Utilities/src/ObjectWithDict.cc

Go to the documentation of this file.
00001 #include "FWCore/Utilities/interface/MemberWithDict.h"
00002 #include "FWCore/Utilities/interface/ObjectWithDict.h"
00003 
00004 namespace edm {
00005 
00006   ObjectWithDict::ObjectWithDict() :
00007     type_(),
00008     address_(nullptr) {
00009   }
00010 
00011   ObjectWithDict
00012   ObjectWithDict::byType(TypeWithDict const& type) {
00013     ObjectWithDict obj(type.construct());
00014     return obj;
00015   }
00016 
00017   ObjectWithDict::ObjectWithDict(TypeWithDict const& type, void* address) :
00018     type_(type),
00019     address_(address) {
00020   }
00021 
00022   ObjectWithDict::ObjectWithDict(std::type_info const& typeID, void* address) :
00023     type_(TypeWithDict(typeID)),
00024     address_(address) {
00025   }
00026 
00027   TypeWithDict const&
00028   ObjectWithDict::typeOf() const {
00029     return type_;
00030   }
00031 
00032   TypeWithDict
00033   ObjectWithDict::dynamicType() const {
00034     if(!type_.isVirtual()) {
00035       return type_;
00036     }
00037     struct Dummy_t {virtual ~Dummy_t() {} };
00038     return TypeWithDict(typeid(*(Dummy_t*)address_));
00039   }
00040 
00041   ObjectWithDict::operator bool() const {
00042     return bool(type_) && address_ != nullptr;
00043   }
00044 
00045   void*
00046   ObjectWithDict::address() const {
00047     return address_;
00048   }
00049 
00050   ObjectWithDict
00051   ObjectWithDict::get(std::string const& memberName) const {
00052     return type_.dataMemberByName(memberName).get(*this);
00053   }
00054 }