Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:18

0001 #ifndef GENERS_ARRAYREFERENCE_HH_
0002 #define GENERS_ARRAYREFERENCE_HH_
0003 
0004 #include <cstddef>
0005 #include "Alignment/Geners/interface/AbsReference.hh"
0006 
0007 namespace gs {
0008     template <typename T>
0009     class ArrayReference : public AbsReference
0010     {
0011     public:
0012         inline ArrayReference(AbsArchive& ar, const unsigned long long itemId)
0013             : AbsReference(ar, ClassId::makeId<T>(), "gs::Array", itemId) {}
0014 
0015         inline ArrayReference(AbsArchive& ar,
0016                               const char* name, const char* category)
0017             :  AbsReference(ar, ClassId::makeId<T>(), "gs::Array",
0018                             name, category) {}
0019 
0020         inline ArrayReference(AbsArchive& ar,
0021                               const SearchSpecifier& namePattern,
0022                               const SearchSpecifier& categoryPattern)
0023             :  AbsReference(ar, ClassId::makeId<T>(), "gs::Array",
0024                             namePattern, categoryPattern) {}
0025 
0026         // There is only one method to retrieve an array
0027         void restore(unsigned long idx, T* arr, std::size_t len) const;
0028 
0029     private:
0030         ArrayReference();
0031     };
0032 }
0033 
0034 #include "Alignment/Geners/interface/GenericIO.hh"
0035 
0036 namespace gs {
0037     template <typename T>
0038     inline void ArrayReference<T>::restore(const unsigned long index, T* arr,
0039                                            const std::size_t len) const
0040     {
0041         const unsigned long long itemId = this->id(index);
0042         assert(itemId);
0043         read_array(this->positionInputStream(itemId), arr, len);
0044     }
0045 }
0046 
0047 
0048 #endif // GENERS_ARRAYREFERENCE_HH_
0049