iv::Instance Class Reference

#include <Instance.hpp>

Public Member Functions

 Instance (const SystemContainer *sc)
 
virtual ~Instance ()
 
Instanceinstance ()
 
const SystemContainergetSystemContainer () const
 
SystemContainerduplicateSystemContainer ()
 
template<class TypedSystem >
TypedSystem * getSystem () const
 
unsigned frame_id () const
 
const std::string & instance_name ()
 
void instance_parent (Instance *parent)
 
void instance_finalize (std::string const &inst_name, ClientMarker const *root_client)
 
void client_register (ClientMarker const *marker)
 
void client_unregister (ClientMarker const *marker)
 
void client_log (ClientMarker const *cm, SrcInfo const &info, LogId id, std::string const &message)
 
bool client_log_enabled (ClientMarker const *cm, LogId id)
 
void debug_print_clients (TextDebugView *view)
 
InstanceDebug_Parent ()
 
const std::unordered_set< Instance * > & Debug_Children ()
 
const ClientMarkerDebug_RootClient ()
 
const std::unordered_set< ClientMarker const * > & Debug_Clients ()
 
template<class TypedClient >
void Debug_ForeachClient (std::function< void(TypedClient *) > const &lambda)
 

Friends

class instance_ptr_interface
 

Detailed Description

Definition at line 30 of file Instance.hpp.

Constructor & Destructor Documentation

◆ Instance()

iv::Instance::Instance ( const SystemContainer sc)

Definition at line 12 of file Instance.cpp.

◆ ~Instance()

iv::Instance::~Instance ( )
virtual

Definition at line 26 of file Instance.cpp.

Member Function Documentation

◆ instance()

Instance* iv::Instance::instance ( )
inline

Definition at line 36 of file Instance.hpp.

◆ getSystemContainer()

const SystemContainer * iv::Instance::getSystemContainer ( ) const

Returns SystemContainer given in constructor. Do not use it directly, only Properties and Components should use this to communicate with systems.

Definition at line 102 of file Instance.cpp.

◆ duplicateSystemContainer()

SystemContainer * iv::Instance::duplicateSystemContainer ( )

SystemContainer of this Instance will be duplicated (to contain the same systems as the original SystemContainer). From now on, all children of this Instance will receive the new SystemContainer in the constructor. This Instance will still use the old SystemContainer. If the SystemContainer is already duplicated, this will just return pointer to it. Instance can change which systems are contained in the new SystemContainer (using the pointer returned from this method).

Call SystemContainer::createProxies after/if you create new systems in that SystemContainer.

Definition at line 107 of file Instance.cpp.

◆ getSystem()

template<class TypedSystem >
TypedSystem * iv::Instance::getSystem

Shortcut for getSystemContainer()->getSystem< TypedSystem >().

Definition at line 5 of file Instance.inl.

◆ frame_id()

unsigned iv::Instance::frame_id ( ) const

Definition at line 56 of file Instance.cpp.

◆ instance_name()

const std::string & iv::Instance::instance_name ( )

Name for introspection purposes.

Definition at line 169 of file Instance.cpp.

◆ instance_parent()

void iv::Instance::instance_parent ( Instance parent)

Creates two way relation that is automaticaly cleaned when either Instance is destroyed. Instance can has only one parent, can be nullptr to clear existing relation.

Definition at line 84 of file Instance.cpp.

◆ instance_finalize()

void iv::Instance::instance_finalize ( std::string const &  inst_name,
ClientMarker const *  root_client 
)

Usually assigned right after instantiation. Can be called only once. This finalizes the Instance instanciation, so the instance is registered to InstanceSystem and debug listeners from this method.

Definition at line 61 of file Instance.cpp.

◆ client_register()

void iv::Instance::client_register ( ClientMarker const *  marker)

Called automatically from ClientMarker.

Definition at line 128 of file Instance.cpp.

◆ client_unregister()

void iv::Instance::client_unregister ( ClientMarker const *  marker)

Definition at line 141 of file Instance.cpp.

◆ client_log()

void iv::Instance::client_log ( ClientMarker const *  cm,
SrcInfo const &  info,
LogId  id,
std::string const &  message 
)

Definition at line 154 of file Instance.cpp.

◆ client_log_enabled()

bool iv::Instance::client_log_enabled ( ClientMarker const *  cm,
LogId  id 
)

Definition at line 161 of file Instance.cpp.

◆ debug_print_clients()

void iv::Instance::debug_print_clients ( TextDebugView view)

Definition at line 95 of file Instance.cpp.

◆ Debug_Parent()

Instance * iv::Instance::Debug_Parent ( )

Definition at line 174 of file Instance.cpp.

◆ Debug_Children()

const std::unordered_set< Instance * > & iv::Instance::Debug_Children ( )

Definition at line 179 of file Instance.cpp.

◆ Debug_RootClient()

const ClientMarker * iv::Instance::Debug_RootClient ( )

Definition at line 184 of file Instance.cpp.

◆ Debug_Clients()

const std::unordered_set< ClientMarker const * > & iv::Instance::Debug_Clients ( )

Definition at line 189 of file Instance.cpp.

◆ Debug_ForeachClient()

template<class TypedClient >
void iv::Instance::Debug_ForeachClient ( std::function< void(TypedClient *) > const &  lambda)

Helper method, iterates over set returned by DebugClientMarkers(), checks type and casts client if type is equal. NOTE - currently unsafe - changes to Instance clients (adding or removing) may corrupt iterators used in this method and cause segfault

  • should be refactored in future to support some kind of safe listener based approach

Definition at line 11 of file Instance.inl.

Friends And Related Function Documentation

◆ instance_ptr_interface

friend class instance_ptr_interface
friend

Definition at line 138 of file Instance.hpp.


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