oculus1

view libovr/Src/OVR_DeviceHandle.h @ 18:1b107de821c1

fixed the test to work with non-pow2 textures
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Sep 2013 10:33:08 +0300
parents
children
line source
1 /************************************************************************************
3 PublicHeader: OVR.h
4 Filename : OVR_DeviceHandle.h
5 Content : Handle to a device that was enumerated
6 Created : February 5, 2013
7 Authors : Lee Cooper
9 Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
11 Use of this software is subject to the terms of the Oculus license
12 agreement provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
15 *************************************************************************************/
17 #ifndef OVR_DeviceHandle_h
18 #define OVR_DeviceHandle_h
20 #include "OVR_DeviceConstants.h"
22 namespace OVR {
24 class DeviceBase;
25 class DeviceInfo;
27 // Internal
28 class DeviceCreateDesc;
29 class DeviceEnumerationArgs;
32 //-------------------------------------------------------------------------------------
33 // ***** DeviceHandle
35 // DeviceHandle references a specific device that was enumerated; it can be assigned
36 // directly from DeviceEnumerator.
37 //
38 // Devices represented by DeviceHandle are not necessarily created or available.
39 // A device may become unavailable if, for example, it its unplugged. If the device
40 // is available, it can be created by calling CreateDevice.
41 //
43 class DeviceHandle
44 {
45 friend class DeviceManager;
46 friend class DeviceManagerImpl;
47 template<class B> friend class HIDDeviceImpl;
49 public:
50 DeviceHandle() : pImpl(0) { }
51 DeviceHandle(const DeviceHandle& src);
52 ~DeviceHandle();
54 void operator = (const DeviceHandle& src);
56 bool operator == (const DeviceHandle& other) const { return pImpl == other.pImpl; }
57 bool operator != (const DeviceHandle& other) const { return pImpl != other.pImpl; }
59 // operator bool() returns true if Handle/Enumerator points to a valid device.
60 operator bool () const { return GetType() != Device_None; }
62 // Returns existing device, or NULL if !IsCreated. The returned ptr is
63 // addref-ed.
64 DeviceBase* GetDevice_AddRef() const;
65 DeviceType GetType() const;
66 bool GetDeviceInfo(DeviceInfo* info) const;
67 bool IsAvailable() const;
68 bool IsCreated() const;
69 // Returns true, if the handle contains the same device ptr
70 // as specified in the parameter.
71 bool IsDevice(DeviceBase*) const;
73 // Creates a device, or returns AddRefed pointer if one is already created.
74 // New devices start out with RefCount of 1.
75 DeviceBase* CreateDevice();
77 // Creates a device, or returns AddRefed pointer if one is already created.
78 // New devices start out with RefCount of 1. DeviceT is used to cast the
79 // DeviceBase* to a concreete type.
80 template <class DeviceT>
81 DeviceT* CreateDeviceTyped() const
82 {
83 return static_cast<DeviceT*>(DeviceHandle(*this).CreateDevice());
84 }
86 // Resets the device handle to uninitialized state.
87 void Clear();
89 protected:
90 explicit DeviceHandle(DeviceCreateDesc* impl);
91 bool enumerateNext(const DeviceEnumerationArgs& args);
92 DeviceCreateDesc* pImpl;
93 };
95 } // namespace OVR
97 #endif