HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SYS_Handle.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_Handle.h (SYS Library, C++)
7  *
8  * COMMENTS: Platform independent handle for marshalling between Unix file
9  * descriptors (int) and Windows HANDLE objects (which are assumed
10  * to be void *).
11  */
12 
13 #ifndef __SYS_HANDLE_H_INCLUDED__
14 #define __SYS_HANDLE_H_INCLUDED__
15 
16 #include "SYS_API.h"
17 
18 
19 typedef void * SYS_WinHandle;
20 typedef int SYS_UnixHandle;
21 
22 // We assume that sizeof(SYS_WinHandle) > sizeof(UnixHandle) so we use that as
23 // the invalid value.
24 #define SYS_INVALID_HANDLE SYS_WinHandle(-1)
25 
26 
28 {
29 public:
31  : myWinHandle(SYS_INVALID_HANDLE)
32  {
33  }
34  explicit
36  : myWinHandle(SYS_INVALID_HANDLE)
37  {
38  myUnixHandle = h;
39  if (h < 0)
40  invalidate();
41  }
42  explicit
44  : myWinHandle(h)
45  {
46  }
47 
48  void invalidate()
49  { myWinHandle = SYS_INVALID_HANDLE; }
50  bool isValid() const
51  { return (myWinHandle != SYS_INVALID_HANDLE); }
52 
54  { return myUnixHandle; }
56  { myUnixHandle = h; }
57 
59  { return myWinHandle; }
61  { myWinHandle = h; }
62 
63 private:
64  SYS_WinHandle myWinHandle;
65  SYS_UnixHandle myUnixHandle;
66 };
67 
68 #endif // __SYS_HANDLE_H_INCLUDED__
SYS_Handle(SYS_WinHandle h)
Definition: SYS_Handle.h:43
SYS_Handle(SYS_UnixHandle h)
Definition: SYS_Handle.h:35
int SYS_UnixHandle
Definition: SYS_Handle.h:20
void invalidate()
Definition: SYS_Handle.h:48
void * SYS_WinHandle
Definition: SYS_Handle.h:19
void setWinHandle(SYS_WinHandle h)
Definition: SYS_Handle.h:60
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
SYS_WinHandle winHandle() const
Definition: SYS_Handle.h:58
void setUnixHandle(SYS_UnixHandle h)
Definition: SYS_Handle.h:55
bool isValid() const
Definition: SYS_Handle.h:50
#define SYS_API
Definition: SYS_API.h:11
SYS_UnixHandle unixHandle() const
Definition: SYS_Handle.h:53
#define SYS_INVALID_HANDLE
Definition: SYS_Handle.h:24