OVR_DeviceHandle.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 PublicHeader:   OVR.h
00004 Filename    :   OVR_DeviceHandle.h
00005 Content     :   Handle to a device that was enumerated
00006 Created     :   February 5, 2013
00007 Authors     :   Lee Cooper
00008 
00009 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00010 
00011 Use of this software is subject to the terms of the Oculus license
00012 agreement provided at the time of installation or download, or which
00013 otherwise accompanies this software in either electronic or hard copy form.
00014 
00015 *************************************************************************************/
00016 
00017 #ifndef OVR_DeviceHandle_h
00018 #define OVR_DeviceHandle_h
00019 
00020 #include "OVR_DeviceConstants.h"
00021 
00022 namespace OVR {
00023 
00024 class DeviceBase;
00025 class DeviceInfo;
00026 
00027 // Internal
00028 class DeviceCreateDesc;
00029 class DeviceEnumerationArgs;
00030 
00031 
00032 //-------------------------------------------------------------------------------------
00033 // ***** DeviceHandle
00034 
00035 // DeviceHandle references a specific device that was enumerated; it can be assigned
00036 // directly from DeviceEnumerator.
00037 //
00038 // Devices represented by DeviceHandle are not necessarily created or available.
00039 // A device may become unavailable if, for example, it its unplugged. If the device
00040 // is available, it can be created by calling CreateDevice.
00041 //
00042 
00043 class DeviceHandle
00044 {    
00045         friend class DeviceManager;
00046         friend class DeviceManagerImpl;
00047     template<class B> friend class HIDDeviceImpl;
00048 
00049 public:
00050         DeviceHandle() : pImpl(0) { }    
00051         DeviceHandle(const DeviceHandle& src);
00052         ~DeviceHandle();
00053 
00054         void operator = (const DeviceHandle& src);
00055 
00056         bool operator == (const DeviceHandle& other) const { return pImpl == other.pImpl; }
00057         bool operator != (const DeviceHandle& other) const { return pImpl != other.pImpl; }
00058 
00059         // operator bool() returns true if Handle/Enumerator points to a valid device.
00060         operator bool () const   { return GetType() != Device_None; }
00061 
00062     // Returns existing device, or NULL if !IsCreated. The returned ptr is 
00063     // addref-ed.
00064     DeviceBase* GetDevice_AddRef() const;
00065         DeviceType  GetType() const;
00066         bool        GetDeviceInfo(DeviceInfo* info) const;
00067         bool        IsAvailable() const;
00068         bool        IsCreated() const;
00069     // Returns true, if the handle contains the same device ptr
00070     // as specified in the parameter.
00071     bool        IsDevice(DeviceBase*) const;
00072 
00073         // Creates a device, or returns AddRefed pointer if one is already created.
00074         // New devices start out with RefCount of 1.
00075         DeviceBase* CreateDevice();
00076 
00077     // Creates a device, or returns AddRefed pointer if one is already created.
00078     // New devices start out with RefCount of 1. DeviceT is used to cast the
00079     // DeviceBase* to a concreete type.
00080     template <class DeviceT>
00081     DeviceT* CreateDeviceTyped() const
00082     {
00083         return static_cast<DeviceT*>(DeviceHandle(*this).CreateDevice());
00084     }
00085 
00086         // Resets the device handle to uninitialized state.
00087         void        Clear();
00088 
00089 protected:
00090         explicit DeviceHandle(DeviceCreateDesc* impl);
00091         bool     enumerateNext(const DeviceEnumerationArgs& args);
00092         DeviceCreateDesc* pImpl;
00093 };
00094 
00095 } // namespace OVR
00096 
00097 #endif


oculus_sdk
Author(s): Tully Foote
autogenerated on Thu Jun 6 2019 20:13:48