X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=include%2Fbase.h;h=86aa2769fc3112956b3666a24708637c1720e8dc;hb=cada37c7b51c0f1bee8117caa0123412b2e48081;hp=45c60802c7454f85c46d5af7aeead636710cac2d;hpb=46a39046196f55b52336e19662bb7bac85b731ac;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/base.h b/include/base.h index 45c60802c..86aa2769f 100644 --- a/include/base.h +++ b/include/base.h @@ -20,12 +20,12 @@ */ -#ifndef BASE_H -#define BASE_H +#pragma once #include #include #include +#include /** Dummy class to help enforce culls being parent-called up to classbase */ class CullResult @@ -121,7 +121,7 @@ class CoreExport usecountbase }; template -class CoreExport reference +class reference { T* value; public: @@ -142,7 +142,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; } @@ -150,7 +165,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 @@ -234,10 +249,11 @@ class CoreExport ServiceProvider : public classbase const std::string name; /** Type of service (must match object type) */ const ServiceType service; - ServiceProvider(Module* Creator, const std::string& Name, ServiceType Type) - : creator(Creator), name(Name), service(Type) {} + ServiceProvider(Module* Creator, const std::string& Name, ServiceType Type); virtual ~ServiceProvider(); -}; + /** If called, this ServiceProvider won't be registered automatically + */ + void DisableAutoRegister(); +}; -#endif