summaryrefslogtreecommitdiff
path: root/includes/Handle.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-26 11:47:38 -0700
committerPixel <pixel@nobis-crew.org>2011-10-26 15:05:29 -0700
commite5804f2cb929083713c0082f39182a858c082587 (patch)
tree7e2e97ace60235b753925197a01ed7d7aa9c16c9 /includes/Handle.h
parent8b1e278ef364fff2aa7d6b805353a722db1b4b89 (diff)
Protecting the IO class a bit more, and adding the raw filename paradigm for at least the Input class.
Diffstat (limited to 'includes/Handle.h')
-rw-r--r--includes/Handle.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/includes/Handle.h b/includes/Handle.h
index 96f1736..321d8db 100644
--- a/includes/Handle.h
+++ b/includes/Handle.h
@@ -63,7 +63,7 @@ class IOBase {
IOBase() : m_h(NULL) { }
~IOBase() { if (m_h) m_h->delRef(); }
protected:
- void setHandle(Handle * h) { m_h = h; m_h->addRef(); }
+ void setHandle(Handle * h) { m_h = h; if (m_h) m_h->addRef(); }
Handle * m_h;
template<class T>
friend class IO;
@@ -74,11 +74,12 @@ class IO : public IOBase {
public:
IO() { }
IO(T * h) { setHandle(h); }
- IO(const IO<T> & io) { setHandle(io.m_h); }
+ IO(const IO<T> & io) { if (io.m_h) setHandle(io.m_h); }
template<class U>
- IO(const IO<U> & io) { setHandle(io.m_h); }
+ IO(const IO<U> & io) { if (io.m_h) setHandle(io.m_h); }
IO<T> & operator=(const IO<T> & io) { if (m_h) m_h->delRef(); setHandle(io.m_h); return *this; }
T * operator->() { Assert(m_h); return dynamic_cast<T *>(m_h); }
+ bool isNull() { return dynamic_cast<T *>(m_h); }
};
class SeekableHandle : public Handle {