Anope IRC Services  Version 2.0
redis.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  */
9 
10 namespace Redis
11 {
12  struct Reply
13  {
14  enum Type
15  {
18  OK,
19  INT,
22  }
23  type;
24 
25  Reply() { Clear(); }
26  ~Reply() { Clear(); }
27 
28  void Clear()
29  {
30  type = NOT_PARSED;
31  i = 0;
32  bulk.clear();
33  multi_bulk_size = 0;
34  for (unsigned j = 0; j < multi_bulk.size(); ++j)
35  delete multi_bulk[j];
36  multi_bulk.clear();
37  }
38 
39  int64_t i;
42  std::deque<Reply *> multi_bulk;
43  };
44 
45  class Interface
46  {
47  public:
49 
50  Interface(Module *m) : owner(m) { }
51  virtual ~Interface() { }
52 
53  virtual void OnResult(const Reply &r) = 0;
54  virtual void OnError(const Anope::string &error) { Log(owner) << error; }
55  };
56 
57  class Provider : public Service
58  {
59  public:
60  Provider(Module *c, const Anope::string &n) : Service(c, "Redis::Provider", n) { }
61 
62  virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) = 0;
63  virtual void SendCommand(Interface *i, const Anope::string &str) = 0;
64 
65  virtual bool BlockAndProcess() = 0;
66 
67  virtual void Subscribe(Interface *i, const Anope::string &pattern) = 0;
68  virtual void Unsubscribe(const Anope::string &pattern) = 0;
69 
70  virtual void StartTransaction() = 0;
71  virtual void CommitTransaction() = 0;
72  };
73 }
74 
virtual void Unsubscribe(const Anope::string &pattern)=0
virtual void OnError(const Anope::string &error)
Definition: redis.h:54
void clear()
Definition: anope.h:187
~Reply()
Definition: redis.h:26
enum Redis::Reply::Type type
void Clear()
Definition: redis.h:28
std::deque< Reply * > multi_bulk
Definition: redis.h:42
virtual void OnResult(const Reply &r)=0
Definition: redis.h:10
int multi_bulk_size
Definition: redis.h:41
Provider(Module *c, const Anope::string &n)
Definition: redis.h:60
virtual void CommitTransaction()=0
int64_t i
Definition: redis.h:39
virtual ~Interface()
Definition: redis.h:51
virtual void SendCommand(Interface *i, const std::vector< Anope::string > &cmds)=0
Module * owner
Definition: redis.h:48
Interface(Module *m)
Definition: redis.h:50
Definition: logger.h:53
virtual void Subscribe(Interface *i, const Anope::string &pattern)=0
virtual void StartTransaction()=0
virtual bool BlockAndProcess()=0
Anope::string bulk
Definition: redis.h:40