HiveMind
IBittyBuzzVm.h
Go to the documentation of this file.
1 #ifndef __IBITTYBUZZVM_H_
2 #define __IBITTYBUZZVM_H_
3 
4 #include "IBittyBuzzLib.h"
5 #include <bbzvm.h>
6 #include <functional>
7 #include <logger/ILogger.h>
8 
9 /*@brief Return codes of the VM when executing*/
10 enum class BBVMRet { Ok = 0, Stopped, VmErr, OutMsgErr };
11 
14 class IBittyBuzzVm {
15  public:
16  virtual ~IBittyBuzzVm() = default;
17 
21  virtual bool init(const std::reference_wrapper<IBittyBuzzLib>* bbzLibs,
22  uint32_t bbzLibsLength) = 0;
23 
25  virtual bool start() = 0;
26 
28  virtual void stop() = 0;
29 
32  virtual BBVMRet step() = 0;
33 
36  virtual void terminate() = 0;
37 
40  virtual void logDump(LogLevel logLevel) = 0;
41 
43  virtual bbzvm_state getState() const = 0;
44 
46  virtual bbzvm_error getError() const = 0;
47 
49  virtual bbzvm_instr getInstruction() const = 0;
50 };
51 
52 #endif // __IBITTYBUZZVM_H_
BBVMRet
BBVMRet
Definition: IBittyBuzzVm.h:10
IBittyBuzzVm::stop
virtual void stop()=0
Stops the vm, can be called in another thread or in an interrupt.
IBittyBuzzVm::getError
virtual bbzvm_error getError() const =0
Get the error state of the VM.
BBVMRet::Stopped
@ Stopped
LogLevel
LogLevel
The log level used for the logger.
Definition: ILogger.h:9
IBittyBuzzVm::step
virtual BBVMRet step()=0
Does one execution step in the virtual machine. Thus execute the buzz code in the step function.
IBittyBuzzVm
Manages BittyBuzz virtual machine.
Definition: IBittyBuzzVm.h:14
IBittyBuzzVm::init
virtual bool init(const std::reference_wrapper< IBittyBuzzLib > *bbzLibs, uint32_t bbzLibsLength)=0
Init the virtual machine.
IBittyBuzzVm::logDump
virtual void logDump(LogLevel logLevel)=0
Logs the virtual machine state, stack, heap and table segments.
IBittyBuzzVm::getInstruction
virtual bbzvm_instr getInstruction() const =0
Get the current instruction of the VM.
BBVMRet::OutMsgErr
@ OutMsgErr
IBittyBuzzLib.h
IBittyBuzzVm::terminate
virtual void terminate()=0
Terminate the virtual machine and removes all messages that were supposed to be processed.
IBittyBuzzVm::~IBittyBuzzVm
virtual ~IBittyBuzzVm()=default
IBittyBuzzVm::getState
virtual bbzvm_state getState() const =0
Get the state of the vm.
DeviceState::Ok
@ Ok
IBittyBuzzVm::start
virtual bool start()=0
Starts the vm.
ILogger.h
BBVMRet::VmErr
@ VmErr