Brick
Toggle main menu visibility
Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1
/**
2
* @file device.h
3
* @brief Implements device port and connection logic used by VEX device subclasses.
4
*/
5
6
#pragma once
7
8
struct
_V5_Device;
9
10
namespace
crust
{
11
12
/**
13
* @brief Base class for devices connected to physical Smart Ports.
14
*
15
* Stores the physical port, expected device type, and C SDK handle.
16
* Derived classes use handle() to call C SDK functions.
17
*/
18
class
Device
{
19
public
:
20
/**
21
* @brief Gets the physical Smart Port number.
22
* @return Port number [1, 21], rather than the C SDK's [0, 20] index.
23
*/
24
int
port
()
const
{
return
port_; }
25
26
/**
27
* @brief Checks whether the expected device is currently connected.
28
* @return True if this port has a valid handle and reports the expected device type;
29
* false if disconnected, occupied by another device type, or no status is available.
30
*/
31
bool
installed
()
const
;
32
33
protected
:
34
/**
35
* @brief Resolves and caches the C SDK handle for a physical Smart Port.
36
* @param port Physical Smart Port number [1, 21].
37
* @param expected_type C SDK device type supplied by the base class.
38
*/
39
Device
(
int
port
,
int
expected_type);
40
41
/// Destroys the device.
42
~Device
() =
default
;
43
44
/// Provides the device handle associated with this port.
45
_V5_Device*
handle
()
const
{
return
device_; }
46
47
private
:
48
int
port_;
///< Physical Smart Port number [1, 21].
49
int
expected_type_;
///< C SDK Device Type Number.
50
_V5_Device* device_;
///< Device handle.
51
};
52
53
}
// namespace crust
crust::Device::handle
_V5_Device * handle() const
Provides the device handle associated with this port.
Definition
device.h:45
crust::Device::port
int port() const
Gets the physical Smart Port number.
Definition
device.h:24
crust::Device::~Device
~Device()=default
Destroys the device.
crust::Device::installed
bool installed() const
Checks whether the expected device is currently connected.
crust::Device::Device
Device(int port, int expected_type)
Resolves and caches the C SDK handle for a physical Smart Port.
crust
The namespace of the entire Crust package, which contains direct abstractions for VEX hardware.
crust
devices
device.h
Generated by
1.18.0