Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:52

0001 #ifndef GENERS_IOISREADABLE_HH_
0002 #define GENERS_IOISREADABLE_HH_
0003 
0004 #include "Alignment/Geners/interface/ClassId.hh"
0005 #include "Alignment/Geners/interface/IOIsClassType.hh"
0006 #include "Alignment/Geners/interface/StrippedType.hh"
0007 
0008 namespace gs {
0009   template <typename T>
0010   class IOIsHeapReadableHelper {
0011   private:
0012     template <T *(*)(const ClassId &, std::istream &)>
0013     struct tester;
0014     typedef char One;
0015     typedef struct {
0016       char a[2];
0017     } Two;
0018     template <typename C>
0019     static One test(tester<&C::read> *);
0020     template <typename C>
0021     static Two test(...);
0022 
0023   public:
0024     enum { value = sizeof(IOIsHeapReadableHelper<T>::template test<T>(nullptr)) == 1 };
0025   };
0026 
0027   template <typename T, bool is_class_type = IOIsClassType<T>::value>
0028   struct IOIsHeapReadable {
0029     enum { value = 0 };
0030   };
0031 
0032   template <typename T>
0033   struct IOIsHeapReadable<T, true> {
0034     enum { value = IOIsHeapReadableHelper<typename StrippedType<T>::type>::value };
0035   };
0036 
0037   template <typename T>
0038   class IOIsPlaceReadableHelper {
0039   private:
0040     template <void (*)(const ClassId &, std::istream &, T *)>
0041     struct tester;
0042     typedef char One;
0043     typedef struct {
0044       char a[2];
0045     } Two;
0046     template <typename C>
0047     static One test(tester<&C::restore> *);
0048     template <typename C>
0049     static Two test(...);
0050 
0051   public:
0052     enum { value = sizeof(IOIsPlaceReadableHelper<T>::template test<T>(0)) == 1 };
0053   };
0054 
0055   template <typename T, bool is_class_type = IOIsClassType<T>::value>
0056   struct IOIsPlaceReadable {
0057     enum { value = 0 };
0058   };
0059 
0060   template <typename T>
0061   struct IOIsPlaceReadable<T, true> {
0062     enum { value = IOIsPlaceReadableHelper<typename StrippedType<T>::type>::value };
0063   };
0064 }  // namespace gs
0065 
0066 #endif  // GENERS_IOISREADABLE_HH_