Allolib  1.0
C++ Components For Interactive Multimedia
al::ConsoleDomain Class Reference

ConsoleDomain class. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/app/al_ConsoleDomain.hpp>

Inheritance diagram for al::ConsoleDomain:
al::AsynchronousDomain al::ComputationDomain

Public Member Functions

bool init (ComputationDomain *parent=nullptr) override
 initialize More...
 
bool start () override
 start the asyncrhonous execution of the domain More...
 
bool stop () override
 stop the asyncrhonous execution of the domain More...
 
bool cleanup (ComputationDomain *parent=nullptr) override
 cleanup More...
 
template<class DomainType >
std::shared_ptr< DomainType > newSubDomain (bool prepend=false)
 Add a synchronous domain to this domain. More...
 
void removeSubDomain (std::shared_ptr< SynchronousDomain > subDomain)
 Remove a subdomain. More...
 
double timeDelta ()
 Return time delta with respect to previous processing pass for this domain. More...
 
void setTimeDelta (double delta)
 
void registerInitializeCallback (std::function< void(ComputationDomain *)> callback)
 register callbacks to be called in the init() function More...
 
void registerCleanupCallback (std::function< void(ComputationDomain *)> callback)
 register callbacks to be called in the cleanup() function More...
 
std::vector< ParameterMeta * > parameters ()
 Return a list of parameters that control this domain. More...
 

Public Attributes

std::function< bool(const std::string &)> onLine
 

Protected Member Functions

void callStartCallbacks ()
 callStartCallbacks should be called by children of this class after the domain has been set up to start, before going into the blocking loop
 
void callStopCallbacks ()
 callStopCallbacks should be called by children of this class on the stop request, before the domain has been stopped
 
bool initializeSubdomains (bool pre=false)
 initializeSubdomains should be called within the domain's initialization function More...
 
bool tickSubdomains (bool pre=false)
 execute subdomains More...
 
bool cleanupSubdomains (bool pre=false)
 cleanup subdomains More...
 
void callInitializeCallbacks ()
 callInitializeCallbacks should be called by children of this class after the domain has been initialized
 
void callCleanupCallbacks ()
 callInitializeCallbacks should be called by children of this class before the domain has been cleaned up
 

Protected Attributes

std::mutex mSubdomainLock
 
double mTimeDrift {0.0}
 
std::vector< std::pair< std::shared_ptr< SynchronousDomain >, bool > > mSubDomainList
 
std::vector< ParameterMeta * > mParameters
 

Detailed Description

ConsoleDomain class.

This domain is a blocking domain, i.e. blocks on start(). Set the onLine() function to get lines entered in the console. My default, the domain exits when the line is empty (when return is pressed). You can use this domain instead of app to build your own command line classes.

Definition at line 21 of file al_ConsoleDomain.hpp.

Member Function Documentation

◆ cleanup()

bool al::ConsoleDomain::cleanup ( ComputationDomain parent = nullptr)
inlineoverridevirtual

cleanup

Parameters
parent
Returns
true if cleanup succesfull

Reimplemented from al::ComputationDomain.

Definition at line 35 of file al_ConsoleDomain.hpp.

◆ cleanupSubdomains()

bool al::ComputationDomain::cleanupSubdomains ( bool  pre = false)
protectedinherited

cleanup subdomains

Parameters
precleanup prepended domains if true, otherwise appended domains.
Returns
true if all cleanup sucessful.

You must call this function twice: once for prepended and then for appended domains.

◆ init()

bool al::ConsoleDomain::init ( ComputationDomain parent = nullptr)
inlineoverridevirtual

initialize

Parameters
parent
Returns
true if init succeeded

Multiple calls to init() should be allowed.

Reimplemented from al::ComputationDomain.

Definition at line 23 of file al_ConsoleDomain.hpp.

◆ initializeSubdomains()

bool al::ComputationDomain::initializeSubdomains ( bool  pre = false)
protectedinherited

initializeSubdomains should be called within the domain's initialization function

Parameters
preinitialize prepended domains if true, otherwise appended domains.
Returns
true if all initializations sucessful.

You must call this function twice: once for prepended and then for appended domains.

◆ newSubDomain()

template<class DomainType >
std::shared_ptr< DomainType > al::ComputationDomain::newSubDomain ( bool  prepend = false)
inherited

Add a synchronous domain to this domain.

Parameters
prependDetermines whether the sub-domain should run before or after this domain
Returns
the created domain.

The domain specified by DomainType must inherit from SynchronousDomian. It will trigger an assertion if not (will have undefined behavior for Release builds) This operation is thread safe if the domain can pause itself, but it is blocking, so there are no guarantees that it will not interefere with the timely running of the domain.

Definition at line 218 of file al_ComputationDomain.hpp.

◆ parameters()

std::vector<ParameterMeta *> al::ComputationDomain::parameters ( )
inlineinherited

Return a list of parameters that control this domain.

Returns
list of parameters

The parameters provided here provide runtime "continuous" parameters, for example like audio gain or eye separation. There should be a clear distinction between values that need to be set on domain intialization that must remain immutable during domain operation and parameters provided here that provide continuous adjustment to the domain's operation.

Definition at line 104 of file al_ComputationDomain.hpp.

◆ registerCleanupCallback()

void al::ComputationDomain::registerCleanupCallback ( std::function< void(ComputationDomain *)>  callback)
inherited

register callbacks to be called in the cleanup() function

Parameters
callback

◆ registerInitializeCallback()

void al::ComputationDomain::registerInitializeCallback ( std::function< void(ComputationDomain *)>  callback)
inherited

register callbacks to be called in the init() function

Parameters
callback

◆ removeSubDomain()

void al::ComputationDomain::removeSubDomain ( std::shared_ptr< SynchronousDomain subDomain)
inherited

Remove a subdomain.

Parameters
subDomainThis operation is thread safe, but it might block causing drops or missed deadlines for the parent domain. If this is a problem, the domain should be stopped prior to adding/removeing sub-domains.

◆ start()

bool al::ConsoleDomain::start ( )
inlineoverridevirtual

start the asyncrhonous execution of the domain

Returns
true if start was successful

Assumes that init() has already been called.

Implements al::AsynchronousDomain.

Definition at line 25 of file al_ConsoleDomain.hpp.

◆ stop()

bool al::ConsoleDomain::stop ( )
inlineoverridevirtual

stop the asyncrhonous execution of the domain

Returns
true if stop was successful

Domains should be written so that either start() or cleanup() work after calling stop()

Implements al::AsynchronousDomain.

Definition at line 33 of file al_ConsoleDomain.hpp.

◆ tickSubdomains()

bool al::ComputationDomain::tickSubdomains ( bool  pre = false)
protectedinherited

execute subdomains

Parameters
preexecute prepended domains if true, otherwise appended domains.
Returns
true if all execution sucessful.

You must call this function twice: once for prepended and then for appended domains.

◆ timeDelta()

double al::ComputationDomain::timeDelta ( )
inlineinherited

Return time delta with respect to previous processing pass for this domain.

Returns
time delta

The time delta may be set internally by the domain so that it is available whenever the domain ticks. It might be 0 for domains that don't support this functionality or that are tied to strict hardware clocks where this information is not necessary

Definition at line 75 of file al_ComputationDomain.hpp.

Member Data Documentation

◆ onLine

std::function<bool(const std::string &)> al::ConsoleDomain::onLine
Initial value:
=
[](const std::string &line) {
if (line.size() == 0) {
return false;
}
return true;
}

Definition at line 37 of file al_ConsoleDomain.hpp.


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