Anope IRC Services  Version 2.0
servers.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  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  */
12 
13 #ifndef SERVERS_H
14 #define SERVERS_H
15 
16 #include "services.h"
17 #include "anope.h"
18 #include "extensible.h"
19 
20 /* Anope. We are at the top of the server tree, our uplink is
21  * almost always me->GetLinks()[0]. We never have an uplink. */
22 extern CoreExport Server *Me;
23 
24 namespace Servers
25 {
26  /* Gets our uplink. Note we don't actually have an "uplink", this is just
27  * the only server whose uplink *is* Me that is not a juped server.
28  * @return Our uplink, or NULL if not uplinked to anything
29  */
30  extern CoreExport Server* GetUplink();
31 
32  /* Server maps by name and id */
35 
36  /* CAPAB/PROTOCTL given by the uplink */
37  extern CoreExport std::set<Anope::string> Capab;
38 }
39 
43 {
44  private:
45  /* Server name */
47  /* Hops between services and server */
48  unsigned int hops;
49  /* Server description */
51  /* Server ID */
53  /* Links for this server */
54  std::vector<Server *> links;
55  /* Uplink for this server */
57  /* Server is syncing */
58  bool syncing;
59  /* The server is juped */
60  bool juped;
61  /* The server is about to quit */
62  bool quitting;
63  /* Reason this server was quit */
65 
66  public:
75  Server(Server *uplink, const Anope::string &name, unsigned hops, const Anope::string &description, const Anope::string &sid = "", bool jupe = false);
76 
77  private:
80  ~Server();
81 
82  public:
83  /* Number of users on the server */
84  unsigned users;
85 
89  void Delete(const Anope::string &reason);
90 
94  const Anope::string &GetName() const;
95 
99  unsigned GetHops() const;
100 
104  void SetDescription(const Anope::string &desc);
105 
109  const Anope::string &GetDescription() const;
110 
114  void SetSID(const Anope::string &sid);
115 
119  const Anope::string &GetSID() const;
120 
123  const Anope::string &GetQuitReason() const;
124 
128  const std::vector<Server *> &GetLinks() const;
129 
133  Server *GetUplink();
134 
138  void AddLink(Server *s);
139 
143  void DelLink(Server *s);
144 
148  void Sync(bool sync_links);
149 
153  bool IsSynced() const;
154 
157  void Unsync();
158 
162  bool IsULined() const;
163 
167  bool IsJuped() const;
168 
172  bool IsQuitting() const;
173 
178  void Notice(BotInfo *source, const Anope::string &message);
179 
185  static Server *Find(const Anope::string &name, bool name_only = false);
186 };
187 
188 #endif // SERVERS_H
Definition: bots.h:24
Definition: servers.h:42
bool quitting
Definition: servers.h:62
CoreExport Anope::map< Server * > ByID
Definition: servers.cpp:27
Anope::string desc
Definition: access.cpp:23
CoreExport std::set< Anope::string > Capab
Definition: servers.cpp:29
Server * uplink
Definition: servers.h:56
Anope::string quit_reason
Definition: servers.h:64
unsigned int hops
Definition: servers.h:48
Anope::string description
Definition: servers.h:50
CoreExport Server * GetUplink()
Definition: servers.cpp:355
bool juped
Definition: servers.h:60
unsigned users
Definition: servers.h:84
CoreExport Anope::map< Server * > ByName
Definition: servers.cpp:26
std::vector< Server * > links
Definition: servers.h:54
Anope::string sid
Definition: servers.h:52
#define CoreExport
Definition: services.h:62
bool syncing
Definition: servers.h:58
CoreExport Server * Me
Definition: servers.cpp:24
Anope::string name
Definition: servers.h:46