tec::VComputerSystem

#include <vcomputer-system.hpp>

Inherits from tec::CommandQueue< VComputerSystem >, tec::EventQueue< KeyboardEvent >, tec::EventQueue< MouseBtnEvent >, tec::EventQueue< MouseClickEvent >, tec::EventQueue< EntityCreated >, tec::EventQueue< EntityDestroyed >

Public Functions

Name
VComputerSystem()
void SetDevice(const eid entity_id, const unsigned int slot, std::shared_ptr< DeviceBase > device)
Sets the specified device for the entity ID to device.
void RemoveDevice(const eid entity_id, const unsigned int slot)
Remove a device from the specified slot.
bool LoadROMFile(const eid entity_id, std::string fname)
Load a ROM file from disk for the specified computer.
void TurnComptuerOn(const eid entity_id)
Turns specified the computer on.
void TurnComptuerOff(const eid entity_id)
Turns specified the computer off.
void Update(double delta)
Handle incoming events to update data.
virtual void On(eid entity_id, std::shared_ptr< KeyboardEvent > data) override
virtual void On(eid entity_id, std::shared_ptr< MouseBtnEvent > data) override
virtual void On(eid entity_id, std::shared_ptr< MouseClickEvent > data) override
virtual void On(eid , std::shared_ptr< EntityCreated > data) override
virtual void On(eid entity_id, std::shared_ptr< EntityDestroyed > data) override

Additional inherited members

Public Functions inherited from tec::CommandQueue< VComputerSystem >

Name
CommandQueue()
~CommandQueue()
void ProcessCommandQueue()
void QueueCommand(Command< T > && command)
void QueueCommand(std::function< void(T *)> && command)

Protected Attributes inherited from tec::CommandQueue< VComputerSystem >

Name
std::atomic< std::queue< Command< T > > * > global_command_queue
std::queue< Command< T > > * local_queue

Public Functions inherited from tec::EventQueue< KeyboardEvent >

Name
EventQueue()
EventQueue(eid entity_id)
virtual ~EventQueue()
void ProcessEventQueue()
void QueueEvent(Event< T > && e)

Protected Attributes inherited from tec::EventQueue< KeyboardEvent >

Name
Queue< Event< T > > * read_event_queue
std::atomic< Queue< Event< T > > * > write_event_queue

Public Functions inherited from tec::EventQueue< MouseBtnEvent >

Name
EventQueue()
EventQueue(eid entity_id)
virtual ~EventQueue()
void ProcessEventQueue()
void QueueEvent(Event< T > && e)

Protected Attributes inherited from tec::EventQueue< MouseBtnEvent >

Name
Queue< Event< T > > * read_event_queue
std::atomic< Queue< Event< T > > * > write_event_queue

Public Functions inherited from tec::EventQueue< MouseClickEvent >

Name
EventQueue()
EventQueue(eid entity_id)
virtual ~EventQueue()
void ProcessEventQueue()
void QueueEvent(Event< T > && e)

Protected Attributes inherited from tec::EventQueue< MouseClickEvent >

Name
Queue< Event< T > > * read_event_queue
std::atomic< Queue< Event< T > > * > write_event_queue

Public Functions inherited from tec::EventQueue< EntityCreated >

Name
EventQueue()
EventQueue(eid entity_id)
virtual ~EventQueue()
void ProcessEventQueue()
void QueueEvent(Event< T > && e)

Protected Attributes inherited from tec::EventQueue< EntityCreated >

Name
Queue< Event< T > > * read_event_queue
std::atomic< Queue< Event< T > > * > write_event_queue

Public Functions inherited from tec::EventQueue< EntityDestroyed >

Name
EventQueue()
EventQueue(eid entity_id)
virtual ~EventQueue()
void ProcessEventQueue()
void QueueEvent(Event< T > && e)

Protected Attributes inherited from tec::EventQueue< EntityDestroyed >

Name
Queue< Event< T > > * read_event_queue
std::atomic< Queue< Event< T > > * > write_event_queue

Public Functions Documentation

function VComputerSystem

VComputerSystem()

function SetDevice

void SetDevice(
    const eid entity_id,
    const unsigned int slot,
    std::shared_ptr< DeviceBase > device
)

Sets the specified device for the entity ID to device.

Parameters:

  • const eid entityID The entity ID the computer/CPU belongs to.
  • const unsigned int The slot to assign device to.
  • std::shared_ptr device The device to install.

function RemoveDevice

void RemoveDevice(
    const eid entity_id,
    const unsigned int slot
)

Remove a device from the specified slot.

Parameters:

  • const eid entityID The entity ID the computer/CPU belongs to.
  • const unsigned int The slot to remove the device from.

function LoadROMFile

bool LoadROMFile(
    const eid entity_id,
    std::string fname
)

Load a ROM file from disk for the specified computer.

Parameters:

  • const eid entityID The entity ID the computer belongs to.
  • const std::string fname The name of the ROM file to load.

Return: bool Whether or not the file loaded successfully (also returns false if no computer exists for the given entity_id).

function TurnComptuerOn

void TurnComptuerOn(
    const eid entity_id
)

Turns specified the computer on.

Parameters:

  • const eid entityID The entity ID the computer belongs to.

function TurnComptuerOff

void TurnComptuerOff(
    const eid entity_id
)

Turns specified the computer off.

Parameters:

  • const eid entityID The entity ID the computer belongs to.

function Update

void Update(
    double delta
)

Handle incoming events to update data.

This function is called once every frame. It is the only function that can write data. This function is in the critical path, job done here must be simple.

If event handling need some batch processing, a task list must be prepared and stored temporarily to be retrieved by RunBatch().

function On

virtual void On(
    eid entity_id,
    std::shared_ptr< KeyboardEvent > data
) override

Reimplements: tec::EventQueue::On

function On

virtual void On(
    eid entity_id,
    std::shared_ptr< MouseBtnEvent > data
) override

Reimplements: tec::EventQueue::On

function On

virtual void On(
    eid entity_id,
    std::shared_ptr< MouseClickEvent > data
) override

Reimplements: tec::EventQueue::On

function On

virtual void On(
    eid ,
    std::shared_ptr< EntityCreated > data
) override

Reimplements: tec::EventQueue::On

function On

virtual void On(
    eid entity_id,
    std::shared_ptr< EntityDestroyed > data
) override

Reimplements: tec::EventQueue::On


Updated on 2022-07-24 at 19:27:35 +0000