HiveMind
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
BittyBuzzClosureRegister Class Reference

#include <BittyBuzzClosureRegister.h>

Inheritance diagram for BittyBuzzClosureRegister:
Inheritance graph
Collaboration diagram for BittyBuzzClosureRegister:
Collaboration graph

Public Member Functions

 ~BittyBuzzClosureRegister ()=default
 
bool registerClosure (const char *functionName, bbzheap_idx_t closureHeapIdx, bbzheap_idx_t selfHeapIdx, const BittyBuzzFunctionDescription &description) override
 register a closure to the list More...
 
void clearClosures () override
 Clears all the registered closures. More...
 
std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > getRegisteredClosure (const char *functionName) const override
 get the id of a stored function by it's associated name More...
 
std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > getRegisteredClosure (uint16_t idx) const override
 get the id of a stored function by it's associated name More...
 
uint16_t getRegisteredClosureLength () const override
 get the length/number of the registered closures More...
 
- Public Member Functions inherited from IBittyBuzzClosureRegister
virtual ~IBittyBuzzClosureRegister ()=default
 

Static Public Attributes

constexpr static uint16_t m_maxSize = BBZ_CLOSURE_REGISTER_LENGTH
 

Private Attributes

HashMapStack< uint16_t, const char *, m_maxSizem_closureNameRegisters
 
HashMapStack< std::string_view, BittyBuzzRegisteredClosure, m_maxSizem_closureRegisterMap
 

Constructor & Destructor Documentation

◆ ~BittyBuzzClosureRegister()

BittyBuzzClosureRegister::~BittyBuzzClosureRegister ( )
default

Member Function Documentation

◆ clearClosures()

void BittyBuzzClosureRegister::clearClosures ( )
overridevirtual

Clears all the registered closures.

Implements IBittyBuzzClosureRegister.

◆ getRegisteredClosure() [1/2]

std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > BittyBuzzClosureRegister::getRegisteredClosure ( const char *  functionName) const
overridevirtual

get the id of a stored function by it's associated name

Parameters
functionNamethe name of the function to fetch
Returns
an optional that has a reference to the info of the registered closure

Implements IBittyBuzzClosureRegister.

◆ getRegisteredClosure() [2/2]

std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > BittyBuzzClosureRegister::getRegisteredClosure ( uint16_t  idx) const
overridevirtual

get the id of a stored function by it's associated name

Parameters
idxthe index of the function to fetch
Returns
an optional that has a reference to the info of the registered closure

Implements IBittyBuzzClosureRegister.

◆ getRegisteredClosureLength()

uint16_t BittyBuzzClosureRegister::getRegisteredClosureLength ( ) const
overridevirtual

get the length/number of the registered closures

Returns
the number of registered closures

Implements IBittyBuzzClosureRegister.

◆ registerClosure()

bool BittyBuzzClosureRegister::registerClosure ( const char *  functionName,
bbzheap_idx_t  closureHeapIdx,
bbzheap_idx_t  selfHeapIdx,
const BittyBuzzFunctionDescription description 
)
overridevirtual

register a closure to the list

Parameters
functionNamethe name of the function, Warning, the register just keeps a pointer to the name, so make sure the data it's points to is valid during usage
closureHeapIdxa pointer to the heap to the closure. When registering, the function will be made permanent.
selfHeapIdxa pointer to the heap to the self variable, can be nil. When registering, the function will be made permanent.
descriptionthe description of the function, it's argument names and types
Returns
true on success, false if not (i.e. no more space in the list, or the heapidx is not a closure)

Implements IBittyBuzzClosureRegister.

Member Data Documentation

◆ m_closureNameRegisters

HashMapStack<uint16_t, const char*, m_maxSize> BittyBuzzClosureRegister::m_closureNameRegisters
private

◆ m_closureRegisterMap

HashMapStack<std::string_view, BittyBuzzRegisteredClosure, m_maxSize> BittyBuzzClosureRegister::m_closureRegisterMap
private

◆ m_maxSize

constexpr static uint16_t BittyBuzzClosureRegister::m_maxSize = BBZ_CLOSURE_REGISTER_LENGTH
staticconstexpr

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