]> git.tdb.fi Git - libs/core.git/blob - source/io/handle.cpp
Add a pimpl Handle class
[libs/core.git] / source / io / handle.cpp
1 #include "handle.h"
2 #include "handle_private.h"
3
4 namespace Msp {
5 namespace IO {
6
7 Handle::Handle():
8         priv(new Private)
9 { }
10
11 Handle::Handle(const Handle &other):
12         priv(new Private)
13 {
14         priv->handle = other.priv->handle;
15 }
16
17 Handle &Handle::operator=(const Handle &other)
18 {
19         priv->handle = other.priv->handle;
20         return *this;
21 }
22
23 Handle::~Handle()
24 {
25         delete priv;
26 }
27
28 Handle::operator const void *() const
29 {
30 #ifdef WIN32
31         return priv->handle!=INVALID_HANDLE_VALUE ? this : 0;
32 #else
33         return priv->handle!=-1 ? this : 0;
34 #endif
35 }
36
37
38 Handle::Private::Private():
39 #ifdef WIN32
40         handle(INVALID_HANDLE_VALUE)
41 #else
42         handle(-1)
43 #endif
44 { }
45
46 Handle::Private &Handle::Private::operator=(H h)
47 {
48         handle = h;
49         return *this;
50 }
51
52 } // namespace IO
53 } // namespace Msp