Pivotal GemFire Native Client Cache Reference  9.0.6
TypeHelper.hpp
1 #ifndef _GEMFIRE_TYPEHELPER_HPP_
2 #define _GEMFIRE_TYPEHELPER_HPP_
3 
4 /*=========================================================================
5  * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
6  * This product is protected by U.S. and international copyright
7  * and intellectual property laws. Pivotal products are covered by
8  * more patents listed at http://www.pivotal.io/patents.
9  *=========================================================================
10  */
11 
16 #include "gfcpp_globals.hpp"
17 
18 
19 namespace gemfire
20 {
21  // Forward declaration of SharedPtr<T>
22  template<typename Target> class SharedPtr;
23 
24  // Forward declaration of SharedArrayPtr<T, ID>
25  template<typename Target, int8_t TYPEID> class SharedArrayPtr;
26 
27  // Forward declaration of CacheableArrayType<T, ID>
28  template<typename Target, int8_t TYPEID> class CacheableArrayType;
29 
35  namespace TypeHelper
36  {
37  typedef uint8_t yes_type;
38  typedef uint32_t no_type;
39 
40  template <typename TBase, typename TDerived> struct BDHelper
41  {
42  template <typename T>
43  static yes_type check_sig( TDerived const volatile *, T );
44  static no_type check_sig( TBase const volatile *, int );
45  };
46 
54  template <typename TBase, typename TDerived> struct SuperSubclass
55  {
56  private:
57 
58  struct Host
59  {
60  operator TBase const volatile* ( ) const;
61  operator TDerived const volatile* ( );
62  };
63 
64 
65  public:
66 
67  static const bool result = sizeof( BDHelper<TBase, TDerived>::
68  check_sig( Host( ), 0 ) ) == sizeof( yes_type );
69  };
70 
75  template <typename TBase> struct SuperSubclass<TBase, TBase>
76  {
77  static const bool result = true;
78  };
79 
84  template <bool getType=true> struct YesNoType
85  {
86  static const yes_type value = 0;
87  };
88 
92  template <> struct YesNoType<false>
93  {
94  static const no_type value = 0;
95  };
96 
98  template <class T> struct UnwrapSharedPtr
99  {
100  };
101 
103  template <class T> struct UnwrapSharedPtr< SharedPtr<T> >
104  {
105  typedef T type;
106  };
107 
109  template <class T, int8_t ID> struct UnwrapSharedPtr< SharedArrayPtr<T, ID> >
110  {
112  };
113 
114  }
115 }
116 
118 #define GF_UNWRAP_SP( T ) typename gemfire::TypeHelper::UnwrapSharedPtr<T>::type
119 
124 #define GF_TYPE_IS_SERIALIZABLE( T ) \
125  gemfire::TypeHelper::SuperSubclass<gemfire::Serializable, T>::result
126 
132 #define GF_TYPE_IS_SERIALIZABLE_TYPE( T ) \
133  gemfire::TypeHelper::YesNoType<GF_TYPE_IS_SERIALIZABLE( T )>::value
134 
135 #define GF_SRC_IS_TARGET_TYPE( TARGET, SRC ) \
136  gemfire::TypeHelper::YesNoType< gemfire::TypeHelper::SuperSubclass< TARGET, SRC >::result >::value
137 
138 
139 #endif // _GEMFIRE_TYPEHELPER_HPP_
This struct unwraps the type T inside SharedPtr.
Definition: TypeHelper.hpp:98
Template class for CacheableArrayType SharedPtr&#39;s that adds [] operator.
Definition: CacheableBuiltins.hpp:154
This struct helps us determine whether or not a class is a subclass of another at compile time...
Definition: TypeHelper.hpp:54
Template class for array of primitive types.
Definition: CacheableBuiltins.hpp:191
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
This struct helps convert a boolean value into static objects of different types. ...
Definition: TypeHelper.hpp:84
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:35

GemFire C++ Cache API Documentation