X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fbase.h;h=19222a6f5d2ac4ac592ae84797c7044c31d7a1a1;hb=756c89cfccb4039bf5b4b59662a0bd7c379287a3;hp=3f70f0195663fb0028c9ee65cea69b10e95d3ea7;hpb=df5f76832ee67d1cbfb1fc47a8d3ec3823f010c5;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/base.h b/include/base.h index 3f70f0195..19222a6f5 100644 --- a/include/base.h +++ b/include/base.h @@ -1,22 +1,32 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2006-2007 Oliver Lupton + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2003-2005, 2007 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #ifndef BASE_H #define BASE_H #include #include #include +#include /** Dummy class to help enforce culls being parent-called up to classbase */ class CullResult @@ -112,7 +122,7 @@ class CoreExport usecountbase }; template -class CoreExport reference +class reference { T* value; public: @@ -133,7 +143,22 @@ class CoreExport reference if (value && value->refcount_dec()) delete value; } - inline operator bool() const { return value; } + + inline reference& operator=(T* other) + { + if (value != other) + { + if (value && value->refcount_dec()) + delete value; + value = other; + if (value) + value->refcount_inc(); + } + + return *this; + } + + inline operator bool() const { return (value != NULL); } inline operator T*() const { return value; } inline T* operator->() const { return value; } inline T& operator*() const { return *value; } @@ -141,7 +166,7 @@ class CoreExport reference inline bool operator>(const reference& other) const { return value > other.value; } static inline void* operator new(size_t, void* m) { return m; } private: -#ifndef WIN32 +#ifndef _WIN32 static void* operator new(size_t); static void operator delete(void*); #endif @@ -176,7 +201,7 @@ class CoreExport CoreException : public std::exception * Actually no, it does nothing. Never mind. * @throws Nothing! */ - virtual ~CoreException() throw() {}; + virtual ~CoreException() throw() {} /** Returns the reason for the exception. * The module should probably put something informative here as the user will see this upon failure. */