From: mental Date: Thu, 15 May 2008 17:01:23 +0000 (+0000) Subject: add DumbPtr X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a7d289ce1a4a04af3521ba9720856c0a5282fddc;p=inkscape.git add DumbPtr --- diff --git a/src/lifecycle.h b/src/lifecycle.h index 7e37bd852..e86697c74 100644 --- a/src/lifecycle.h +++ b/src/lifecycle.h @@ -89,6 +89,30 @@ private: } }; +// Wrapper for a simple pointer emulating the ManagedPtr interface +template +class DumbPtr { +public: + DumbPtr() : ptr(NULL) {} + DumbPtr(T *p) : ptr(p) {} + DumbPtr(DumbPtr const &other) : ptr(other.ptr) {} + + operator T *() const { return ptr; } + T &operator*() const { return *ptr; } + T *operator->() const { return ptr; } + DumbPtr &operator=(T *p) { + ptr = p; + return *this; + } + DumbPtr &operator=(DumbPtr const &other) { + ptr = other.ptr; + return *this; + } + +private: + T *ptr; +}; + // Dummy implementation of AbstractManaged to ease migration class DummyManaged : public virtual AbstractManaged { protected: