VMware GemFire Native C++ Reference  9.1
TypeHelper.hpp
1 #pragma once
2 
3 #ifndef GEODE_TYPEHELPER_H_
4 #define GEODE_TYPEHELPER_H_
5 
6 /*
7  * Licensed to the Apache Software Foundation (ASF) under one or more
8  * contributor license agreements. See the NOTICE file distributed with
9  * this work for additional information regarding copyright ownership.
10  * The ASF licenses this file to You under the Apache License, Version 2.0
11  * (the "License"); you may not use this file except in compliance with
12  * the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
27 #include "geode_globals.hpp"
28 
29 namespace apache {
30 namespace geode {
31 namespace client {
32 // Forward declaration of SharedPtr<T>
33 template <typename Target>
34 class SharedPtr;
35 
36 // Forward declaration of SharedArrayPtr<T, ID>
37 template <typename Target, int8_t TYPEID>
38 class SharedArrayPtr;
39 
40 // Forward declaration of CacheableArrayType<T, ID>
41 template <typename Target, int8_t TYPEID>
42 class CacheableArrayType;
43 
49 namespace TypeHelper {
50 typedef uint8_t yes_type;
51 typedef uint32_t no_type;
52 
53 template <typename TBase, typename TDerived>
54 struct BDHelper {
55  template <typename T>
56  static yes_type check_sig(TDerived const volatile*, T);
57  static no_type check_sig(TBase const volatile*, int);
58 };
59 
69 template <typename TBase, typename TDerived>
70 struct SuperSubclass {
71  private:
72  struct Host {
73  operator TBase const volatile*() const;
74  operator TDerived const volatile*();
75  };
76 
77  public:
78  static const bool result = sizeof(BDHelper<TBase, TDerived>::check_sig(
79  Host(), 0)) == sizeof(yes_type);
80 };
81 
86 template <typename TBase>
87 struct SuperSubclass<TBase, TBase> {
88  static const bool result = true;
89 };
90 
95 template <bool getType = true>
96 struct YesNoType {
97  static const yes_type value = 0;
98 };
99 
103 template <>
104 struct YesNoType<false> {
105  static const no_type value = 0;
106 };
107 
109 template <class T>
110 struct UnwrapSharedPtr {};
111 
113 template <class T>
115  typedef T type;
116 };
117 
119 template <class T, int8_t ID>
122 };
123 } // namespace TypeHelper
124 } // namespace client
125 } // namespace geode
126 } // namespace apache
127 
129 #define GF_UNWRAP_SP(T) \
130  typename apache::geode::client::TypeHelper::UnwrapSharedPtr<T>::type
131 
136 #define GF_TYPE_IS_SERIALIZABLE(T) \
137  apache::geode::client::TypeHelper::SuperSubclass< \
138  apache::geode::client::Serializable, T>::result
139 
145 #define GF_TYPE_IS_SERIALIZABLE_TYPE(T) \
146  apache::geode::client::TypeHelper::YesNoType<GF_TYPE_IS_SERIALIZABLE( \
147  T)>::value
148 
149 #define GF_SRC_IS_TARGET_TYPE(TARGET, SRC) \
150  apache::geode::client::TypeHelper::YesNoType< \
151  apache::geode::client::TypeHelper::SuperSubclass<TARGET, \
152  SRC>::result>::value
153 
154 #endif // GEODE_TYPEHELPER_H_
This struct helps us determine whether or not a class is a subclass of another at compile time...
Definition: TypeHelper.hpp:70
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
This struct helps convert a boolean value into static objects of different types. ...
Definition: TypeHelper.hpp:96
Template class for array of primitive types.
Definition: CacheableBuiltins.hpp:178
This struct unwraps the type T inside SharedPtr.
Definition: TypeHelper.hpp:110
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:52
Template class for CacheableArrayType SharedPtr&#39;s that adds [] operator.
Definition: CacheableBuiltins.hpp:144
This namespace contains all the Geode C++ API classes, enumerations and globals.

Pivotal GemFire C++ Cache API Documentation