Skip to content

Class emulator::EmulatorContext

ClassList > emulator > EmulatorContext

Singleton context for managing emulator component instances. More...

  • #include <emulator_context.hpp>

Public Functions

Type Name
void clean_up ()
Remove all objects from the context.
T & create (Args &&... args)
Create and register a new component instance.
const T & get () const
Get a const reference to an existing component.
T & getNonConst ()
Get a non-const reference to an existing component.
bool has () const
Check if a component of type T exists.

Public Static Functions

Type Name
EmulatorContext & singleton ()
Get the singleton instance.

Detailed Description

Public Functions Documentation

function clean_up

Remove all objects from the context.

inline void emulator::EmulatorContext::clean_up () 

Should be called during shutdown to release resources.


function create

Create and register a new component instance.

template<typename T, typename... Args>
inline T & emulator::EmulatorContext::create (
    Args &&... args
) 

Creates an instance of type T with the given constructor arguments and stores it in the context.

Template parameters:

  • T Component type to create
  • Args Constructor argument types

Parameters:

  • args Arguments to pass to T's constructor

Returns:

Reference to the newly created instance

Exception:

  • std::runtime_error if an instance of T already exists

function get

Get a const reference to an existing component.

template<typename T>
inline const T & emulator::EmulatorContext::get () const

Template parameters:

  • T Component type to retrieve

Returns:

Const reference to the component

Exception:

  • std::runtime_error if no instance of T exists

function getNonConst

Get a non-const reference to an existing component.

template<typename T>
inline T & emulator::EmulatorContext::getNonConst () 

Template parameters:

  • T Component type to retrieve

Returns:

Reference to the component

Exception:

  • std::runtime_error if no instance of T exists

function has

Check if a component of type T exists.

template<typename T>
inline bool emulator::EmulatorContext::has () const

Template parameters:

  • T Component type to check

Returns:

true if an instance of T exists in the context


Public Static Functions Documentation

function singleton

Get the singleton instance.

static inline EmulatorContext & emulator::EmulatorContext::singleton () 

Returns:

Reference to the global EmulatorContext



The documentation for this class was generated from the following file components/emulator_comps/common/src/emulator_context.hpp