summaryrefslogtreecommitdiff
path: root/src/misc/autoptr.hpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-23 22:16:41 +0000
committerrubidium <rubidium@openttd.org>2008-04-23 22:16:41 +0000
commitdce1b331965c660a80996230503149b28221f34c (patch)
tree3c648d4bd6e453e588d664c0eabe3c948a556f7c /src/misc/autoptr.hpp
parent10ab24a5f149955f3af71ba152609a4be676b795 (diff)
downloadopenttd-dce1b331965c660a80996230503149b28221f34c.tar.xz
(svn r12857) -Fix [FS#1948]: remove the last uses of AutoPtr in the station code.
Diffstat (limited to 'src/misc/autoptr.hpp')
-rw-r--r--src/misc/autoptr.hpp106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/misc/autoptr.hpp b/src/misc/autoptr.hpp
deleted file mode 100644
index 8b0d920f5..000000000
--- a/src/misc/autoptr.hpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* $Id$ */
-
-/** @file autoptr.hpp */
-
-#ifndef AUTOPTR_HPP
-#define AUTOPTR_HPP
-
-/** AutoPtrT - kind of smart pointer that ensures the owned object gets
- * deleted when its pointer goes out of scope.
- * It is non-invasive smart pointer (no reference counter).
- * When copied, the copy takes ownership of underlying object
- * and original becomes NULL!
- * Can be used also for polymorphic data types (interfaces).
- */
-template <class T>
-class AutoPtrT {
-public:
- typedef T obj_t;
-
-protected:
- mutable T* m_p; ///< points to the data
-
-public:
- FORCEINLINE AutoPtrT()
- : m_p(NULL)
- {};
-
- FORCEINLINE AutoPtrT(const AutoPtrT<T>& src)
- : m_p(src.m_p)
- {
- if (m_p != NULL) src.m_p = NULL;
- };
-
- FORCEINLINE AutoPtrT(T *p)
- : m_p(p)
- {}
-
- FORCEINLINE ~AutoPtrT()
- {
- if (m_p != NULL) {
- T *p = m_p;
- m_p = NULL;
- delete p;
- }
- }
-
- /** give-up ownership and NULLify the raw pointer */
- FORCEINLINE T* Detach()
- {
- T* p = m_p;
- m_p = NULL;
- return p;
- }
-
- /** raw-pointer cast operator (read only) */
- FORCEINLINE operator const T* () const
- {
- return m_p;
- }
-
- /** raw-pointer cast operator */
- FORCEINLINE operator T* ()
- {
- return m_p;
- }
-
- /** dereference operator (read only) */
- FORCEINLINE const T* operator -> () const
- {
- assert(m_p != NULL);
- return m_p;
- }
-
- /** dereference operator (read / write) */
- FORCEINLINE T* operator -> ()
- {
- assert(m_p != NULL);
- return m_p;
- }
-
- /** assignment operator */
- FORCEINLINE AutoPtrT& operator = (const AutoPtrT& src)
- {
- /* Save original pointer and replace it with the given one to avoid recursive calls. */
- T* p = m_p;
- m_p = src.m_p;
-
- if (m_p != NULL) src.m_p = NULL;
-
- if (p != NULL) {
- /* Now we can safely delete the old one. */
- delete p;
- }
- return *this;
- }
-
- /** forwarding 'lower than' operator to the underlaying items */
- FORCEINLINE bool operator < (const AutoPtrT& other) const
- {
- assert(m_p != NULL);
- assert(other.m_p != NULL);
- return (*m_p) < (*other.m_p);
- }
-};
-
-#endif /* AUTOPTR_HPP */