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 {
361  namespace connection {
362  class ConnectionManager;
363  }
364 
365  namespace serialization {
366  namespace pimpl {
367  class SerializationService;
368  }
369  }
370  namespace spi {
371  class ClientContext;
372 
373  class InvocationService;
374 
375  class ClusterService;
376 
377  class PartitionService;
378 
379  class LifecycleService;
380 
381  class ServerListenerService;
382 
383  }
384 
385  class ClientConfig;
386 
387  class IdGenerator;
388 
389  class IAtomicLong;
390 
391  class ICountDownLatch;
392 
393  class ISemaphore;
394 
395  class ILock;
396 
397  class TransactionContext;
398 
399  class TransactionOptions;
400 
401  class Cluster;
402 
410  class HAZELCAST_API HazelcastClient {
411  friend class spi::ClientContext;
412 
413  public:
419 
423  ~HazelcastClient();
424 
431  template<typename T>
432  T getDistributedObject(const std::string& name) {
433  T t(name, &(clientContext));
434  return t;
435  };
436 
445  template<typename K, typename V>
446  IMap<K, V> getMap(const std::string& name) {
447  return getDistributedObject<IMap<K, V> >(name);
448  };
449 
456  template<typename K, typename V>
457  MultiMap<K, V> getMultiMap(const std::string& name) {
458  return getDistributedObject<MultiMap<K, V> >(name);
459  };
460 
467  template<typename E>
468  IQueue<E> getQueue(const std::string& name) {
469  return getDistributedObject<IQueue<E> >(name);
470  };
471 
480  template<typename E>
481  ISet<E> getSet(const std::string& name) {
482  return getDistributedObject<ISet<E> >(name);
483  };
484 
492  template<typename E>
493  IList<E> getList(const std::string& name) {
494  return getDistributedObject<IList<E> >(name);
495  };
496 
503  template<typename E>
504  ITopic<E> getTopic(const std::string& name) {
505  return getDistributedObject<ITopic<E> >(name);
506  };
507 
516  IdGenerator getIdGenerator(const std::string& name);
517 
525  IAtomicLong getIAtomicLong(const std::string& name);
526 
535  ICountDownLatch getICountDownLatch(const std::string& name);
536 
561  ILock getILock(const std::string& name);
562 
570  ISemaphore getISemaphore(const std::string& name);
571 
576  ClientConfig& getClientConfig();
577 
583  TransactionContext newTransactionContext();
584 
591  TransactionContext newTransactionContext(const TransactionOptions& options);
592 
600  Cluster& getCluster();
601 
612  void addLifecycleListener(LifecycleListener *lifecycleListener);
613 
619  bool removeLifecycleListener(LifecycleListener *lifecycleListener);
620 
624  void shutdown();
625 
626  private:
627  ClientConfig clientConfig;
628  ClientProperties clientProperties;
629  spi::ClientContext clientContext;
630  spi::LifecycleService lifecycleService;
631  serialization::pimpl::SerializationService serializationService;
632  connection::ConnectionManager connectionManager;
633  spi::ClusterService clusterService;
634  spi::PartitionService partitionService;
635  spi::InvocationService invocationService;
636  spi::ServerListenerService serverListenerService;
637  Cluster cluster;
638 
639  HazelcastClient(const HazelcastClient& rhs);
640 
641  void operator=(const HazelcastClient& rhs);
642 
643  };
644 
645  }
646 }
647 
648 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
649 #pragma warning(pop)
650 #endif
651 
652 #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:504
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:468
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:457
IList< E > getList(const std::string &name)
Returns the distributed list instance with the specified name.
Definition: HazelcastClient.h:493
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:481
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:446
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:410
Provides a context to do transactional operations; so beginning/committing transactions, but also retrieving transactional data-structures like the TransactionalMap.
Definition: TransactionContext.h:52
T getDistributedObject(const std::string &name)
Definition: HazelcastClient.h:432