aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-03-02 05:39:12 +0000
committerGravatar Sadie Powell2021-03-02 05:56:56 +0000
commit4e488cb54d72fb4a1caa580f6756a6f4687beaf6 (patch)
treeae74c5dc12685a23ede19a299753aed30c336960 /include
parentMove aligned_storage to the utility directory and clean up. (diff)
Refactor classbase/CullResult into Cullable/Cullable::Result.
Diffstat (limited to 'include')
-rw-r--r--include/base.h27
-rw-r--r--include/cull.h (renamed from include/cull_list.h)30
-rw-r--r--include/dynamic.h2
-rw-r--r--include/extensible.h4
-rw-r--r--include/inspircd.h4
-rw-r--r--include/inspsocket.h2
-rw-r--r--include/iohook.h2
-rw-r--r--include/logger.h2
-rw-r--r--include/mode.h4
-rw-r--r--include/modules.h4
-rw-r--r--include/modules/sql.h8
-rw-r--r--include/server.h2
-rw-r--r--include/socketengine.h2
-rw-r--r--include/stdalgo.h2
-rw-r--r--include/users.h8
-rw-r--r--include/xline.h2
16 files changed, 53 insertions, 52 deletions
diff --git a/include/base.h b/include/base.h
index 83693dc3f..7e541d6b3 100644
--- a/include/base.h
+++ b/include/base.h
@@ -34,30 +34,7 @@
#include <list>
#include "utility/uncopiable.h"
-
-/** Dummy class to help enforce culls being parent-called up to classbase */
-class CullResult
-{
- CullResult() = default;
- friend class classbase;
-};
-
-/** The base class for all inspircd classes with a well-defined lifetime.
- * Classes that inherit from this may be destroyed through GlobalCulls,
- * and may rely on cull() being called prior to their deletion.
- */
-class CoreExport classbase
- : private insp::uncopiable
-{
- public:
- classbase();
-
- /**
- * Called just prior to destruction via cull list.
- */
- virtual CullResult cull();
- virtual ~classbase();
-};
+#include "cull.h"
/** The base class for inspircd classes that provide a wrapping interface, and
* should only exist while being used. Prevents heap allocation.
@@ -239,7 +216,7 @@ enum ServiceType {
};
/** A structure defining something that a module can provide */
-class CoreExport ServiceProvider : public classbase
+class CoreExport ServiceProvider : public Cullable
{
public:
/** Module that is providing this service */
diff --git a/include/cull_list.h b/include/cull.h
index d29b7b267..7660f2109 100644
--- a/include/cull_list.h
+++ b/include/cull.h
@@ -24,6 +24,30 @@
#pragma once
+/* Allows deleting instances of an inheriting type at the end of the current main loop iteration. */
+class CoreExport Cullable
+ : private insp::uncopiable
+{
+ protected:
+ /** Default constructor for the Cullable class. */
+ Cullable();
+
+ public:
+ /** Dummy class to help ensure all superclasses get culled. */
+ class Result final
+ {
+ public:
+ /** Default constructor for the Cullable::Result class. */
+ Result() = default;
+ };
+
+ /** Destroys this instance of the Cullable class. */
+ virtual ~Cullable();
+
+ /** Called just before the instance is deleted to allow culling members. */
+ virtual Result Cull();
+};
+
/**
* The CullList class is used to delete objects at the end of the main loop to
* avoid problems with references to deleted pointers if an object were deleted
@@ -31,13 +55,13 @@
*/
class CoreExport CullList
{
- std::vector<classbase*> list;
+ std::vector<Cullable*> list;
std::vector<LocalUser*> SQlist;
public:
/** Adds an item to the cull list
*/
- void AddItem(classbase* item) { list.push_back(item); }
+ void AddItem(Cullable* item) { list.push_back(item); }
void AddSQItem(LocalUser* item) { SQlist.push_back(item); }
/** Applies the cull list (deletes the contents)
@@ -46,7 +70,7 @@ class CoreExport CullList
};
/** Represents an action which is executable by an action list */
-class CoreExport ActionBase : public classbase
+class CoreExport ActionBase : public Cullable
{
public:
/** Executes this action. */
diff --git a/include/dynamic.h b/include/dynamic.h
index bf19ff6b2..2e1665667 100644
--- a/include/dynamic.h
+++ b/include/dynamic.h
@@ -38,7 +38,7 @@
/** The DLLManager class is able to load a module file by filename,
* and locate its init_module symbol.
*/
-class CoreExport DLLManager : public classbase
+class CoreExport DLLManager : public Cullable
{
private:
/** The last error string. */
diff --git a/include/extensible.h b/include/extensible.h
index 94f3e7c28..50ffad3c3 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -125,7 +125,7 @@ class CoreExport ExtensionItem
* supports arbitrary data storage).
*/
class CoreExport Extensible
- : public classbase
+ : public Cullable
, public Serializable
{
public:
@@ -150,7 +150,7 @@ class CoreExport Extensible
inline const ExtensibleStore& GetExtList() const { return extensions; }
Extensible();
- CullResult cull() override;
+ Cullable::Result Cull() override;
virtual ~Extensible();
void UnhookExtensions(const std::vector<reference<ExtensionItem>>& toRemove);
diff --git a/include/inspircd.h b/include/inspircd.h
index 2b6fdd98c..12ca681b8 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -72,7 +72,7 @@ CoreExport extern InspIRCd* ServerInstance;
#include "config.h"
#include "dynref.h"
#include "consolecolors.h"
-#include "cull_list.h"
+#include "cull.h"
#include "serialize.h"
#include "extensible.h"
#include "fileutils.h"
@@ -565,7 +565,7 @@ class CoreExport InspIRCd
ENTRYPOINT;
-inline void stdalgo::cull_delete::operator()(classbase* item)
+inline void stdalgo::cull_delete::operator()(Cullable* item)
{
if (item)
ServerInstance->GlobalCulls.AddItem(item);
diff --git a/include/inspsocket.h b/include/inspsocket.h
index d5cdb9b57..d5a139888 100644
--- a/include/inspsocket.h
+++ b/include/inspsocket.h
@@ -353,7 +353,7 @@ class CoreExport StreamSocket : public EventHandler
void Close(bool writeblock);
/** This ensures that close is called prior to destructor */
- CullResult cull() override;
+ Cullable::Result Cull() override;
/** Get the IOHook of a module attached to this socket
* @param mod Module whose IOHook to return
diff --git a/include/iohook.h b/include/iohook.h
index b35d68dbf..986a5ba1f 100644
--- a/include/iohook.h
+++ b/include/iohook.h
@@ -64,7 +64,7 @@ class IOHookProvider : public refcountbase, public ServiceProvider
virtual void OnConnect(StreamSocket* sock) = 0;
};
-class IOHook : public classbase
+class IOHook : public Cullable
{
public:
/** The IOHookProvider for this hook, contains information about the hook,
diff --git a/include/logger.h b/include/logger.h
index 520f94040..17b694c43 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -93,7 +93,7 @@ class CoreExport FileWriter
/** LogStream base class. Modules (and other stuff) inherit from this to decide what logging they are interested in, and what to do with it.
*/
-class CoreExport LogStream : public classbase
+class CoreExport LogStream : public Cullable
{
protected:
LogLevel loglvl;
diff --git a/include/mode.h b/include/mode.h
index df789c5a7..694ece305 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -174,7 +174,7 @@ class CoreExport ModeHandler : public ServiceProvider
* @param mclass The object type of this mode handler, one of ModeHandler::Class
*/
ModeHandler(Module* me, const std::string& name, char modeletter, ParamSpec params, ModeType type, Class mclass = MC_OTHER);
- CullResult cull() override;
+ Cullable::Result Cull() override;
virtual ~ModeHandler() = default;
/** Register this object in the ModeParser
@@ -498,7 +498,7 @@ class CoreExport SimpleChannelModeHandler : public ModeHandler
* and attach it to the mode using Server::AddModeWatcher and Server::DelModeWatcher.
* A ModeWatcher will be called both before and after the mode change.
*/
-class CoreExport ModeWatcher : public classbase
+class CoreExport ModeWatcher : public Cullable
{
private:
/**
diff --git a/include/modules.h b/include/modules.h
index 290aa9ee6..5177c1585 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -283,7 +283,7 @@ enum Implementation
* its methods will be called when irc server events occur. class inherited from module must be
* instantiated by the ModuleFactory class (see relevant section) for the module to be initialised.
*/
-class CoreExport Module : public classbase, public usecountbase
+class CoreExport Module : public Cullable, public usecountbase
{
protected:
/** Initializes a new instance of the Module class.
@@ -328,7 +328,7 @@ class CoreExport Module : public classbase, public usecountbase
/** Clean up prior to destruction
* If you override, you must call this AFTER your module's cleanup
*/
- CullResult cull() override;
+ Cullable::Result Cull() override;
/** Default destructor.
* destroys a module class
diff --git a/include/modules/sql.h b/include/modules/sql.h
index ae84e8171..985b273dd 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -101,7 +101,7 @@ class SQL::Field
};
/** Represents the result of an SQL query. */
-class SQL::Result : public classbase
+class SQL::Result : public Cullable
{
public:
/**
@@ -198,7 +198,7 @@ class SQL::Error
* You should store whatever information is needed to have the callbacks work in
* this object (UID of user, channel name, etc).
*/
-class SQL::Query : public classbase
+class SQL::Query : public Cullable
{
protected:
/** Creates a new SQL query. */
@@ -216,12 +216,12 @@ class SQL::Query : public classbase
/** Called when an SQL error happens.
* @param error The error that occurred.
*/
- virtual void OnError(Error& error) = 0;
+ virtual void OnError(SQL::Error& error) = 0;
/** Called when a SQL result is received.
* @param result The result of the SQL query.
*/
- virtual void OnResult(Result& result) = 0;
+ virtual void OnResult(SQL::Result& result) = 0;
};
/**
diff --git a/include/server.h b/include/server.h
index cf9637765..5e28ff9b9 100644
--- a/include/server.h
+++ b/include/server.h
@@ -21,7 +21,7 @@
#pragma once
-class CoreExport Server : public classbase
+class CoreExport Server : public Cullable
{
protected:
/** The unique identifier for this server. */
diff --git a/include/socketengine.h b/include/socketengine.h
index bb04dfc64..2073f2724 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -154,7 +154,7 @@ enum EventMask
* must have a file descriptor. What this file descriptor
* is actually attached to is completely up to you.
*/
-class CoreExport EventHandler : public classbase
+class CoreExport EventHandler : public Cullable
{
private:
/** Private state maintained by socket engine */
diff --git a/include/stdalgo.h b/include/stdalgo.h
index cf267798b..6b0d27390 100644
--- a/include/stdalgo.h
+++ b/include/stdalgo.h
@@ -157,7 +157,7 @@ namespace stdalgo
*/
struct cull_delete
{
- void operator()(classbase* item);
+ void operator()(Cullable* item);
};
/**
diff --git a/include/users.h b/include/users.h
index cf4d9d395..97cae5bce 100644
--- a/include/users.h
+++ b/include/users.h
@@ -306,7 +306,7 @@ class CoreExport User : public Extensible
time_t age;
/** Time the connection was created, set in the constructor. This
- * may be different from the time the user's classbase object was
+ * may be different from the time the user's Cullable object was
* created.
*/
time_t signon = 0;
@@ -619,7 +619,7 @@ class CoreExport User : public Extensible
/** Default destructor
*/
virtual ~User() = default;
- CullResult cull() override;
+ Cullable::Result Cull() override;
/** @copydoc Serializable::Deserialize */
bool Deserialize(Data& data) override;
@@ -685,7 +685,7 @@ class CoreExport LocalUser : public User, public insp::intrusive_list_node<Local
LocalUser(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
LocalUser(int fd, const std::string& uuid, Serializable::Data& data);
- CullResult cull() override;
+ Cullable::Result Cull() override;
UserIOHandler eh;
@@ -859,7 +859,7 @@ class CoreExport FakeUser : public User
nick = sname;
}
- CullResult cull() override;
+ Cullable::Result Cull() override;
const std::string& GetFullHost() override;
const std::string& GetFullRealHost() override;
};
diff --git a/include/xline.h b/include/xline.h
index 781bb70ff..80f4f0857 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -33,7 +33,7 @@
* to a known line type is done by means of an XLineFactory object (see
* below).
*/
-class CoreExport XLine : public classbase
+class CoreExport XLine : public Cullable
{
protected: