Pivotal GemFire Native Client Cache Reference  9.0.6
SharedPtrHelper.hpp
1 #ifndef _GEMFIRE_SPEHELPER_HPP_
2 #define _GEMFIRE_SPEHELPER_HPP_
3 
4 /*=========================================================================
5  * Copyright (c) 2004-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 
12 #include "gfcpp_globals.hpp"
13 #include "TypeHelper.hpp"
14 #include <typeinfo>
15 
16 namespace gemfire {
17 
18  class SharedBase;
19 
23 {
24  public:
25 
26  static void throwNullPointerException( const char* ename );
27 
28  static void throwClassCastException( const char* msg,
29  const char* fromType, const char* toType );
30 };
31 
32 /* Helper function template for type conversion.
33  */
34 template< class Target, class Src > Target* getTargetHelper( Src* ptr, gemfire::TypeHelper::yes_type yes )
35 {
36  return ptr;
37 }
38 
39 /* Helper function template for type conversion.
40  */
41 template< class Target, class Src > Target* getTargetHelper( Src* ptr, gemfire::TypeHelper::no_type no )
42 {
43  Target* tptr = dynamic_cast< Target* >( ptr );
44  if ( tptr ) {
45  return tptr;
46  }
47  else {
48  SPEHelper::throwClassCastException( "getTargetHelper: cast failed",
49  typeid( ptr ).name( ), typeid( tptr ).name( ) );
50  return NULL;
51  }
52 }
53 
54 /* Helper function template for type conversion.
55  */
56 template< class Target, class Src > Target* getTarget( Src* ptr )
57 {
58  return getTargetHelper< Target >( ptr, GF_SRC_IS_TARGET_TYPE( Target, Src ) );
59 }
60 
61 /* Helper function template for type conversion.
62  */
63 template< class Src > SharedBase* getSB( Src* ptr )
64 {
65  return getTarget< SharedBase >( ptr );
66 }
67 }
68 
69 #endif
70 
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
Helper class for SharedPtr exceptions.
Definition: SharedPtrHelper.hpp:22
#define CPPCACHE_EXPORT
Defines a GemFire CPPCACHE export.
Definition: gf_base.hpp:51
This abstract base class is the base class of all user objects that have the shared capability of ref...
Definition: SharedBase.hpp:31

GemFire C++ Cache API Documentation