From be10eab6ce68d4f06cc7b14bc2fca35e005ce6b5 Mon Sep 17 00:00:00 2001 From: danieldg Date: Mon, 19 Oct 2009 20:12:22 +0000 Subject: Maintain refcount of Module objects to complain about leaked pointers git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11925 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/base.h | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'include/base.h') diff --git a/include/base.h b/include/base.h index 13efdd2dd..0de37e781 100644 --- a/include/base.h +++ b/include/base.h @@ -179,21 +179,30 @@ class CoreExport CoreException : public std::exception } }; +class Module; + class CoreExport ModuleException : public CoreException { public: - /** Default constructor, just uses the error mesage 'Module threw an exception'. - */ - ModuleException() : CoreException("Module threw an exception", "A Module") {} - /** This constructor can be used to specify an error message before throwing. */ - ModuleException(const std::string &message) : CoreException(message, "A Module") {} - /** This destructor solves world hunger, cancels the world debt, and causes the world to end. - * Actually no, it does nothing. Never mind. - * @throws Nothing! - */ - virtual ~ModuleException() throw() {}; + ModuleException(const std::string &message, Module* me = NULL); +}; + +class CoreExport ModuleRef : public reference_base +{ + Module* const value; + public: + ModuleRef(Module* v); + ~ModuleRef(); + inline operator Module*() const { return value; } + inline Module* operator->() const { return value; } + inline Module& operator*() const { return *value; } + private: + ModuleRef(const ModuleRef&); + void operator=(const ModuleRef&); + void* operator new(size_t); + void operator delete(void*); }; #endif -- cgit v1.3.1-10-gc9f91