CLI  2.9
ExecutionContext Class Referenceabstract

Execution context. More...

#include <exec_context.h>

Inheritance diagram for ExecutionContext:

Public Member Functions

virtual ~ExecutionContext (void)
 Destructor. More...
 
ExecutionContextManagerGetContextManager (void)
 Execution context manager accessor. More...
 
const IODeviceGetInput (void) const
 Input stream accessor. More...
 
const OutputDeviceGetStream (const STREAM_TYPE E_StreamType) const
 Output stream accessor. More...
 
const bool SetStream (const STREAM_TYPE E_StreamType, OutputDevice &CLI_Stream)
 Output stream positionning. More...
 
const bool StreamEnabled (const STREAM_TYPE E_StreamType) const
 Enabled/disabled stream accessor. More...
 
const bool EnableStream (const STREAM_TYPE E_StreamType, const bool B_Enable)
 Enable/disable stream. More...
 
void SetLang (const ResourceString::LANG E_Lang)
 Language setting. More...
 
const ResourceString::LANG GetLang (void) const
 Language access. More...
 
void SetBeep (const bool B_Enable)
 Beep configuration setting. More...
 
const bool GetBeep (void) const
 Beep configuration access. More...
 
void Beep (void)
 Sends a beep signal. More...
 
void Run (IODevice &CLI_IODevice)
 Runs the execution context onto the corresponding input/output device. More...
 
void Run (void)
 Runs the execution context as a child context of the parent given by the construction. More...
 
const bool IsRunning (void) const
 Tells whether this execution context is running or not. More...
 
void StopExecution (void)
 Terminates this execution context's execution. More...
 
void StopAllExecutions (void)
 Terminates execution for all execution contexts attached to the same top execution context. More...
 
- Public Member Functions inherited from Object
virtual ~Object (void)=0
 Pure virtual destructor. More...
 

Protected Member Functions

 ExecutionContext (void)
 Top context constructor. More...
 
 ExecutionContext (ExecutionContext &CLI_ParentContext)
 Child context constructor. More...
 
virtual const bool OnStartExecution (void)=0
 Beginning of execution handler. More...
 
virtual void OnKey (const KEY E_KeyCode)=0
 Handler called on character input. More...
 
virtual const bool OnStopExecution (void)=0
 Execution termination handler. More...
 
- Protected Member Functions inherited from Object
 Object (void)
 Default constructor only available to sub-classes. More...
 

Detailed Description

Execution context.

An execution context, in the CLI library, is something that manages:

  • a set of input/output devices,
  • settings: language, beep...
  • input character processing

Input character processing

Input character processing is implemented through the Run method. It may be either blocking or non blocking depending on the type of input/output device given.

When the input/output device is a blocking device (IODevice based class), the execution is done whithin a blocking call as illustrated by the following chart:

msc_inline_mscgraph_1

When the input/output device is a non blocking device (NonBlockingIODevice based class), the ExecutionContext::Run() is non blocking, and the execution context waits for keys to be notified by the user's integration. Execution result is notified through the ExecutionResult callback interface:

msc_inline_mscgraph_2

Top and child execution contexts

An execution context may be either a top or child execution context, depending on the kind of constructor actually called. A child execution context uses the same context as its parent.

When execution takes place in a blocking call, the flow charts is straight forward:

msc_inline_mscgraph_3

When it takes place in a non blocking call, the input/output device automatically forwards input keys to the current active context:

msc_inline_mscgraph_4

Definition at line 149 of file exec_context.h.

Constructor & Destructor Documentation

◆ ExecutionContext() [1/2]

ExecutionContext::ExecutionContext ( void  )
explicitprotected

Top context constructor.

◆ ExecutionContext() [2/2]

ExecutionContext::ExecutionContext ( ExecutionContext CLI_ParentContext)
explicitprotected

Child context constructor.

Makes this execution context run in the same context as the one given for parent.

Parameters
CLI_ParentContextParent execution context.

◆ ~ExecutionContext()

virtual ExecutionContext::~ExecutionContext ( void  )
virtual

Destructor.

Member Function Documentation

◆ Beep()

void ExecutionContext::Beep ( void  )

◆ EnableStream()

const bool ExecutionContext::EnableStream ( const STREAM_TYPE  E_StreamType,
const bool  B_Enable 
)

Enable/disable stream.

Returns
true: success, false: failure.
Parameters
E_StreamTypeOutput stream identifier.
B_EnableEnable flag.

◆ GetBeep()

const bool ExecutionContext::GetBeep ( void  ) const

Beep configuration access.

Returns
The current beep configuration. true if enabled, false otherwise.

◆ GetContextManager()

ExecutionContextManager& ExecutionContext::GetContextManager ( void  )

Execution context manager accessor.

Returns
Execution context manager reference.

◆ GetInput()

const IODevice& ExecutionContext::GetInput ( void  ) const

Input stream accessor.

Returns
The input stream attached to the context for its execution.

◆ GetLang()

const ResourceString::LANG ExecutionContext::GetLang ( void  ) const

Language access.

Returns
The language currently set.

Referenced by Choice::ResetToDefault().

◆ GetStream()

const OutputDevice& ExecutionContext::GetStream ( const STREAM_TYPE  E_StreamType) const

Output stream accessor.

Returns
The required stream. null if an error occurred.
Parameters
E_StreamTypeOutput stream identifier.

Referenced by Password::OnKey(), More::OnKey(), Line::OnKey(), UI::OnStopExecution(), Password::ResetToDefault(), Less::ResetToDefault(), More::ResetToDefault(), and Line::SetLine().

◆ IsRunning()

const bool ExecutionContext::IsRunning ( void  ) const

Tells whether this execution context is running or not.

Returns
The running status.

◆ OnKey()

virtual void ExecutionContext::OnKey ( const KEY  E_KeyCode)
protectedpure virtual

Handler called on character input.

Parameters
E_KeyCodeInput key.

Implemented in Shell, Line, Less, More, Password, Choice, Float, Int, and YesNo.

◆ OnStartExecution()

virtual const bool ExecutionContext::OnStartExecution ( void  )
protectedpure virtual

Beginning of execution handler.

Returns
true for success, false otherwise.

Implemented in Shell, and UI.

◆ OnStopExecution()

virtual const bool ExecutionContext::OnStopExecution ( void  )
protectedpure virtual

Execution termination handler.

Returns
true for success, false otherwise.

Implemented in Shell, and UI.

◆ Run() [1/2]

void ExecutionContext::Run ( IODevice CLI_IODevice)

Runs the execution context onto the corresponding input/output device.

Call this runner method, for top execution contexts.

Parameters
CLI_IODeviceInput/output device to run onto.

◆ Run() [2/2]

void ExecutionContext::Run ( void  )

Runs the execution context as a child context of the parent given by the construction.

Call this runner method, for child execution contexts.

◆ SetBeep()

void ExecutionContext::SetBeep ( const bool  B_Enable)

Beep configuration setting.

Parameters
B_EnableNew value.

◆ SetLang()

void ExecutionContext::SetLang ( const ResourceString::LANG  E_Lang)

Language setting.

Parameters
E_LangNew value.

◆ SetStream()

const bool ExecutionContext::SetStream ( const STREAM_TYPE  E_StreamType,
OutputDevice CLI_Stream 
)

Output stream positionning.

Returns
true: success, false: failure.
Warning
Please ensure one of the following conditions regarding the given device:
  • Either the device is an auto-deleted device,
  • or it will be destroyed after this execution context object,
  • or another call to this method with the null device is done on termination. Otherwise you could experience consistency troubles. The null device and standard devices are not subject to this remark.
Parameters
E_StreamTypeOutput stream identifier.
CLI_StreamStream reference.

◆ StopAllExecutions()

void ExecutionContext::StopAllExecutions ( void  )

Terminates execution for all execution contexts attached to the same top execution context.

Warning
Not thread safe. Implement a non blocking device if your CLI execution should interact with external events.

◆ StopExecution()

void ExecutionContext::StopExecution ( void  )

Terminates this execution context's execution.

Warning
Not thread safe. Implement a non blocking device if your CLI execution should interact with external events.

Referenced by UI::EndControl().

◆ StreamEnabled()

const bool ExecutionContext::StreamEnabled ( const STREAM_TYPE  E_StreamType) const

Enabled/disabled stream accessor.

Returns
true: the stream is enabled, false: the stream is disabled.
Parameters
E_StreamTypeOutput stream identifier.

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