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

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

#include <hal/handles/IndexedHandleResource.h>

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

Public Member Functions

 IndexedHandleResource ()=default
 
 IndexedHandleResource (const IndexedHandleResource &)=delete
 
IndexedHandleResourceoperator= (const IndexedHandleResource &)=delete
 
std::shared_ptr< TStruct > Allocate (int16_t index, THandle *handle, int32_t *status)
 
int16_t GetIndex (THandle handle)
 
std::shared_ptr< TStruct > Get (THandle handle)
 
void Free (THandle handle)
 
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 IndexedHandleResourceTest
 

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, HAL_HandleEnum enumValue>
class hal::IndexedHandleResource< THandle, TStruct, size, enumValue >

The IndexedHandleResource class is a way to track handles.

This version allows a limited number of handles that are allocated by index. 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
enumValueThe type value stored in the handle

Constructor & Destructor Documentation

◆ IndexedHandleResource() [1/2]

template<typename THandle , typename TStruct , int16_t size, HAL_HandleEnum enumValue>
hal::IndexedHandleResource< THandle, TStruct, size, enumValue >::IndexedHandleResource ( )
default

◆ IndexedHandleResource() [2/2]

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

Member Function Documentation

◆ Allocate()

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

◆ Free()

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

◆ Get()

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

◆ GetIndex()

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

◆ operator=()

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

◆ ResetHandles()

template<typename THandle , typename TStruct , int16_t size, HAL_HandleEnum enumValue>
void hal::IndexedHandleResource< THandle, TStruct, size, enumValue >::ResetHandles
overridevirtual

Reimplemented from hal::HandleBase.

Friends And Related Function Documentation

◆ IndexedHandleResourceTest

template<typename THandle , typename TStruct , int16_t size, HAL_HandleEnum enumValue>
friend class IndexedHandleResourceTest
friend

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