diff options
| author | Adam <Adam@anope.org> | 2012-09-15 10:11:31 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-09-30 20:30:27 -0400 |
| commit | 9ba719688161499f01c168b1aed84a563bcb5953 (patch) | |
| tree | b2ffbe3ceebf2a32820780fb76d30967af8ea50c /include | |
| parent | 1e71303ffaf263adb0cc659505caa223f7f27b85 (diff) | |
Make CommandSource use references, sometimes we hold them for awhile
Diffstat (limited to 'include')
| -rw-r--r-- | include/base.h | 7 | ||||
| -rw-r--r-- | include/commands.h | 21 | ||||
| -rw-r--r-- | include/logger.h | 2 |
3 files changed, 19 insertions, 11 deletions
diff --git a/include/base.h b/include/base.h index 9ea0dc630..c09b97400 100644 --- a/include/base.h +++ b/include/base.h @@ -88,6 +88,13 @@ class dynamic_reference : public dynamic_reference_base return NULL; } + inline T* operator*() + { + if (operator bool()) + return this->ref; + return NULL; + } + inline void operator=(T *newref) { if (operator bool()) diff --git a/include/commands.h b/include/commands.h index c3a412624..45b122247 100644 --- a/include/commands.h +++ b/include/commands.h @@ -44,18 +44,18 @@ class CoreExport CommandSource /* The nick executing the command */ Anope::string nick; /* User executing the command, may be NULL */ - User *u; + dynamic_reference<User> u; public: /* The account executing the command */ - NickCore *nc; + dynamic_reference<NickCore> nc; /* Where the reply should go */ CommandReply *reply; /* Channel the command was executed on (fantasy) */ - Channel *c; + dynamic_reference<Channel> c; /* The service this command is on */ - BotInfo *owner; + dynamic_reference<BotInfo> owner; /* The service the reply should come from, *not* necessarily the service the command is on */ - BotInfo *service; + dynamic_reference<BotInfo> service; /* The actual name of the command being executed */ Anope::string command; /* The permission of the command being executed */ @@ -64,17 +64,18 @@ class CoreExport CommandSource CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *reply); const Anope::string &GetNick() const; - User *GetUser() const; - AccessGroup AccessFor(ChannelInfo *ci) const; - bool IsFounder(ChannelInfo *ci) const; + User *GetUser(); + NickCore *GetAccount(); + AccessGroup AccessFor(ChannelInfo *ci); + bool IsFounder(ChannelInfo *ci); void Reply(const char *message, ...); void Reply(const Anope::string &message); bool HasCommand(const Anope::string &cmd); bool HasPriv(const Anope::string &cmd); - bool IsServicesOper() const; - bool IsOper() const; + bool IsServicesOper(); + bool IsOper(); }; /** Every services command is a class, inheriting from Command. diff --git a/include/logger.h b/include/logger.h index eea86f890..9b3658e94 100644 --- a/include/logger.h +++ b/include/logger.h @@ -65,7 +65,7 @@ class CoreExport Log Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ - Log(LogType type, const CommandSource &source, Command *c, const ChannelInfo *ci = NULL); + Log(LogType type, CommandSource &source, Command *c, const ChannelInfo *ci = NULL); /* LOG_CHANNEL */ Log(const User *u, Channel *c, const Anope::string &category = ""); |
