diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-19 20:12:22 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-19 20:12:22 +0000 |
commit | be10eab6ce68d4f06cc7b14bc2fca35e005ce6b5 (patch) | |
tree | c22583006f80a8cb86bb15489c196832476cd28a /include/base.h | |
parent | aa7cc18468f4b16bf79cd1788cad0cbf0d926817 (diff) |
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
Diffstat (limited to 'include/base.h')
-rw-r--r-- | include/base.h | 29 |
1 files changed, 19 insertions, 10 deletions
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 |