GridGain C++ Client Library
grid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) GridGain Systems. All Rights Reserved.
3  * _________ _____ __________________ _____
4  * __ ____/___________(_)______ /__ ____/______ ____(_)_______
5  * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
6  * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
7  * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
8  */
9 
15 #ifndef _GRIDGAIN_GRID
16 #define _GRIDGAIN_GRID
17 
18 #include "gridgain/cache/cache.h"
19 #include "gridgain/impl/grid_impl.h"
21 
22 namespace gridgain
23 {
27  class IGNITE_IMPORT_EXPORT Grid
28  {
29  public:
33  Grid();
34 
38  Grid(impl::GridImpl* impl);
39 
45  const char* GetName() const;
46 
53  template<typename K, typename V>
54  cache::Cache<K, V> GetCache(const char* name)
55  {
56  GridError err;
57 
58  cache::Cache<K, V> res = GetCache<K, V>(name, &err);
59 
61 
62  return res;
63  }
64 
72  template<typename K, typename V>
73  cache::Cache<K, V> GetCache(const char* name, GridError* err)
74  {
75  impl::cache::CacheImpl* cacheImpl = impl.Get()->GetCache<K, V>(name, err);
76 
77  return cache::Cache<K, V>(cacheImpl);
78  }
79 
86  template<typename K, typename V>
88  {
89  GridError err;
90 
91  cache::Cache<K, V> res = GetOrCreateCache<K, V>(name, &err);
92 
94 
95  return res;
96  }
97 
105  template<typename K, typename V>
107  {
108  impl::cache::CacheImpl* cacheImpl = impl.Get()->GetOrCreateCache<K, V>(name, err);
109 
110  return cache::Cache<K, V>(cacheImpl);
111  }
112 
119  template<typename K, typename V>
120  cache::Cache<K, V> CreateCache(const char* name)
121  {
122  GridError err;
123 
124  cache::Cache<K, V> res = CreateCache<K, V>(name, &err);
125 
127 
128  return res;
129  }
130 
138  template<typename K, typename V>
139  cache::Cache<K, V> CreateCache(const char* name, GridError* err)
140  {
141  impl::cache::CacheImpl* cacheImpl = impl.Get()->CreateCache<K, V>(name, err);
142 
143  return cache::Cache<K, V>(cacheImpl);
144  }
145 
151  bool IsValid()
152  {
153  return impl.IsValid();
154  }
155 
156  private:
158  ignite::common::concurrent::SharedPointer<impl::GridImpl> impl;
159  };
160 }
161 
162 #endif
Main entry point for all Data Grid APIs.
Definition: cache.h:43
Main interface to operate with GridGain.
Definition: grid.h:27
cache::Cache< K, V > CreateCache(const char *name, GridError *err)
Create cache.
Definition: grid.h:139
cache::Cache< K, V > GetOrCreateCache(const char *name, GridError *err)
Get or create cache.
Definition: grid.h:106
Declares gridgain::cache::Cache class.
bool IsValid()
Check if the instance is valid.
Definition: grid.h:151
cache::Cache< K, V > GetCache(const char *name, GridError *err)
Get cache.
Definition: grid.h:73
cache::Cache< K, V > CreateCache(const char *name)
Create cache.
Definition: grid.h:120
static void ThrowIfNeeded(GridError &err)
Throw an error if code is not GG_SUCCESS.
Definition: grid_error.cpp:22
Declares gridgain::GridJvmOption class and gridgain::GridConfiguration structs.
cache::Cache< K, V > GetOrCreateCache(const char *name)
Get or create cache.
Definition: grid.h:87
GridGain API.
Definition: cache.h:35
Grid error information.
Definition: grid_error.h:70
cache::Cache< K, V > GetCache(const char *name)
Get cache.
Definition: grid.h:54