Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:06

0001 #include "FWCore/Reflection/interface/MemberWithDict.h"
0002 
0003 #include "FWCore/Reflection/interface/ObjectWithDict.h"
0004 #include "FWCore/Reflection/interface/TypeWithDict.h"
0005 #include <ostream>
0006 #include <sstream>
0007 
0008 namespace edm {
0009 
0010   MemberWithDict::MemberWithDict() : dataMember_(nullptr) {}
0011 
0012   MemberWithDict::MemberWithDict(TDataMember* dataMember) : dataMember_(dataMember) {}
0013 
0014   MemberWithDict::operator bool() const { return dataMember_ != nullptr; }
0015 
0016   std::string MemberWithDict::name() const { return dataMember_->GetName(); }
0017 
0018   TypeWithDict MemberWithDict::typeOf() const {
0019     if (isArray()) {
0020       std::ostringstream name;
0021       name << dataMember_->GetTrueTypeName();
0022       for (int i = 0; i < dataMember_->GetArrayDim(); ++i) {
0023         name << '[';
0024         name << dataMember_->GetMaxIndex(i);
0025         name << ']';
0026       }
0027       return TypeWithDict::byName(name.str());
0028     }
0029     return TypeWithDict::byName(dataMember_->GetTrueTypeName());
0030   }
0031 
0032   TypeWithDict MemberWithDict::declaringType() const { return TypeWithDict(dataMember_->GetClass()); }
0033 
0034   bool MemberWithDict::isArray() const { return dataMember_->Property() & kIsArray; }
0035 
0036   bool MemberWithDict::isConst() const { return dataMember_->Property() & kIsConstant; }
0037 
0038   bool MemberWithDict::isPublic() const { return dataMember_->Property() & kIsPublic; }
0039 
0040   bool MemberWithDict::isStatic() const { return dataMember_->Property() & kIsStatic; }
0041 
0042   bool MemberWithDict::isTransient() const { return !dataMember_->IsPersistent(); }
0043 
0044   size_t MemberWithDict::offset() const { return dataMember_->GetOffset(); }
0045 
0046   ObjectWithDict MemberWithDict::get() const {
0047     return ObjectWithDict(typeOf(), reinterpret_cast<void*>(dataMember_->GetOffset()));
0048   }
0049 
0050   ObjectWithDict MemberWithDict::get(ObjectWithDict const& obj) const {
0051     return ObjectWithDict(typeOf(), reinterpret_cast<char*>(obj.address()) + dataMember_->GetOffset());
0052   }
0053 
0054 }  // namespace edm