InfinispanHotRodC++Client  8.2.0.Alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ClientListener.h
Go to the documentation of this file.
1 /*
2  * ClientListener.h
3  *
4  * Created on: Aug 3, 2016
5  * Author: rigazilla
6  */
7 
8 #ifndef INCLUDE_INFINISPAN_HOTROD_CLIENTLISTENER_H_
9 #define INCLUDE_INFINISPAN_HOTROD_CLIENTLISTENER_H_
10 
13 #include <vector>
14 #include <list>
15 #include <functional>
16 
17 using namespace infinispan::hotrod;
18 
19 namespace infinispan {
20 namespace hotrod {
21 
22 namespace transport {
23 class Transport;
24 }
25 
26 namespace protocol {
27 class Codec20;
28 }
29 class RemoteCacheBase;
30 template <class K, class V>
31 class RemoteCache;
32 
33 namespace event {
34 
36 {
37 public:
38  bool includeCurrentState = false;
39  std::vector<char> filterFactoryName;
40  std::vector<char> converterFactoryName;
41  bool useRawData = false ;
42  virtual void processEvent(ClientCacheEntryCreatedEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
43  virtual void processEvent(ClientCacheEntryModifiedEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
44  virtual void processEvent(ClientCacheEntryRemovedEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
45  virtual void processEvent(ClientCacheEntryExpiredEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
46  virtual void processEvent(ClientCacheEntryCustomEvent, std::vector<char >listId, uint8_t isCustom) const = 0;
47  virtual void processFailoverEvent() const
48  {
49  for (auto callable : failoverCallbacks) {
50  callable();
51  }
52  }
53  void add_listener(std::function<void()> callback) {
54  failoverCallbacks.push_back(callback);
55  }
56 
57  virtual ~ClientListener() {}
58 
59  const std::vector<char>& getListenerId() const {
60  return listenerId;
61  }
62 
63  void setListenerId(const std::vector<char>& listenerId) {
64  this->listenerId = listenerId;
65  }
66 
67 private:
68  std::list<std::function<void()> > failoverCallbacks;
69  std::vector<char> listenerId;
70 };
71 
72 }}}
73 
74 
75 #endif /* INCLUDE_INFINISPAN_HOTROD_CLIENTLISTENER_H_ */
void add_listener(std::function< void()> callback)
Definition: ClientListener.h:53
const std::vector< char > & getListenerId() const
Definition: ClientListener.h:59
std::vector< char > filterFactoryName
Definition: ClientListener.h:39
Definition: CacheClientListener.h:28
virtual ~ClientListener()
Definition: ClientListener.h:57
virtual void processFailoverEvent() const
Definition: ClientListener.h:47
Definition: ClientListener.h:35
void setListenerId(const std::vector< char > &listenerId)
Definition: ClientListener.h:63
std::vector< char > converterFactoryName
Definition: ClientListener.h:40
Definition: RemoteCacheBase.h:36