WPILibC++ 2024.3.2
hal::DigitalHandleResource< THandle, TStruct, size > Class Template Reference

The DigitalHandleResource class is a way to track handles. More...

#include <hal/handles/DigitalHandleResource.h>

Inheritance diagram for hal::DigitalHandleResource< THandle, TStruct, size >:
hal::HandleBase

Public Member Functions

 DigitalHandleResource ()=default
 
 DigitalHandleResource (const DigitalHandleResource &)=delete
 
DigitalHandleResourceoperator= (const DigitalHandleResource &)=delete
 
std::shared_ptr< TStruct > Allocate (int16_t index, HAL_HandleEnum enumValue, THandle *handle, int32_t *status)
 
int16_t GetIndex (THandle handle, HAL_HandleEnum enumValue)
 
std::shared_ptr< TStruct > Get (THandle handle, HAL_HandleEnum enumValue)
 
void Free (THandle handle, HAL_HandleEnum enumValue)
 
void ResetHandles () override
 
- Public Member Functions inherited from hal::HandleBase
 HandleBase ()
 
 ~HandleBase ()
 
 HandleBase (const HandleBase &)=delete
 
HandleBaseoperator= (const HandleBase &)=delete
 
virtual void ResetHandles ()
 

Friends

class DigitalHandleResourceTest
 

Additional Inherited Members

- Static Public Member Functions inherited from hal::HandleBase
static void ResetGlobalHandles ()
 
- Protected Attributes inherited from hal::HandleBase
int16_t m_version
 

Detailed Description

template<typename THandle, typename TStruct, int16_t size>
class hal::DigitalHandleResource< THandle, TStruct, size >

The DigitalHandleResource class is a way to track handles.

This version allows a limited number of handles that are allocated by index. The enum value is separate, as 2 enum values are allowed per handle Because they are allocated by index, each individual index holds its own mutex, which reduces contention heavily.

Template Parameters
THandleThe Handle Type (Must be typedefed from HAL_Handle)
TStructThe struct type held by this resource
sizeThe number of resources allowed to be allocated

Constructor & Destructor Documentation

◆ DigitalHandleResource() [1/2]

template<typename THandle , typename TStruct , int16_t size>
hal::DigitalHandleResource< THandle, TStruct, size >::DigitalHandleResource ( )
default

◆ DigitalHandleResource() [2/2]

template<typename THandle , typename TStruct , int16_t size>
hal::DigitalHandleResource< THandle, TStruct, size >::DigitalHandleResource ( const DigitalHandleResource< THandle, TStruct, size > &  )
delete

Member Function Documentation

◆ Allocate()

template<typename THandle , typename TStruct , int16_t size>
std::shared_ptr< TStruct > hal::DigitalHandleResource< THandle, TStruct, size >::Allocate ( int16_t  index,
HAL_HandleEnum  enumValue,
THandle *  handle,
int32_t *  status 
)

◆ Free()

template<typename THandle , typename TStruct , int16_t size>
void hal::DigitalHandleResource< THandle, TStruct, size >::Free ( THandle  handle,
HAL_HandleEnum  enumValue 
)

◆ Get()

template<typename THandle , typename TStruct , int16_t size>
std::shared_ptr< TStruct > hal::DigitalHandleResource< THandle, TStruct, size >::Get ( THandle  handle,
HAL_HandleEnum  enumValue 
)

◆ GetIndex()

template<typename THandle , typename TStruct , int16_t size>
int16_t hal::DigitalHandleResource< THandle, TStruct, size >::GetIndex ( THandle  handle,
HAL_HandleEnum  enumValue 
)
inline

◆ operator=()

template<typename THandle , typename TStruct , int16_t size>
DigitalHandleResource & hal::DigitalHandleResource< THandle, TStruct, size >::operator= ( const DigitalHandleResource< THandle, TStruct, size > &  )
delete

◆ ResetHandles()

template<typename THandle , typename TStruct , int16_t size>
void hal::DigitalHandleResource< THandle, TStruct, size >::ResetHandles
overridevirtual

Reimplemented from hal::HandleBase.

Friends And Related Function Documentation

◆ DigitalHandleResourceTest

template<typename THandle , typename TStruct , int16_t size>
friend class DigitalHandleResourceTest
friend

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