/export/rook2/users/build/gfcppsancout64/product/include/gfcpp/FunctionService.hpp

Go to the documentation of this file.
00001 #ifndef __GEMFIRE_FUNCTION_SERVICE_H__
00002 #define __GEMFIRE_FUNCTION_SERVICE_H__
00003 
00004 /*=========================================================================
00005   * (c) Copyright 2002-2010, GemStone Systems, Inc. All Rights Reserved.
00006   * 1260 NW Waterhouse Ave., Suite 200,  Beaverton, OR 97006
00007   *
00008   * The specification of function behaviors is found in the corresponding
00009   * .cpp file.
00010   *
00011   *========================================================================
00012   */
00013 
00014 #include "gfcpp_globals.hpp"
00015 #include "gf_types.hpp"
00016 #include "Execution.hpp"
00017 
00022 // macros to resolve ambiguity between PoolPtr and RegionServicePtr
00023 #define GF_TYPE_IS_POOL(T) \
00024   gemfire::TypeHelper::SuperSubclass<gemfire::Pool, T>::result
00025 #define GF_TYPE_IS_POOL_TYPE(T) \
00026   gemfire::TypeHelper::YesNoType<GF_TYPE_IS_POOL(T)>::value
00027 
00028 namespace gemfire {
00035   class CPPCACHE_EXPORT FunctionService : public SharedBase
00036 {
00037   public:
00056   static ExecutionPtr onRegion(RegionPtr region);
00057 
00071   inline static ExecutionPtr onServer(const PoolPtr& pool)
00072   {
00073     return onServerWithPool(pool);
00074   }
00075 
00090   inline static ExecutionPtr onServer(const RegionServicePtr& cache)
00091   {
00092     return onServerWithCache(cache);
00093   }
00094 
00095   template <typename T>
00096   static ExecutionPtr onServer(const SharedPtr<T>& poolOrCache)
00097   {
00098     return onServer(poolOrCache, GF_TYPE_IS_POOL_TYPE(T));
00099   }
00100   
00114   inline static ExecutionPtr onServers(const PoolPtr& pool)
00115   {
00116     return onServersWithPool(pool);
00117   }
00118 
00133   inline static ExecutionPtr onServers(const RegionServicePtr& cache)
00134   {
00135     return onServersWithCache(cache);
00136   }
00137 
00138   template <typename T>
00139   static ExecutionPtr onServers(const SharedPtr<T>& poolOrCache)
00140   {
00141     return onServers(poolOrCache, GF_TYPE_IS_POOL_TYPE(T));
00142   }
00143 
00144   virtual ~FunctionService()
00145   {
00146   }
00147 
00148 private:
00149 
00150   static ExecutionPtr onServerWithPool(const PoolPtr& pool);
00151 
00152   static ExecutionPtr onServerWithCache(const RegionServicePtr& cache);
00153 
00154   static ExecutionPtr onServersWithPool(const PoolPtr& pool);
00155 
00156   static ExecutionPtr onServersWithCache(const RegionServicePtr& cache);
00157 
00158   template <typename T>
00159   static ExecutionPtr onServer(const SharedPtr<T>& pool,
00160       TypeHelper::yes_type isPool)
00161   {
00162     return onServerWithPool(pool);
00163   }
00164 
00165   template <typename T>
00166   static ExecutionPtr onServer(const SharedPtr<T>& cache,
00167       TypeHelper::no_type isPool)
00168   {
00169     return onServerWithCache(cache);
00170   }
00171 
00172   template <typename T>
00173   static ExecutionPtr onServers(const SharedPtr<T>& pool,
00174       TypeHelper::yes_type isPool)
00175   {
00176     return onServersWithPool(pool);
00177   }
00178 
00179   template <typename T>
00180   static ExecutionPtr onServers(const SharedPtr<T>& cache,
00181       TypeHelper::no_type isPool)
00182   {
00183     return onServersWithCache(cache);
00184   }
00185 };
00186 
00187 } //namespace gemfire
00188 
00189 #endif //__GEMFIRE_FUNCTION_SERVICE_H__

GemFire C++ Cache API Documentation