Red Hat Data Grid HotRod C++ Client  7.2.0
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  unsigned char interestFlag=0;
43 
44  void setInterestFlag(unsigned char flag) { interestFlag=flag; }
45  virtual void processEvent(ClientCacheEntryCreatedEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
46  virtual void processEvent(ClientCacheEntryModifiedEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
47  virtual void processEvent(ClientCacheEntryRemovedEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
48  virtual void processEvent(ClientCacheEntryExpiredEvent<std::vector<char> >, std::vector<char >listId, uint8_t isCustom) const = 0;
49  virtual void processEvent(ClientCacheEntryCustomEvent, std::vector<char >listId, uint8_t isCustom) const = 0;
50  virtual void processFailoverEvent() const
51  {
52  for (auto callable : failoverCallbacks) {
53  callable();
54  }
55  }
56  void add_listener(std::function<void()> callback) {
57  failoverCallbacks.push_back(callback);
58  }
59 
60  virtual ~ClientListener() {}
61 
62  const std::vector<char>& getListenerId() const {
63  return listenerId;
64  }
65 
66  void setListenerId(const std::vector<char>& listenerId) {
67  this->listenerId = listenerId;
68  }
69 
70 private:
71  std::list<std::function<void()> > failoverCallbacks;
72  std::vector<char> listenerId;
73 };
74 
75 }}}
76 
77 
78 #endif /* INCLUDE_INFINISPAN_HOTROD_CLIENTLISTENER_H_ */
void add_listener(std::function< void()> callback)
Definition: ClientListener.h:56
const std::vector< char > & getListenerId() const
Definition: ClientListener.h:62
std::vector< char > filterFactoryName
Definition: ClientListener.h:39
Definition: CacheClientListener.h:28
Definition: AuthenticationConfiguration.h:10
virtual ~ClientListener()
Definition: ClientListener.h:60
virtual void processFailoverEvent() const
Definition: ClientListener.h:50
Definition: ClientListener.h:35
Definition: AuthenticationConfiguration.h:11
void setListenerId(const std::vector< char > &listenerId)
Definition: ClientListener.h:66
std::vector< char > converterFactoryName
Definition: ClientListener.h:40
void setInterestFlag(unsigned char flag)
Definition: ClientListener.h:44