File tree Expand file tree Collapse file tree 2 files changed +19
-26
lines changed
Expand file tree Collapse file tree 2 files changed +19
-26
lines changed Original file line number Diff line number Diff line change @@ -23,20 +23,26 @@ namespace edm {
2323 static ObjectWithDict byType (TypeWithDict const &);
2424
2525 public:
26- ObjectWithDict ();
27- explicit ObjectWithDict (TypeWithDict const &, void * address);
28- explicit ObjectWithDict (std::type_info const &, void * address);
29- explicit operator bool () const ;
30- void * address () const ;
31- TypeWithDict typeOf () const ;
26+ ObjectWithDict () : address_( nullptr ) {}
27+ explicit ObjectWithDict (TypeWithDict const & type , void * address) : type_(type), address_(address) {}
28+ explicit ObjectWithDict (std::type_info const & type , void * address) : type_(TypeWithDict(type)), address_(address) {}
29+ explicit operator bool () const { return bool (type_) && (address_ != nullptr ); }
30+ void * address () const { return address_; }
31+ TypeWithDict const & typeOf () const { return type_; }
3232 TypeWithDict dynamicType () const ;
3333 ObjectWithDict castObject (TypeWithDict const &) const ;
3434 ObjectWithDict get (std::string const & memberName) const ;
3535 // ObjectWithDict construct() const;
3636 void destruct (bool dealloc) const ;
37+
38+ template <typename T>
39+ T& objectCast () {
40+ return *reinterpret_cast <T*>(address ());
41+ }
42+
3743 template <typename T>
38- T objectCast () {
39- return *reinterpret_cast <T*>(address_ );
44+ T const & objectCast () const {
45+ return *reinterpret_cast <T*>(address () );
4046 }
4147 };
4248
Original file line number Diff line number Diff line change 1- #include " FWCore/Reflection/interface/ObjectWithDict.h"
1+ #ifndef _LIBCPP_VERSION
2+ #include < cxxabi.h>
3+ #endif
24
35#include " FWCore/Reflection/interface/BaseWithDict.h"
46#include " FWCore/Reflection/interface/MemberWithDict.h"
7+ #include " FWCore/Reflection/interface/ObjectWithDict.h"
58#include " FWCore/Reflection/interface/TypeWithDict.h"
69
7- #ifndef _LIBCPP_VERSION
8- #include < cxxabi.h>
9- #endif
10-
1110namespace edm {
1211
1312 ObjectWithDict ObjectWithDict::byType (TypeWithDict const & type) {
1413 ObjectWithDict obj (type.construct ());
1514 return obj;
1615 }
1716
18- ObjectWithDict::ObjectWithDict () : type_(), address_(nullptr ) {}
19-
20- ObjectWithDict::ObjectWithDict (TypeWithDict const & type, void * address) : type_(type), address_(address) {}
21-
22- ObjectWithDict::ObjectWithDict (std::type_info const & ti, void * address)
23- : type_(TypeWithDict(ti)), address_(address) {}
24-
25- ObjectWithDict::operator bool () const { return bool (type_) && (address_ != nullptr ); }
26-
27- void * ObjectWithDict::address () const { return address_; }
28-
29- TypeWithDict ObjectWithDict::typeOf () const { return type_; }
30-
3117 class DummyVT {
3218 public:
3319 virtual ~DummyVT ();
3420 };
3521
3622 DummyVT::~DummyVT () {}
3723
24+ // FIXME improve TypeWithDict::byTypeInfo to return by const& and return by const& here
3825 TypeWithDict ObjectWithDict::dynamicType () const {
3926 if (!type_.isVirtual ()) {
4027 return type_;
You can’t perform that action at this time.
0 commit comments