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 {
401  namespace connection {
402  class ConnectionManager;
403  }
404 
405  namespace serialization {
406  namespace pimpl {
407  class SerializationService;
408  }
409  }
410  namespace spi {
411  class ClientContext;
412 
413  class InvocationService;
414 
415  class ClusterService;
416 
417  class PartitionService;
418 
419  class LifecycleService;
420 
421  class ServerListenerService;
422 
423  }
424 
425  class ClientConfig;
426 
427  class IdGenerator;
428 
429  class IAtomicLong;
430 
431  class ICountDownLatch;
432 
433  class ISemaphore;
434 
435  class ILock;
436 
437  class TransactionContext;
438 
439  class TransactionOptions;
440 
441  class Cluster;
442 
450  class HAZELCAST_API HazelcastClient {
451  friend class spi::ClientContext;
452 
453  public:
460 
464  ~HazelcastClient();
465 
472  template<typename T>
473  T getDistributedObject(const std::string& name) {
474  T t(name, &(clientContext));
475  return t;
476  };
477 
488  template<typename K, typename V>
489  IMap<K, V> getMap(const std::string& name) {
490  return getDistributedObject<IMap<K, V> >(name);
491  };
492 
499  template<typename K, typename V>
500  MultiMap<K, V> getMultiMap(const std::string& name) {
501  return getDistributedObject<MultiMap<K, V> >(name);
502  };
503 
510  template<typename E>
511  IQueue<E> getQueue(const std::string& name) {
512  return getDistributedObject<IQueue<E> >(name);
513  };
514 
523  template<typename E>
524  ISet<E> getSet(const std::string& name) {
525  return getDistributedObject<ISet<E> >(name);
526  };
527 
535  template<typename E>
536  IList<E> getList(const std::string& name) {
537  return getDistributedObject<IList<E> >(name);
538  };
539 
546  template<typename E>
547  ITopic<E> getTopic(const std::string& name) {
548  return getDistributedObject<ITopic<E> >(name);
549  };
550 
559  IdGenerator getIdGenerator(const std::string& name);
560 
568  IAtomicLong getIAtomicLong(const std::string& name);
569 
578  ICountDownLatch getICountDownLatch(const std::string& name);
579 
604  ILock getILock(const std::string& name);
605 
613  ISemaphore getISemaphore(const std::string& name);
614 
619  ClientConfig& getClientConfig();
620 
626  TransactionContext newTransactionContext();
627 
634  TransactionContext newTransactionContext(const TransactionOptions& options);
635 
643  Cluster& getCluster();
644 
655  void addLifecycleListener(LifecycleListener *lifecycleListener);
656 
662  bool removeLifecycleListener(LifecycleListener *lifecycleListener);
663 
667  void shutdown();
668 
669  private:
670  ClientConfig clientConfig;
671  ClientProperties clientProperties;
672  spi::ClientContext clientContext;
673  spi::LifecycleService lifecycleService;
674  serialization::pimpl::SerializationService serializationService;
675  connection::ConnectionManager connectionManager;
676  spi::ClusterService clusterService;
677  spi::PartitionService partitionService;
678  spi::InvocationService invocationService;
679  spi::ServerListenerService serverListenerService;
680  Cluster cluster;
681 
682  HazelcastClient(const HazelcastClient& rhs);
683 
684  void operator=(const HazelcastClient& rhs);
685 
686  };
687 
688  }
689 }
690 
691 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
692 #pragma warning(pop)
693 #endif
694 
695 #endif /* HAZELCAST_CLIENT */
Contains the configuration for a Hazelcast transaction.
Definition: TransactionOptions.h:67
Concurrent, blocking, distributed, observable, client queue.
Definition: IQueue.h:38
ITopic< E > getTopic(const std::string &name)
Returns the distributed topic instance with the specified name and entry type E.
Definition: HazelcastClient.h:547
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:511
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:500
IList< E > getList(const std::string &name)
Returns the distributed list instance with the specified name.
Definition: HazelcastClient.h:536
A specialized distributed map client whose keys can be associated with multiple values.
Definition: MultiMap.h:41
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:42
Concurrent, distributed client implementation of std::unordered_set.
Definition: ISet.h:36
Hazelcast provides distribution mechanism for publishing messages that are delivered to multiple subs...
Definition: ITopic.h:41
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:524
Listener object for listening lifecycle events of hazelcast instance.
Definition: LifecycleListener.h:44
IMap< K, V > getMap(const std::string &name)
Definition: HazelcastClient.h:489
Concurrent, distributed, observable and queryable map client.
Definition: IMap.h:58
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:450
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:473