WPILibC++ 2023.4.3-108-ge5452e3
hal::UnlimitedHandleResource< THandle, TStruct, enumValue > Class Template Reference

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

#include <hal/handles/UnlimitedHandleResource.h>

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

Public Member Functions

 UnlimitedHandleResource ()=default
 
 UnlimitedHandleResource (const UnlimitedHandleResource &)=delete
 
UnlimitedHandleResourceoperator= (const UnlimitedHandleResource &)=delete
 
THandle Allocate (std::shared_ptr< TStruct > structure)
 
int16_t GetIndex (THandle handle)
 
std::shared_ptr< TStruct > Get (THandle handle)
 
std::shared_ptr< TStruct > Free (THandle handle)
 
void ResetHandles () override
 
template<typename Functor >
void ForEach (Functor func)
 
- Public Member Functions inherited from hal::HandleBase
 HandleBase ()
 
 ~HandleBase ()
 
 HandleBase (const HandleBase &)=delete
 
HandleBaseoperator= (const HandleBase &)=delete
 
virtual void ResetHandles ()
 

Friends

class UnlimitedHandleResourceTest
 

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

The UnlimitedHandleResource class is a way to track handles.

This version allows an unlimited number of handles that are allocated sequentially. When possible, indices are reused to save memory usage and keep the array length down. However, automatic array management has not been implemented, but might be in the future. Because we have to loop through the allocator, we must use a global mutex.

Template Parameters
THandleThe Handle Type (Must be typedefed from HAL_Handle)
TStructThe struct type held by this resource
enumValueThe type value stored in the handle

Constructor & Destructor Documentation

◆ UnlimitedHandleResource() [1/2]

template<typename THandle , typename TStruct , HAL_HandleEnum enumValue>
hal::UnlimitedHandleResource< THandle, TStruct, enumValue >::UnlimitedHandleResource ( )
default

◆ UnlimitedHandleResource() [2/2]

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

Member Function Documentation

◆ Allocate()

template<typename THandle , typename TStruct , HAL_HandleEnum enumValue>
THandle hal::UnlimitedHandleResource< THandle, TStruct, enumValue >::Allocate ( std::shared_ptr< TStruct >  structure)

◆ ForEach()

template<typename THandle , typename TStruct , HAL_HandleEnum enumValue>
template<typename Functor >
void hal::UnlimitedHandleResource< THandle, TStruct, enumValue >::ForEach ( Functor  func)

◆ Free()

template<typename THandle , typename TStruct , HAL_HandleEnum enumValue>
std::shared_ptr< TStruct > hal::UnlimitedHandleResource< THandle, TStruct, enumValue >::Free ( THandle  handle)

◆ Get()

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

◆ GetIndex()

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

◆ operator=()

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

◆ ResetHandles()

template<typename THandle , typename TStruct , HAL_HandleEnum enumValue>
void hal::UnlimitedHandleResource< THandle, TStruct, enumValue >::ResetHandles
overridevirtual

Reimplemented from hal::HandleBase.

Friends And Related Function Documentation

◆ UnlimitedHandleResourceTest

template<typename THandle , typename TStruct , HAL_HandleEnum enumValue>
friend class UnlimitedHandleResourceTest
friend

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