HiveMind
IBittyBuzzClosureRegister.h
Go to the documentation of this file.
1 #ifndef __IBITTYBUZZCLOSUREREGISTER_H_
2 #define __IBITTYBUZZCLOSUREREGISTER_H_
3 
5 #include <bbzvm.h>
6 #include <optional>
7 
10  public:
11  BittyBuzzRegisteredClosure(uint16_t closureId,
12  BittyBuzzFunctionDescription description,
13  bbzheap_idx_t closureHeapIdx,
14  bbzheap_idx_t selfHeapIdx);
15 
16  uint16_t m_closureId;
17  bbzheap_idx_t m_closureHeapIdx;
18  bbzheap_idx_t m_selfHeapIdx;
20 };
21 
25  public:
26  virtual ~IBittyBuzzClosureRegister() = default;
27 
39  virtual bool registerClosure(const char* functionName,
40  bbzheap_idx_t closureHeapIdx,
41  bbzheap_idx_t selfHeapIdx,
42  const BittyBuzzFunctionDescription& description) = 0;
43 
45  virtual void clearClosures() = 0;
50  virtual std::optional<std::reference_wrapper<const BittyBuzzRegisteredClosure>>
51  getRegisteredClosure(const char* functionName) const = 0;
52 
57  virtual std::optional<std::reference_wrapper<const BittyBuzzRegisteredClosure>>
58  getRegisteredClosure(uint16_t idx) const = 0;
59 
63  virtual uint16_t getRegisteredClosureLength() const = 0;
64 };
65 
66 #endif // __IBITTYBUZZCLOSUREREGISTER_H_
BittyBuzzRegisteredClosure::m_closureHeapIdx
bbzheap_idx_t m_closureHeapIdx
Definition: IBittyBuzzClosureRegister.h:17
BittyBuzzRegisteredClosure::m_closureId
uint16_t m_closureId
Definition: IBittyBuzzClosureRegister.h:16
IBittyBuzzClosureRegister::clearClosures
virtual void clearClosures()=0
Clears all the registered closures.
IBittyBuzzClosureRegister
A class to register buzz function/closures id and associate them with a string.
Definition: IBittyBuzzClosureRegister.h:24
BittyBuzzRegisteredClosure::m_selfHeapIdx
bbzheap_idx_t m_selfHeapIdx
Definition: IBittyBuzzClosureRegister.h:18
IBittyBuzzClosureRegister::registerClosure
virtual bool registerClosure(const char *functionName, bbzheap_idx_t closureHeapIdx, bbzheap_idx_t selfHeapIdx, const BittyBuzzFunctionDescription &description)=0
register a closure to the list
BittyBuzzFunctionDescription
Description for a function, used for the FunctionDescriptionRequest/Response.
Definition: BittyBuzzFunctionDescription.h:11
BittyBuzzRegisteredClosure::m_description
BittyBuzzFunctionDescription m_description
Definition: IBittyBuzzClosureRegister.h:19
BittyBuzzFunctionDescription.h
BittyBuzzRegisteredClosure
a class containing info of a registered closure
Definition: IBittyBuzzClosureRegister.h:9
IBittyBuzzClosureRegister::~IBittyBuzzClosureRegister
virtual ~IBittyBuzzClosureRegister()=default
IBittyBuzzClosureRegister::getRegisteredClosureLength
virtual uint16_t getRegisteredClosureLength() const =0
get the length/number of the registered closures
BittyBuzzRegisteredClosure::BittyBuzzRegisteredClosure
BittyBuzzRegisteredClosure(uint16_t closureId, BittyBuzzFunctionDescription description, bbzheap_idx_t closureHeapIdx, bbzheap_idx_t selfHeapIdx)
Definition: BittyBuzzClosureRegister.cpp:6
IBittyBuzzClosureRegister::getRegisteredClosure
virtual std::optional< std::reference_wrapper< const BittyBuzzRegisteredClosure > > getRegisteredClosure(const char *functionName) const =0
get the id of a stored function by it's associated name