2007-07-16 17:30:04 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2009-01-02 18:16:05 +00:00
|
|
|
* InspIRCd: (C) 2002-2009 InspIRCd Development Team
|
2009-03-15 12:42:35 +00:00
|
|
|
* See: http://wiki.inspircd.org/Credits
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CULLLIST_H__
|
|
|
|
#define __CULLLIST_H__
|
|
|
|
|
2008-01-16 16:19:57 +00:00
|
|
|
/** The CullList class is used by the core to create lists of users
|
|
|
|
* prior to actually quitting (and deleting the objects) all at once.
|
2007-07-16 17:30:04 +00:00
|
|
|
* to quitting them all at once. This is faster than quitting
|
|
|
|
* them within the loop, as the loops become tighter with
|
|
|
|
* little or no comparisons within them. The CullList class
|
|
|
|
* operates by allowing the programmer to push users onto
|
|
|
|
* the list, each with a seperate quit reason, and then, once
|
|
|
|
* the list is complete, call a method to flush the list,
|
|
|
|
* quitting all the users upon it. A CullList may hold local
|
|
|
|
* or remote users, but it may only hold each user once. If
|
|
|
|
* you attempt to add the same user twice, then the second
|
|
|
|
* attempt will be ignored.
|
2008-01-16 16:19:57 +00:00
|
|
|
*
|
|
|
|
* NOTE: Don't use this outside core, use the QuitUser method like everyone else!
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
class CoreExport CullList : public classbase
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
/** Creator of this CullList
|
|
|
|
*/
|
|
|
|
InspIRCd* ServerInstance;
|
|
|
|
|
|
|
|
/** Holds a list of users being quit.
|
|
|
|
* See the information for CullItem for
|
|
|
|
* more information.
|
|
|
|
*/
|
2008-01-16 07:59:09 +00:00
|
|
|
std::vector<User *> list;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** Constructor.
|
|
|
|
* @param Instance Creator of this CullList object
|
|
|
|
*/
|
|
|
|
CullList(InspIRCd* Instance);
|
|
|
|
|
|
|
|
/** Adds a user to the cull list for later
|
|
|
|
* removal via QUIT.
|
|
|
|
* @param user The user to add
|
|
|
|
* @param reason The quit reason of the user being added
|
|
|
|
* @param o_reason The quit reason to show only to opers
|
|
|
|
*/
|
2008-01-16 07:59:09 +00:00
|
|
|
void AddItem(User* user);
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/* Turn an item into a silent item (don't send out QUIT for this user)
|
|
|
|
*/
|
2007-10-15 20:59:05 +00:00
|
|
|
void MakeSilent(User* user);
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/** Applies the cull list, quitting all the users
|
|
|
|
* on the list with their quit reasons all at once.
|
|
|
|
* This is a very fast operation compared to
|
|
|
|
* iterating the user list and comparing each one,
|
|
|
|
* especially if there are multiple comparisons
|
|
|
|
* to be done, or recursion.
|
|
|
|
*/
|
2009-04-17 21:47:30 +00:00
|
|
|
void Apply();
|
2007-07-16 17:30:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|