Nymph  v1.5.2
Flow-Based Data Processing Framework
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
KTProcessorToolbox Class Reference

Manages processors requested by the user at run time. More...

#include <KTProcessorToolbox.hh>

Inheritance diagram for KTProcessorToolbox:
Inheritance graph

Classes

struct  CompareThread
 
struct  ProcessorInfo
 
struct  Thread
 

Public Member Functions

 KTProcessorToolbox (const std::string &name="processor-toolbox")
 
virtual ~KTProcessorToolbox ()
 
bool Configure (const scarab::param_node &node)
 Configure the toolbox: create the processors; connnect signals and slots; and setup the run queue. More...
 
bool ConfigureProcessors (const scarab::param_node &node)
 Configure processors (only those specified in the toolbox) More...
 
bool ConfigureProcessors (const std::string &config)
 Configure processors from a json-encoding of their configurations. More...
 
bool Run ()
 
KTProcessorGetProcessor (const std::string &procName)
 Get a pointer to a processor in the toolbox. More...
 
const KTProcessorGetProcessor (const std::string &procName) const
 Get a pointer to a processor in the toolbox. More...
 
bool AddProcessor (const std::string &procName, KTProcessor *proc)
 
bool AddProcessor (const std::string &procType, const std::string &procName)
 
bool RemoveProcessor (const std::string &procName)
 Remove a processor from the toolbox. More...
 
KTProcessorReleaseProcessor (const std::string &procName)
 
void ClearProcessors ()
 
bool MakeConnection (const std::string &signal, const std::string &slot, int order=std::numeric_limits< int >::min())
 
bool MakeConnection (const std::string &signalProcName, const std::string &signalName, const std::string &slotProcName, const std::string &slotName, int order=std::numeric_limits< int >::min())
 
bool PushBackToRunQueue (const std::string &name)
 Push a single processor to the back of the run queue. More...
 
bool PushBackToRunQueue (std::initializer_list< std::string > names)
 Push a set of processors to be run in parallel to the back of the run queue. More...
 
bool PushBackToRunQueue (std::vector< std::string > names)
 Push a set of processors to be run in parallel to the back of the run queue. More...
 
void PopBackOfRunQueue ()
 Remove the last item in the run queue, whether it's a single processor or a group of processors. More...
 
void ClearRunQueue ()
 Clear the run queue. More...
 
- Public Member Functions inherited from KTConfigurable
 KTConfigurable (const std::string &name="default-name")
 
virtual ~KTConfigurable ()
 
bool Configure (const std::string &config)
 Implement the option for calling Configure without passing a parameter store node. More...
 
const std::string & GetConfigName () const
 
void SetConfigName (const std::string &name)
 

Private Types

typedef std::map< std::string, ProcessorInfoProcessorMap
 
typedef ProcessorMap::iterator ProcMapIt
 
typedef ProcessorMap::const_iterator ProcMapCIt
 
typedef ProcessorMap::value_type ProcMapValue
 
typedef std::set< Thread, CompareThreadThreadGroup
 
typedef std::deque< ThreadGroupRunQueue
 

Private Member Functions

bool ParseSignalSlotName (const std::string &toParse, std::string &nameOfProc, std::string &nameOfSigSlot) const
 
bool AddProcessorToThreadGroup (const std::string &name, ThreadGroup &group)
 

Private Attributes

ProcessorMap fProcMap
 
RunQueue fRunQueue
 

Static Private Attributes

static const char fSigSlotNameSep = ':'
 

Additional Inherited Members

- Protected Attributes inherited from KTConfigurable
KTCommandLineHandlerfCLHandler
 
std::string fConfigName
 

Detailed Description

Manages processors requested by the user at run time.

Author
N. S. Oblath

KTProcessorToolbox allows the user to setup an application at runtime.

The user chooses the processors to be used, how they're linked with signals and slots, and what is used to "run" the program via a configuration file.

While this does result in longer configuration files, it drastically simplifies the space of executables that are needed.

The following order should be used for configuring the processor toolbox:

  1. Create processors
  2. Connect signals and slots
  3. Create the run queue

Available (nested) configuration values:

Definition at line 71 of file KTProcessorToolbox.hh.

Member Typedef Documentation

◆ ProcessorMap

typedef std::map< std::string, ProcessorInfo > ProcessorMap
private

Definition at line 98 of file KTProcessorToolbox.hh.

◆ ProcMapCIt

typedef ProcessorMap::const_iterator ProcMapCIt
private

Definition at line 100 of file KTProcessorToolbox.hh.

◆ ProcMapIt

typedef ProcessorMap::iterator ProcMapIt
private

Definition at line 99 of file KTProcessorToolbox.hh.

◆ ProcMapValue

typedef ProcessorMap::value_type ProcMapValue
private

Definition at line 101 of file KTProcessorToolbox.hh.

◆ RunQueue

typedef std::deque< ThreadGroup > RunQueue
private

Definition at line 176 of file KTProcessorToolbox.hh.

◆ ThreadGroup

typedef std::set< Thread, CompareThread > ThreadGroup
private

Definition at line 175 of file KTProcessorToolbox.hh.

Constructor & Destructor Documentation

◆ KTProcessorToolbox()

KTProcessorToolbox ( const std::string &  name = "processor-toolbox")

Definition at line 31 of file KTProcessorToolbox.cc.

◆ ~KTProcessorToolbox()

~KTProcessorToolbox ( )
virtual

Definition at line 38 of file KTProcessorToolbox.cc.

Member Function Documentation

◆ AddProcessor() [1/2]

bool AddProcessor ( const std::string &  procName,
KTProcessor proc 
)

Add a processor to the toolbox Toolbox takes ownership of the processor

Definition at line 321 of file KTProcessorToolbox.cc.

◆ AddProcessor() [2/2]

bool AddProcessor ( const std::string &  procType,
const std::string &  procName 
)

Definition at line 336 of file KTProcessorToolbox.cc.

◆ AddProcessorToThreadGroup()

bool AddProcessorToThreadGroup ( const std::string &  name,
ThreadGroup group 
)
private

Definition at line 513 of file KTProcessorToolbox.cc.

◆ ClearProcessors()

void ClearProcessors ( )

Remove all processors from the toolbox Also clears the run queue

Definition at line 386 of file KTProcessorToolbox.cc.

◆ ClearRunQueue()

void ClearRunQueue ( )
inline

Clear the run queue.

Definition at line 189 of file KTProcessorToolbox.hh.

◆ Configure()

bool Configure ( const scarab::param_node &  node)
virtual

Configure the toolbox: create the processors; connnect signals and slots; and setup the run queue.

Implements KTConfigurable.

Definition at line 43 of file KTProcessorToolbox.cc.

◆ ConfigureProcessors() [1/2]

bool ConfigureProcessors ( const scarab::param_node &  node)

Configure processors (only those specified in the toolbox)

Definition at line 212 of file KTProcessorToolbox.cc.

◆ ConfigureProcessors() [2/2]

bool ConfigureProcessors ( const std::string &  config)

Configure processors from a json-encoding of their configurations.

Definition at line 252 of file KTProcessorToolbox.cc.

◆ GetProcessor() [1/2]

KTProcessor * GetProcessor ( const std::string &  procName)

Get a pointer to a processor in the toolbox.

Definition at line 299 of file KTProcessorToolbox.cc.

◆ GetProcessor() [2/2]

const KTProcessor * GetProcessor ( const std::string &  procName) const

Get a pointer to a processor in the toolbox.

Definition at line 310 of file KTProcessorToolbox.cc.

◆ MakeConnection() [1/2]

bool MakeConnection ( const std::string &  signal,
const std::string &  slot,
int  order = std::numeric_limits< int >::min() 
)

Make a connection between the signal from one processor and the slot from another processor Both processors should already have been added to the Toolbox Signal and slot strings should be formatted as: [processor name]:[signal/slot name]

Definition at line 398 of file KTProcessorToolbox.cc.

◆ MakeConnection() [2/2]

bool MakeConnection ( const std::string &  signalProcName,
const std::string &  signalName,
const std::string &  slotProcName,
const std::string &  slotName,
int  order = std::numeric_limits< int >::min() 
)

Make a connection between the signal from one processor and the slot from another processor Both processors should already have been added to the Toolbox

Definition at line 417 of file KTProcessorToolbox.cc.

◆ ParseSignalSlotName()

bool ParseSignalSlotName ( const std::string &  toParse,
std::string &  nameOfProc,
std::string &  nameOfSigSlot 
) const
private

Definition at line 456 of file KTProcessorToolbox.cc.

◆ PopBackOfRunQueue()

void PopBackOfRunQueue ( )
inline

Remove the last item in the run queue, whether it's a single processor or a group of processors.

Definition at line 183 of file KTProcessorToolbox.hh.

◆ PushBackToRunQueue() [1/3]

bool PushBackToRunQueue ( const std::string &  name)

Push a single processor to the back of the run queue.

Definition at line 470 of file KTProcessorToolbox.cc.

◆ PushBackToRunQueue() [2/3]

bool PushBackToRunQueue ( std::initializer_list< std::string >  names)

Push a set of processors to be run in parallel to the back of the run queue.

◆ PushBackToRunQueue() [3/3]

bool PushBackToRunQueue ( std::vector< std::string >  names)

Push a set of processors to be run in parallel to the back of the run queue.

Definition at line 491 of file KTProcessorToolbox.cc.

◆ ReleaseProcessor()

KTProcessor * ReleaseProcessor ( const std::string &  procName)

Remove a processor from the toolbox and return it to the user Ownership is passed to the user

Definition at line 373 of file KTProcessorToolbox.cc.

◆ RemoveProcessor()

bool RemoveProcessor ( const std::string &  procName)

Remove a processor from the toolbox.

Definition at line 361 of file KTProcessorToolbox.cc.

◆ Run()

bool Run ( )

Process the run queue. This will call Run() on all of the processors in the queue.

Definition at line 260 of file KTProcessorToolbox.cc.

Member Data Documentation

◆ fProcMap

ProcessorMap fProcMap
private

Definition at line 126 of file KTProcessorToolbox.hh.

◆ fRunQueue

RunQueue fRunQueue
private

Definition at line 179 of file KTProcessorToolbox.hh.

◆ fSigSlotNameSep

const char fSigSlotNameSep = ':'
staticprivate

Definition at line 141 of file KTProcessorToolbox.hh.


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