CGenericDevice.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.2.0 $Rev: 1869 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CGenericDeviceH
46 #define CGenericDeviceH
47 //------------------------------------------------------------------------------
48 #include "math/CConstants.h"
49 //------------------------------------------------------------------------------
50 
51 //------------------------------------------------------------------------------
52 namespace chai3d {
53 //------------------------------------------------------------------------------
54 
55 //==============================================================================
62 //==============================================================================
63 
64 //------------------------------------------------------------------------------
65 const unsigned int C_MAX_DEVICES = 16;
66 //------------------------------------------------------------------------------
67 
68 //==============================================================================
82 //==============================================================================
84 {
85  //--------------------------------------------------------------------------
86  // CONSTRUCTOR & DESTRUCTOR:
87  //--------------------------------------------------------------------------
88 
89 public:
90 
92  cGenericDevice(unsigned int a_deviceNumber = 0);
93 
95  virtual ~cGenericDevice() {};
96 
97 
98  //--------------------------------------------------------------------------
99  // PUBLIC METHODS:
100  //--------------------------------------------------------------------------
101 
102 public:
103 
105  virtual bool open() { return (C_ERROR); }
106 
108  virtual bool close() { return (C_ERROR); }
109 
112 
114  bool isDeviceReady() { return (m_deviceReady); }
115 
116 
117  //--------------------------------------------------------------------------
118  // PUBLIC STATIC METHODS:
119  //--------------------------------------------------------------------------
120 
121 public:
122 
124  static unsigned int getNumDevices() { return (0); }
125 
126 
127  //--------------------------------------------------------------------------
128  // PROTECTED MEMBERS:
129  //--------------------------------------------------------------------------
130 
131 protected:
132 
135 
138 
141 
142 
143  //--------------------------------------------------------------------------
144  // PROTECTED STATIC METHODS - DEVICE LIBRARY INITIALIZATION:
145  //--------------------------------------------------------------------------
146 
147 protected:
148 
150  static bool openLibraries() { return (C_SUCCESS); }
151 
153  static bool closeLibraries() { return (C_SUCCESS); }
154 };
155 
156 //------------------------------------------------------------------------------
157 } // namespace chai3d
158 //------------------------------------------------------------------------------
159 
160 //------------------------------------------------------------------------------
161 #endif
162 //------------------------------------------------------------------------------
This class implements an abstract class for hardware devices.
Definition: CGenericDevice.h:83
int m_deviceNumber
Device number ID for this category of devices. Value must be equal or bigger than 0...
Definition: CGenericDevice.h:140
const unsigned int C_MAX_DEVICES
Definition: CGenericDevice.h:65
const bool C_SUCCESS
Function returns successfully.
Definition: CConstants.h:77
static bool closeLibraries()
This method closes libraries for this class of devices.
Definition: CGenericDevice.h:153
bool m_deviceAvailable
Flag that indicates if the device is available to the computer.
Definition: CGenericDevice.h:134
virtual bool open()
This method opens a connection to this device.
Definition: CGenericDevice.h:105
cGenericDevice(unsigned int a_deviceNumber=0)
Constructor of cGenericDevice.
Definition: CGenericDevice.cpp:57
Implements mathematical constants.
bool m_deviceReady
Flag that indicates if connection to device was opened successfully by calling method open()...
Definition: CGenericDevice.h:137
const bool C_ERROR
Function returns with an error.
Definition: CConstants.h:74
bool isDeviceReady()
This method returns true if the connection to the device has been established by calling method open(...
Definition: CGenericDevice.h:114
static unsigned int getNumDevices()
This method returns the number of haptic devices available for this class of devices.
Definition: CGenericDevice.h:124
virtual bool close()
This method closes the connection to this device.
Definition: CGenericDevice.h:108
Definition: CAudioBuffer.cpp:56
virtual ~cGenericDevice()
Destructor of cGenericDevice.
Definition: CGenericDevice.h:95
static bool openLibraries()
This method opens libraries for this class of devices.
Definition: CGenericDevice.h:150
bool isDeviceAvailable()
This method returns true if the device is available for communication, false otherwise.
Definition: CGenericDevice.h:111