/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FWCore/Reflection/interface/ObjectWithDict.h
51 строка
2 KB
Andrea Bocci
Modernise the interface of ObjectWithDict
25 фев 2025, 18:47
Не верифицирован
25 фев 2025, 18:47
56fc42f
Код
Авторство
О чём код?
#ifndef FWCore_Reflection_ObjectWithDict_h #define FWCore_Reflection_ObjectWithDict_h /*---------------------------------------------------------------------- ObjectWithDict: A holder for an object and its type information. ----------------------------------------------------------------------*/ #include <string> #include <typeinfo> #include "FWCore/Reflection/interface/TypeWithDict.h" namespace edm { class ObjectWithDict { private: TypeWithDict type_; void* address_; public: static ObjectWithDict byType(TypeWithDict const&); public: ObjectWithDict() : address_(nullptr) {} explicit ObjectWithDict(TypeWithDict const& type, void* address) : type_(type), address_(address) {} explicit ObjectWithDict(std::type_info const& type, void* address) : type_(TypeWithDict(type)), address_(address) {} explicit operator bool() const { return bool(type_) && (address_ != nullptr); } void* address() const { return address_; } TypeWithDict const& typeOf() const { return type_; } TypeWithDict dynamicType() const; ObjectWithDict castObject(TypeWithDict const&) const; ObjectWithDict get(std::string const& memberName) const; //ObjectWithDict construct() const; void destruct(bool dealloc) const; template <typename T> T& objectCast() { return *reinterpret_cast<T*>(address()); } template <typename T> T const& objectCast() const { return *reinterpret_cast<T*>(address()); } }; } // namespace edm #endif // FWCore_Reflection_ObjectWithDict_h