libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AlgAudio::SCLangSubprocess Class Reference

#include <SCLangSubprocess.hpp>

Public Member Functions

 SCLangSubprocess (std::string command)
 
void SendInstruction (std::string)
 
void SendInstruction (std::string instruction, std::function< void(std::string)> reply_action)
 
void Start ()
 
void Stop ()
 
void TriggerSignals ()
 
 ~SCLangSubprocess ()
 

Public Attributes

Signal< std::string > on_any_line_received
 
Signal on_started
 

Detailed Description

A wrapper for Subprocess, specialised in managing sclang{,.exe}. In particular, it can recognize comamnd prompt at SC output, pass events to main loop, and trigger some signals.

Constructor & Destructor Documentation

AlgAudio::SCLangSubprocess::SCLangSubprocess ( std::string  command)

Prepares to launch sclang with the given command. The process will not be started in the constructor.

See also
Start
AlgAudio::SCLangSubprocess::~SCLangSubprocess ( )

Member Function Documentation

void AlgAudio::SCLangSubprocess::SendInstruction ( std::string  )

Sends an instruction to sclang subprocess (using its stdio).

void AlgAudio::SCLangSubprocess::SendInstruction ( std::string  instruction,
std::function< void(std::string)>  reply_action 
)

Sends an instruction to sclang subprocess (using its stdio) and triggers the reply_action with the string that sclang outputted after sending that command and before the next prompt.

void AlgAudio::SCLangSubprocess::Start ( )

Starts the managed sclang process and the subprocess I/O thread.

Warning
The thread cannot be started in the constructor. See https://rafalcieslak.wordpress.com/2014/05/16/c11-stdthreads-managed-by-a-designated-class/ for details.
void AlgAudio::SCLangSubprocess::Stop ( )

Stops sclang process.

void AlgAudio::SCLangSubprocess::TriggerSignals ( )

The I/O thread may not do any UI calls. They are all left for the main thread. The main thread should run the following method from time to time, it fires all signals that should. This way all subscribers are run by the main thread.

Member Data Documentation

Signal<std::string> AlgAudio::SCLangSubprocess::on_any_line_received
Signal AlgAudio::SCLangSubprocess::on_started

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