VPTissue Reference Manual
SimShell::Session::ISession Class Referenceabstract

Generic session interface. More...

#include <ISession.h>

Inheritance diagram for SimShell::Session::ISession:
Inheritance graph
Collaboration diagram for SimShell::Session::ISession:
Collaboration graph

Classes

struct  ExporterType
 

Public Types

using ExportCallbackType = std::function< void(const std::string &)>
 
using ExportersType = std::vector< std::pair< std::string, ExporterType >>
 
enum  InfoMessageReason { Stepped, Started, Stopped, Terminated }
 Enumeration for the reason of an emitted InfoMessage from the project.
 
using RootViewerType = Viewer::IViewerNode
 
- Public Types inherited from SimPT_Sim::ClockMan::Timeable<>
using Timings = typename ClockTraits< std::chrono::system_clock, typename std::chrono::system_clock::duration >::CumulativeTimings
 
- Public Types inherited from SimPT_Sim::ClockMan::ClockTraits< std::chrono::system_clock, typename std::chrono::system_clock::duration >
using Clock = std::chrono::system_clock
 Type for clock.
 
using CumulativeTimings = SimPT_Sim::ClockMan::CumulativeRecords< typename std::chrono::system_clock::duration >
 Records with cumulative timing info.
 
using Duration = typename std::chrono::system_clock::duration
 Type for time duration units.
 
using IndividualTimings = SimPT_Sim::ClockMan::IndividualRecords< typename std::chrono::system_clock::duration >
 Records with individual timing info.
 
using Stopclock = SimPT_Sim::ClockMan::Stopwatch< std::chrono::system_clock >
 Stopwatch to measure time durations.
 

Signals

void ErrorMessage (const std::string &error)
 Emitted when an error in a time step occurred (Multithreading cannot return bool directly in ProjectBase::TimeStep(), as the computation is queued for another thread) More...
 
void InfoMessage (const std::string &message, const InfoMessageReason &reason)
 Emitted when an event with an accompanying info message has been done/occurred (Multithreading cannot return bool directly in ProjectBase::TimeStep(), as the computation is queued for another thread) More...
 

Public Member Functions

virtual ~ISession ()
 Virtual destructor for interface class.
 
virtual std::shared_ptr< RootViewerTypeCreateRootViewer (Gui::Controller::AppController *parent=nullptr)=0
 Return root viewer, i.e. More...
 
virtual void ForceExport ()=0
 Force enabled viewers to export. More...
 
virtual ExportersType GetExporters ()=0
 Return list of callbacks for exporting simulation state to a file.
 
virtual const boost::property_tree::ptree & GetParameters () const =0
 Get simulation parameters. More...
 
virtual void SetParameters (const boost::property_tree::ptree &)=0
 Set simulation parameters.
 
virtual void StartSimulation (int steps=-1)=0
 Starts doing time steps until termination or until stopped. More...
 
virtual void StopSimulation ()=0
 Stops taking simulation time steps.
 
virtual void TimeStep ()=0
 Perform 1 simulation step, bringing simulation into the "next" state. More...
 
- Public Member Functions inherited from SimPT_Sim::ClockMan::Timeable<>
virtual ~Timeable ()
 Destructor virtual for polymorphic class.
 
virtual Timings GetTimings () const =0
 Timings in duration units specified above.
 

Detailed Description

Generic session interface.

A session is a collection of instances associated with an opened/running project.

As this interface is designed to also be implemented by an asynchronously running simulation inside a project, take care to also use it like that. This is why, for example, there a signals for info and errors, rather than return values/getters for the information.

Definition at line 53 of file ISession.h.

Member Function Documentation

virtual std::shared_ptr<RootViewerType> SimShell::Session::ISession::CreateRootViewer ( Gui::Controller::AppController parent = nullptr)
pure virtual

Return root viewer, i.e.

the viewer that owns all other viewers.

Implemented in SimPT_Shell::Session::SimSession, and SimPT_Shell::Session::SimSessionCoupled.

void SimShell::Session::ISession::ErrorMessage ( const std::string &  error)
signal

Emitted when an error in a time step occurred (Multithreading cannot return bool directly in ProjectBase::TimeStep(), as the computation is queued for another thread)

Parameters
errorThe error message
virtual void SimShell::Session::ISession::ForceExport ( )
pure virtual

Force enabled viewers to export.

This is useful when e.g. parameters or preferences are changed and we need a "checkpoint" in simulation history for this event.

Implemented in SimPT_Shell::Session::SimSession, and SimPT_Shell::Session::SimSessionCoupled.

virtual const boost::property_tree::ptree& SimShell::Session::ISession::GetParameters ( ) const
pure virtual

Get simulation parameters.

Returns
const ptree& A reference to the parameters of the simulation. This reference will stay valid as long as the user of this function doesn't return to the Qt event loop.

Implemented in SimPT_Shell::Session::SimSession, and SimPT_Shell::Session::SimSessionCoupled.

void SimShell::Session::ISession::InfoMessage ( const std::string &  message,
const InfoMessageReason reason 
)
signal

Emitted when an event with an accompanying info message has been done/occurred (Multithreading cannot return bool directly in ProjectBase::TimeStep(), as the computation is queued for another thread)

Parameters
messageThe simulation info message
reasonThe reason why an info message was emitted

Referenced by SimPT_Shell::Session::SimSessionCoupled::StartSimulation(), and SimPT_Shell::Session::SimSessionCoupled::StopSimulation().

Here is the caller graph for this function:

virtual void SimShell::Session::ISession::StartSimulation ( int  steps = -1)
pure virtual

Starts doing time steps until termination or until stopped.

Parameters
stepsThe maximum number of steps to simulate (-1 for unlimited) The previous number of steps is overwritten by this

Implemented in SimPT_Shell::Session::SimSession, and SimPT_Shell::Session::SimSessionCoupled.

virtual void SimShell::Session::ISession::TimeStep ( )
pure virtual

Perform 1 simulation step, bringing simulation into the "next" state.

This method cannot return a result, as the time step may be performed in another thread. Instead, an InfoMessage or ErrorMessage signal will be emitted.

Exceptions
Exceptionif no time step could be performed due to other reasons.

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