]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/commands/cmd_whowas.h
m_namedmodes Inherit command handler from SplitCommand
[user/henk/code/inspircd.git] / include / commands / cmd_whowas.h
index f9b2322818ec1a3268b80b891fae40049a9aa8dc..aaea31864f38bc2ec53cb46811fb14406f5b47ea 100644 (file)
 
 #include "modules.h"
 
-/* Forward ref for typedefs */
-class WhoWasGroup;
-
 namespace WhoWas
 {
+       /** One entry for a nick. There may be multiple entries for a nick.
+        */
+       struct Entry
+       {
+               /** Real host
+                */
+               const std::string host;
+
+               /** Displayed host
+                */
+               const std::string dhost;
+
+               /** Ident
+                */
+               const std::string ident;
+
+               /** Server name
+                */
+               const std::string server;
+
+               /** Full name (GECOS)
+                */
+               const std::string gecos;
+
+               /** Signon time
+                */
+               const time_t signon;
+
+               /** Initialize this Entry with a user
+                */
+               Entry(User* user);
+       };
+
        /** Everything known about one nick
         */
-       struct Nick : public intrusive_list_node<Nick>
+       struct Nick : public insp::intrusive_list_node<Nick>
        {
                /** A group of users related by nickname
                 */
-               typedef std::deque<WhoWasGroup*> List;
+               typedef std::deque<Entry*> List;
 
                /** Container where each element has information about one occurrence of this nick
                 */
@@ -60,15 +90,22 @@ namespace WhoWas
        class Manager
        {
         public:
+               struct Stats
+               {
+                       /** Number of currently existing WhoWas::Entry objects
+                        */
+                       size_t entrycount;
+               };
+
                /** Add a user to the whowas database. Called when a user quits.
                 * @param user The user to add to the database
                 */
                void Add(User* user);
 
                /** Retrieves statistics about the whowas database
-                * @return Whowas statistics
+                * @return Whowas statistics as a WhoWas::Manager::Stats struct
                 */
-               std::string GetStats() const;
+               Stats GetStats() const;
 
                /** Expires old entries
                 */
@@ -105,7 +142,7 @@ namespace WhoWas
         private:
                /** Order in which the users were added into the map, used to remove oldest nick
                 */
-               typedef intrusive_list_tail<Nick> FIFO;
+               typedef insp::intrusive_list_tail<Nick> FIFO;
 
                /** Sets of users in the whowas system
                 */
@@ -135,6 +172,16 @@ namespace WhoWas
                /** Shrink all data structures to honor the current settings
                 */
                void Prune();
+
+               /** Remove a nick (and all entries belonging to it) from the database
+                * @param it Iterator to the nick to purge
+                */
+               void PurgeNick(whowas_users::iterator it);
+
+               /** Remove a nick (and all entries belonging to it) from the database
+                * @param nick Nick to purge
+                */
+               void PurgeNick(WhoWas::Nick* nick);
        };
 }
 
@@ -159,32 +206,3 @@ class CommandWhowas : public Command
         */
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
 };
-
-/** Used to hold WHOWAS information
- */
-class WhoWasGroup
-{
- public:
-       /** Real host
-        */
-       std::string host;
-       /** Displayed host
-        */
-       std::string dhost;
-       /** Ident
-        */
-       std::string ident;
-       /** Server name
-        */
-       std::string server;
-       /** Fullname (GECOS)
-        */
-       std::string gecos;
-       /** Signon time
-        */
-       time_t signon;
-
-       /** Initialize this WhoWasFroup with a user
-        */
-       WhoWasGroup(User* user);
-};