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:
420 
424  ~HazelcastClient();
425 
432  template<typename T>
433  T getDistributedObject(const std::string& name) {
434  T t(name, &(clientContext));
435  return t;
436  };
437 
446  template<typename K, typename V>
447  IMap<K, V> getMap(const std::string& name) {
448  return getDistributedObject<IMap<K, V> >(name);
449  };
450 
457  template<typename K, typename V>
458  MultiMap<K, V> getMultiMap(const std::string& name) {
459  return getDistributedObject<MultiMap<K, V> >(name);
460  };
461 
468  template<typename E>
469  IQueue<E> getQueue(const std::string& name) {
470  return getDistributedObject<IQueue<E> >(name);
471  };
472 
481  template<typename E>
482  ISet<E> getSet(const std::string& name) {
483  return getDistributedObject<ISet<E> >(name);
484  };
485 
493  template<typename E>
494  IList<E> getList(const std::string& name) {
495  return getDistributedObject<IList<E> >(name);
496  };
497 
504  template<typename E>
505  ITopic<E> getTopic(const std::string& name) {
506  return getDistributedObject<ITopic<E> >(name);
507  };
508 
517  IdGenerator getIdGenerator(const std::string& name);
518 
526  IAtomicLong getIAtomicLong(const std::string& name);
527 
536  ICountDownLatch getICountDownLatch(const std::string& name);
537 
562  ILock getILock(const std::string& name);
563 
571  ISemaphore getISemaphore(const std::string& name);
572 
577  ClientConfig& getClientConfig();
578 
584  TransactionContext newTransactionContext();
585 
592  TransactionContext newTransactionContext(const TransactionOptions& options);
593 
601  Cluster& getCluster();
602 
613  void addLifecycleListener(LifecycleListener *lifecycleListener);
614 
620  bool removeLifecycleListener(LifecycleListener *lifecycleListener);
621 
625  void shutdown();
626 
627  private:
628  ClientConfig clientConfig;
629  ClientProperties clientProperties;
630  spi::ClientContext clientContext;
631  spi::LifecycleService lifecycleService;
632  serialization::pimpl::SerializationService serializationService;
633  connection::ConnectionManager connectionManager;
634  spi::ClusterService clusterService;
635  spi::PartitionService partitionService;
636  spi::InvocationService invocationService;
637  spi::ServerListenerService serverListenerService;
638  Cluster cluster;
639 
640  HazelcastClient(const HazelcastClient& rhs);
641 
642  void operator=(const HazelcastClient& rhs);
643 
644  };
645 
646  }
647 }
648 
649 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
650 #pragma warning(pop)
651 #endif
652 
653 #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:505
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:469
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:458
IList< E > getList(const std::string &name)
Returns the distributed list instance with the specified name.
Definition: HazelcastClient.h:494
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:482
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:447
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:433