Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
HazelcastClient.h
1 /*
2  * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef HAZELCAST_CLIENT
17 #define HAZELCAST_CLIENT
18 
19 #include "hazelcast/client/IMap.h"
20 #include "hazelcast/client/MultiMap.h"
21 #include "hazelcast/client/IQueue.h"
22 #include "hazelcast/client/ISet.h"
23 #include "hazelcast/client/IList.h"
24 #include "hazelcast/client/ITopic.h"
25 #include "hazelcast/client/TransactionOptions.h"
26 #include "hazelcast/client/TransactionContext.h"
27 #include "hazelcast/client/Cluster.h"
28 #include "hazelcast/client/ClientConfig.h"
29 #include "hazelcast/client/ClientProperties.h"
30 #include "hazelcast/client/spi/InvocationService.h"
31 #include "hazelcast/client/spi/PartitionService.h"
32 #include "hazelcast/client/spi/ServerListenerService.h"
33 #include "hazelcast/client/spi/LifecycleService.h"
34 #include "hazelcast/client/connection/ConnectionManager.h"
35 
36 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
37 #pragma warning(push)
38 #pragma warning(disable: 4251) //for dll export
39 #endif
40 
41 namespace hazelcast {
42  namespace client {
363  namespace connection {
364  class ConnectionManager;
365  }
366 
367  namespace serialization {
368  namespace pimpl {
369  class SerializationService;
370  }
371  }
372  namespace spi {
373  class ClientContext;
374 
375  class InvocationService;
376 
377  class ClusterService;
378 
379  class PartitionService;
380 
381  class LifecycleService;
382 
383  class ServerListenerService;
384 
385  }
386 
387  class ClientConfig;
388 
389  class IdGenerator;
390 
391  class IAtomicLong;
392 
393  class ICountDownLatch;
394 
395  class ISemaphore;
396 
397  class ILock;
398 
399  class TransactionContext;
400 
401  class TransactionOptions;
402 
403  class Cluster;
404 
412  class HAZELCAST_API HazelcastClient {
413  friend class spi::ClientContext;
414 
415  public:
421 
425  ~HazelcastClient();
426 
433  template<typename T>
434  T getDistributedObject(const std::string& name) {
435  T t(name, &(clientContext));
436  return t;
437  };
438 
447  template<typename K, typename V>
448  IMap<K, V> getMap(const std::string& name) {
449  return getDistributedObject<IMap<K, V> >(name);
450  };
451 
458  template<typename K, typename V>
459  MultiMap<K, V> getMultiMap(const std::string& name) {
460  return getDistributedObject<MultiMap<K, V> >(name);
461  };
462 
469  template<typename E>
470  IQueue<E> getQueue(const std::string& name) {
471  return getDistributedObject<IQueue<E> >(name);
472  };
473 
482  template<typename E>
483  ISet<E> getSet(const std::string& name) {
484  return getDistributedObject<ISet<E> >(name);
485  };
486 
494  template<typename E>
495  IList<E> getList(const std::string& name) {
496  return getDistributedObject<IList<E> >(name);
497  };
498 
505  template<typename E>
506  ITopic<E> getTopic(const std::string& name) {
507  return getDistributedObject<ITopic<E> >(name);
508  };
509 
518  IdGenerator getIdGenerator(const std::string& name);
519 
527  IAtomicLong getIAtomicLong(const std::string& name);
528 
537  ICountDownLatch getICountDownLatch(const std::string& name);
538 
563  ILock getILock(const std::string& name);
564 
572  ISemaphore getISemaphore(const std::string& name);
573 
578  ClientConfig& getClientConfig();
579 
585  TransactionContext newTransactionContext();
586 
593  TransactionContext newTransactionContext(const TransactionOptions& options);
594 
602  Cluster& getCluster();
603 
614  void addLifecycleListener(LifecycleListener *lifecycleListener);
615 
621  bool removeLifecycleListener(LifecycleListener *lifecycleListener);
622 
626  void shutdown();
627 
628  private:
629  ClientConfig clientConfig;
630  ClientProperties clientProperties;
631  spi::ClientContext clientContext;
632  spi::LifecycleService lifecycleService;
633  serialization::pimpl::SerializationService serializationService;
634  connection::ConnectionManager connectionManager;
635  spi::ClusterService clusterService;
636  spi::PartitionService partitionService;
637  spi::InvocationService invocationService;
638  spi::ServerListenerService serverListenerService;
639  Cluster cluster;
640 
641  HazelcastClient(const HazelcastClient& rhs);
642 
643  void operator=(const HazelcastClient& rhs);
644 
645  };
646 
647  }
648 }
649 
650 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
651 #pragma warning(pop)
652 #endif
653 
654 #endif /* HAZELCAST_CLIENT */
Contains the configuration for a Hazelcast transaction.
Definition: TransactionOptions.h:67
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:34
ITopic< E > getTopic(const std::string &name)
Returns the distributed topic instance with the specified name and entry type E.
Definition: HazelcastClient.h:506
Cluster-wide unique id generator.
Definition: IdGenerator.h:42
IQueue< E > getQueue(const std::string &name)
Returns the distributed queue instance with the specified name and entry type E.
Definition: HazelcastClient.h:470
IAtomicLong is a distributed atomic long implementation.
Definition: IAtomicLong.h:38
ICountDownLatch is a backed-up distributed alternative to the java.util.concurrent.CountDownLatch java.util.concurrent.CountDownLatch.
Definition: ICountDownLatch.h:62
MultiMap< K, V > getMultiMap(const std::string &name)
Returns the distributed multimap instance with the specified name.
Definition: HazelcastClient.h:459
IList< E > getList(const std::string &name)
Returns the distributed list instance with the specified name.
Definition: HazelcastClient.h:495
A specialized distributed map client whose keys can be associated with multiple values.
Definition: MultiMap.h:37
Re-entrant Lock, Distributed client implementation of Lock.
Definition: ILock.h:43
Client Properties is an internal class.
Definition: ClientProperties.h:71
Concurrent, distributed , client implementation of std::list.
Definition: IList.h:38
Concurrent, distributed client implementation of std::unordered_set.
Definition: ISet.h:32
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subs...
Definition: ITopic.h:45
Hazelcast cluster interface.
Definition: Cluster.h:40
ISet< E > getSet(const std::string &name)
Returns the distributed set instance with the specified name and entry type E.
Definition: HazelcastClient.h:483
Listener object for listening lifecycle events of hazelcast instance.
Definition: LifecycleListener.h:44
IMap< K, V > getMap(const std::string &name)
Returns the distributed map instance with the specified name.
Definition: HazelcastClient.h:448
Concurrent, distributed, observable and queryable map client.
Definition: IMap.h:52
ISemaphore is a backed-up distributed alternative to the java.util.concurrent.Semaphore.
Definition: ISemaphore.h:57
HazelcastClient configuration class.
Definition: ClientConfig.h:47
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:412
Provides a context to do transactional operations; so beginning/committing transactions, but also retrieving transactional data-structures like the TransactionalMap.
Definition: TransactionContext.h:57
T getDistributedObject(const std::string &name)
Definition: HazelcastClient.h:434