/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Alignment/Geners/interface/Reference.hh
86 строк
3 KB
Ivan Razumov
Add missing include
30 ноя 2023, 14:11
30 ноя 2023, 14:11
3d5c5ef
Код
Авторство
О чём код?
#ifndef GENERS_REFERENCE_HH_ #define GENERS_REFERENCE_HH_ #include "Alignment/Geners/interface/AbsReference.hh" #include <memory> #include <memory> namespace gs { template <typename T> class Reference : public AbsReference { public: inline Reference(AbsArchive &ar, const unsigned long long itemId) : AbsReference(ar, ClassId::makeId<T>(), "gs::Single", itemId) {} inline Reference(AbsArchive &ar, const char *name, const char *category) : AbsReference(ar, ClassId::makeId<T>(), "gs::Single", name, category) {} #ifndef SWIG inline Reference(AbsArchive &ar, const std::string &name, const char *category) : AbsReference(ar, ClassId::makeId<T>(), "gs::Single", name.c_str(), category) {} inline Reference(AbsArchive &ar, const char *name, const std::string &category) : AbsReference(ar, ClassId::makeId<T>(), "gs::Single", name, category.c_str()) {} inline Reference(AbsArchive &ar, const std::string &name, const std::string &category) : AbsReference(ar, ClassId::makeId<T>(), "gs::Single", name.c_str(), category.c_str()) {} #endif inline Reference(AbsArchive &ar, const SearchSpecifier &namePattern, const SearchSpecifier &categoryPattern) : AbsReference(ar, ClassId::makeId<T>(), "gs::Single", namePattern, categoryPattern) {} // Methods to retrieve the item void restore(unsigned long index, T *obj) const; std::unique_ptr<T> get(unsigned long index) const; std::shared_ptr<T> getShared(unsigned long index) const; Reference() = delete; private: T *getPtr(unsigned long index) const; }; } // namespace gs #include "Alignment/Geners/interface/GenericIO.hh" namespace gs { template <typename T> inline void Reference<T>::restore(const unsigned long index, T *obj) const { const unsigned long long itemId = this->id(index); assert(itemId); restore_item(this->positionInputStream(itemId), obj, true); } template <typename T> inline T *Reference<T>::getPtr(const unsigned long index) const { const unsigned long long itemId = this->id(index); assert(itemId); T *barePtr = nullptr; std::vector<ClassId> state; if (GenericReader<std::istream, std::vector<ClassId>, T *, Int2Type<IOTraits<int>::ISNULLPOINTER>>::process( barePtr, this->positionInputStream(itemId), &state, true)) assert(barePtr); else { delete barePtr; barePtr = nullptr; } if (!barePtr) throw IOInvalidData( "In gs::Reference::getPtr: " "failed to read in the object"); return barePtr; } template <typename T> inline std::unique_ptr<T> Reference<T>::get(const unsigned long index) const { return std::unique_ptr<T>(getPtr(index)); } template <typename T> inline std::shared_ptr<T> Reference<T>::getShared(const unsigned long index) const { return std::shared_ptr<T>(getPtr(index)); } } // namespace gs #endif // GENERS_REFERENCE_HH_