DUDS
Distributed Update of Data from Something
duds::hardware::interface::DigitalPinAccess Class Reference

Provides access to a single pin on a DigitalPort. More...

#include <DigitalPinAccess.hpp>

Inheritance diagram for duds::hardware::interface::DigitalPinAccess:
Collaboration diagram for duds::hardware::interface::DigitalPinAccess:

Public Member Functions

 DigitalPinAccess ()
 Constructs an access object with nothing to access. More...
 
 ~DigitalPinAccess ()
 Relinquish access on destruction. More...
 
bool canBeInput () const
 Returns true if the pin can operate as an input. More...
 
bool canBeOutput () const
 Returns true if the pin can operate as an output. More...
 
bool canFloat () const
 Returns true if the pin can provide a non-input high impedence state (or maybe allow input state?). More...
 
DigitalPinCap capabilities () const
 Returns the capabilities of the accessed pin. More...
 
DigitalPinConfig configuration () const
 Returns the current configuration of the accessed pin. More...
 
unsigned int globalId () const
 Returns the global pin ID of the accessed pin. More...
 
bool havePin () const
 Returns true if this object has been given a pin to access. More...
 
bool input () const
 Samples the input state of the pin. More...
 
bool isInput () const
 Returns true if the pin is configured as an input. More...
 
bool isOutput () const
 Returns true if the pin is configured as an output. More...
 
unsigned int localId () const
 Returns the local pin ID of the accessed pin. More...
 
DigitalPinConfig modifyConfig (const DigitalPinConfig &conf) const
 Modifies the configuration of the pin. More...
 
DigitalPinAccessoperator= (DigitalPinAccess &&old)
 A move assignment. More...
 
void output (bool state) const
 Changes the output state of the pin. More...
 
DigitalPinRejectedConfiguration::Reason proposeConfig (DigitalPinConfig &conf) const
 Propose a new configuration for the accessed pin using the current configuration as the initial configuration. More...
 
DigitalPinRejectedConfiguration::Reason proposeConfig (DigitalPinConfig &proposed, DigitalPinConfig &initial) const
 Propose a new configuration for the accessed pin using a hypothetical given initial configuration. More...
 
void retire () noexcept
 Relinquish access. More...
 
- Public Member Functions inherited from duds::hardware::interface::DigitalPinAccessBase
DigitalPortport () const
 Returns a pointer to the port that controls the pin(s) that are operated through this object. More...
 

Private Member Functions

 DigitalPinAccess (DigitalPort *port, unsigned int globalPinId)
 Used by DigitalPort. More...
 

Private Attributes

friend DigitalPort
 
unsigned int gid
 Global pin ID. More...
 

Additional Inherited Members

- Protected Member Functions inherited from duds::hardware::interface::DigitalPinAccessBase
 DigitalPinAccessBase ()
 Cannot be constructed using this base class, but allows the construction of a useless access object without a DigitalPort. More...
 
 DigitalPinAccessBase (DigitalPort *port)
 Initializes the port pointer. More...
 
 ~DigitalPinAccessBase ()=default
 Cannot be destructed using this base class to avoid the need for a virtual destructor. More...
 
DigitalPinAccessBaseoperator= (DigitalPinAccessBase &&old) noexcept
 Allows moving access objects. More...
 
void reset ()
 Loses the pointer to the DigitalPort rendering the access object useless. More...
 
- Protected Attributes inherited from duds::hardware::interface::DigitalPinAccessBase
PortData portdata
 Port specific information. More...
 

Detailed Description

Provides access to a single pin on a DigitalPort.

Author
Jeff Jackowski

Definition at line 22 of file DigitalPinAccess.hpp.

Constructor & Destructor Documentation

◆ DigitalPinAccess() [1/2]

duds::hardware::interface::DigitalPinAccess::DigitalPinAccess ( DigitalPort port,
unsigned int  globalPinId 
)
inlineprivate

Used by DigitalPort.

Parameters
portThe port making this object.
globalPinIdThe global pin ID of the pin to represent.

Definition at line 32 of file DigitalPinAccess.hpp.

◆ DigitalPinAccess() [2/2]

duds::hardware::interface::DigitalPinAccess::DigitalPinAccess ( )
inline

Constructs an access object with nothing to access.

Note
The pin ID will be uninitialized.

Definition at line 40 of file DigitalPinAccess.hpp.

◆ ~DigitalPinAccess()

duds::hardware::interface::DigitalPinAccess::~DigitalPinAccess ( )
inline

Relinquish access on destruction.

Definition at line 55 of file DigitalPinAccess.hpp.

Member Function Documentation

◆ canBeInput()

bool duds::hardware::interface::DigitalPinAccess::canBeInput ( ) const
inline

Returns true if the pin can operate as an input.

Definition at line 169 of file DigitalPinAccess.hpp.

◆ canBeOutput()

bool duds::hardware::interface::DigitalPinAccess::canBeOutput ( ) const
inline

Returns true if the pin can operate as an output.

Definition at line 175 of file DigitalPinAccess.hpp.

◆ canFloat()

bool duds::hardware::interface::DigitalPinAccess::canFloat ( ) const
inline

Returns true if the pin can provide a non-input high impedence state (or maybe allow input state?).

Definition at line 182 of file DigitalPinAccess.hpp.

◆ capabilities()

DigitalPinCap duds::hardware::interface::DigitalPinAccess::capabilities ( ) const
inline

Returns the capabilities of the accessed pin.

Definition at line 83 of file DigitalPinAccess.hpp.

Referenced by canBeInput(), canBeOutput(), and canFloat().

◆ configuration()

DigitalPinConfig duds::hardware::interface::DigitalPinAccess::configuration ( ) const
inline

Returns the current configuration of the accessed pin.

Definition at line 89 of file DigitalPinAccess.hpp.

Referenced by isInput(), and isOutput().

◆ globalId()

unsigned int duds::hardware::interface::DigitalPinAccess::globalId ( ) const
inline

Returns the global pin ID of the accessed pin.

Definition at line 77 of file DigitalPinAccess.hpp.

◆ havePin()

bool duds::hardware::interface::DigitalPinAccess::havePin ( ) const
inline

Returns true if this object has been given a pin to access.

Definition at line 65 of file DigitalPinAccess.hpp.

Referenced by retire().

◆ input()

bool duds::hardware::interface::DigitalPinAccess::input ( ) const
inline

Samples the input state of the pin.

Exceptions
PinWrongDirectionThis pin is not configured as an input.

Definition at line 139 of file DigitalPinAccess.hpp.

◆ isInput()

bool duds::hardware::interface::DigitalPinAccess::isInput ( ) const
inline

Returns true if the pin is configured as an input.

Definition at line 157 of file DigitalPinAccess.hpp.

◆ isOutput()

bool duds::hardware::interface::DigitalPinAccess::isOutput ( ) const
inline

Returns true if the pin is configured as an output.

Definition at line 163 of file DigitalPinAccess.hpp.

◆ localId()

unsigned int duds::hardware::interface::DigitalPinAccess::localId ( ) const
inline

Returns the local pin ID of the accessed pin.

Definition at line 71 of file DigitalPinAccess.hpp.

Referenced by duds::hardware::interface::linux::GpioDevPort::madeAccess(), and duds::hardware::interface::DigitalPort::updateAccess().

◆ modifyConfig()

DigitalPinConfig duds::hardware::interface::DigitalPinAccess::modifyConfig ( const DigitalPinConfig conf) const
inline

Modifies the configuration of the pin.

If the port implementation is a derivative of DigitalPortDependentPins, the change may affect multiple pins, and the configuration of other pins may prevent the requested change.

Parameters
confThe requested new configuration.
Returns
The actual new configuration.

Definition at line 132 of file DigitalPinAccess.hpp.

◆ operator=()

DigitalPinAccess & duds::hardware::interface::DigitalPinAccess::operator= ( DigitalPinAccess &&  old)

A move assignment.

This requires a call to DigitalPort::updateAccess(), which needs to synchronize on its internal data. As a result, move assignments are not speedy. However, they assure pin access is transfered without being lost.

Definition at line 14 of file DigitalPinAccess.cpp.

Referenced by DigitalPinAccess().

◆ output()

void duds::hardware::interface::DigitalPinAccess::output ( bool  state) const
inline

Changes the output state of the pin.

If the pin is not currently configured to output, the configuration will not change, but the new output state will be used when the pin becomes an output in the future.

Parameters
stateThe new output state.

Definition at line 148 of file DigitalPinAccess.hpp.

◆ proposeConfig() [1/2]

DigitalPinRejectedConfiguration::Reason duds::hardware::interface::DigitalPinAccess::proposeConfig ( DigitalPinConfig conf) const
inline

Propose a new configuration for the accessed pin using the current configuration as the initial configuration.

The pin's configuration is not changed; this only checks for a valid supported change.

Parameters
confThe proposed configuration.
Returns
The reason the configuration is bad, or DigitalPinRejectedConfiguration::NotRejected if it can be used.

Definition at line 101 of file DigitalPinAccess.hpp.

◆ proposeConfig() [2/2]

DigitalPinRejectedConfiguration::Reason duds::hardware::interface::DigitalPinAccess::proposeConfig ( DigitalPinConfig proposed,
DigitalPinConfig initial 
) const
inline

Propose a new configuration for the accessed pin using a hypothetical given initial configuration.

The pin's configuration is not changed; this only checks for a valid supported change.

Parameters
proposedThe proposed configuration.
initialThe initial configuration. It should be a valid configuration for the pin and port, but it doesn't need to be the current configuration.
Returns
The reason the configuration is bad, or DigitalPinRejectedConfiguration::NotRejected if it can be used.

Definition at line 118 of file DigitalPinAccess.hpp.

◆ retire()

void duds::hardware::interface::DigitalPinAccess::retire ( )
noexcept

Relinquish access.

Definition at line 29 of file DigitalPinAccess.cpp.

Referenced by operator=(), and ~DigitalPinAccess().

Member Data Documentation

◆ DigitalPort

friend duds::hardware::interface::DigitalPinAccess::DigitalPort
private

Definition at line 34 of file DigitalPinAccess.hpp.

◆ gid

unsigned int duds::hardware::interface::DigitalPinAccess::gid
private

Global pin ID.

Definition at line 26 of file DigitalPinAccess.hpp.

Referenced by globalId(), and operator=().


The documentation for this class was generated from the following files: