00001 #ifndef ISPN_HOTROD_REMOTECACHEMANAGER_H
00002 #define ISPN_HOTROD_REMOTECACHEMANAGER_H
00003
00004 #include "infinispan/hotrod/BasicMarshaller.h"
00005 #include "infinispan/hotrod/ImportExport.h"
00006 #include "infinispan/hotrod/Handle.h"
00007 #include "infinispan/hotrod/RemoteCache.h"
00008 #include "infinispan/hotrod/Configuration.h"
00009
00010 #include <string>
00011 #include <map>
00012
00013 namespace infinispan {
00014 namespace hotrod {
00015
00016 class RemoteCacheManagerImpl;
00017
00038 class HR_EXTERN RemoteCacheManager : public Handle<RemoteCacheManagerImpl>
00039 {
00040 public:
00041
00049 explicit RemoteCacheManager(bool start = true);
00050
00051 explicit RemoteCacheManager(
00052 const std::map<std::string, std::string>& configuration,
00053 bool start = true);
00054
00064 explicit RemoteCacheManager(
00065 const Configuration& configuration,
00066 bool start = true);
00067
00072 void start();
00073
00078 void stop();
00079
00087 bool isStarted();
00088
00096 const Configuration& getConfiguration();
00097
00112 template <class K, class V> RemoteCache<K, V> getCache(
00113 bool forceReturnValue = false)
00114 {
00115 RemoteCache<K, V> rcache;
00116 initCache(rcache, forceReturnValue);
00117 rcache.keyMarshaller.reset(new BasicMarshaller<K>());
00118 rcache.valueMarshaller.reset(new BasicMarshaller<V>());
00119 return rcache;
00120 }
00121
00137 template <class K, class V> RemoteCache<K, V> getCache(
00138 const std::string& name, bool forceReturnValue = false)
00139 {
00140 RemoteCache<K, V> rcache;
00141 initCache(rcache, name, forceReturnValue);
00142 rcache.keyMarshaller.reset(new BasicMarshaller<K>());
00143 rcache.valueMarshaller.reset(new BasicMarshaller<V>());
00144 return rcache;
00145 }
00146
00164 template <class K, class V> RemoteCache<K, V> getCache(
00165 HR_SHARED_PTR<Marshaller<K> > km, HR_SHARED_PTR<Marshaller<V> > vm,
00166 bool forceReturnValue = false)
00167 {
00168 RemoteCache<K, V> rcache;
00169 initCache(rcache, forceReturnValue);
00170 rcache.keyMarshaller = km;
00171 rcache.valueMarshaller = vm;
00172 return rcache;
00173 }
00174
00193 template <class K, class V> RemoteCache<K, V> getCache(
00194 HR_SHARED_PTR<Marshaller<K> > km, HR_SHARED_PTR<Marshaller<V> > vm,
00195 const std::string& name, bool forceReturnValue = false)
00196 {
00197 RemoteCache<K, V> rcache;
00198 initCache(rcache, name, forceReturnValue);
00199 rcache.keyMarshaller = km;
00200 rcache.valueMarshaller = vm;
00201 return rcache;
00202 }
00203
00204 private:
00205 void initCache(RemoteCacheBase& cache, bool forceReturnValue);
00206 void initCache(RemoteCacheBase& cache, const std::string& name, bool forceReturnValue);
00207
00208
00209 RemoteCacheManager(const RemoteCacheManager&);
00210 RemoteCacheManager operator=(const RemoteCacheManager&);
00211 };
00212
00213 }}
00214
00215 #endif