Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Attributes

dynamicgraph::Interpreter Class Reference
[Core classes and objects]

This class implements the first level interpretor to control basic functionnalities of the plugins. More...

Collaboration diagram for dynamicgraph::Interpreter:
Collaboration graph
[legend]

List of all members.

Public Types

typedef boost::function3< void,
const std::string
&, std::istringstream
&, std::ostream & > 
ShellBasicFunction
 Type of a basic function for the shell. Such function returns a void and takes 3 arguments:
typedef PluginLoadersotPluginLoaderPTR

Public Member Functions

 Interpreter (PluginLoader *dlPtr=NULL)
 Default constructor.
void registerFunction (const std::string &funname, const ShellBasicFunction &fun)
 Register a function at the upper level of the shell.
bool deregisterFunction (const std::string &funname)
void referencePluginLoader (PluginLoader *dl__)
 Set the reference of the plugin loader.
void shell (std::istream &sin, std::ostream &sout, const std::string &prompt="")
 Method to start the shell.
void writeCompletionList (std::ostream &os)

Public Attributes

sotPluginLoaderPTR dlPtr
 The plugin loader.
std::string prompt

Static Public Attributes

static const std::string PROMPT_DEFAULT

Protected Types

typedef std::map< std::string,
ShellBasicFunction
FunctionMap
 This type defines a sorted set of basic functions with a unique key.

Protected Attributes

FunctionMap functionMap
bool initDone

Implements the commands.



void cmdNew (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Instanciante an object Extracts the name and the class of the object, verifies it is unique, and creates the instance if this is the case.
void cmdDestroy (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Destroy the object. Extracts the name for cmdArg and destroy the object.
void cmdPlug (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Connect two signals. Connect an input signal to an output one.
void cmdLoadPlugin (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Load a dynamic library which includes a plugin. Extracts the name first and the directory in second from cmdArg to load the dynamic library.
void cmdUnloadPlugin (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Unload a dynamic library which includes a plugin. Extracts the name to unload the dynamic library.
void cmdHelp (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Ask to each register function to display its help.
void cmdRun (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Run a script.
void cmdSetSignal (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Set a signal <obj.signal> to a value with cmdArg = "<obj.signal> <value>".
void cmdGetSignal (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Display the value of the signal <obj.signal> with cmdArg = "<obj.signal>".
void cmdComputeSignal (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Compute the value of the signal <obj.signal> at time <time> with cmdArg = "<obj.signal> <time>".
void cmd (const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
 Entry point to treat a command.
static bool objectNameParser (std::istringstream &cmdparse, std::string &objName, std::string &funName)
 Extract the object name and the function name from a command.

Detailed Description

This class implements the first level interpretor to control basic functionnalities of the plugins.

It provides a shell allowing to :


Member Typedef Documentation

typedef std::map< std::string,ShellBasicFunction > dynamicgraph::Interpreter::FunctionMap [protected]

This type defines a sorted set of basic functions with a unique key.

typedef boost::function3<void,const std::string&,std::istringstream&,std::ostream&> dynamicgraph::Interpreter::ShellBasicFunction

Type of a basic function for the shell. Such function returns a void and takes 3 arguments:

  • the functionnality (i.e. the method) it provides to the shell,
  • a stream of input string to pass when called,
  • an output stream for display.

Constructor & Destructor Documentation

dynamicgraph::Interpreter::Interpreter ( PluginLoader dlPtr = NULL  ) 

Default constructor.

[in] dlPtr: a plugin loader to perform the actions provided by this shell.

Member Function Documentation

void dynamicgraph::Interpreter::cmd ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Entry point to treat a command.

void dynamicgraph::Interpreter::cmdComputeSignal ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Compute the value of the signal <obj.signal> at time <time> with cmdArg = "<obj.signal> <time>".

void dynamicgraph::Interpreter::cmdDestroy ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Destroy the object. Extracts the name for cmdArg and destroy the object.

void dynamicgraph::Interpreter::cmdGetSignal ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Display the value of the signal <obj.signal> with cmdArg = "<obj.signal>".

void dynamicgraph::Interpreter::cmdHelp ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Ask to each register function to display its help.

void dynamicgraph::Interpreter::cmdLoadPlugin ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Load a dynamic library which includes a plugin. Extracts the name first and the directory in second from cmdArg to load the dynamic library.

void dynamicgraph::Interpreter::cmdNew ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Instanciante an object Extracts the name and the class of the object, verifies it is unique, and creates the instance if this is the case.

void dynamicgraph::Interpreter::cmdPlug ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Connect two signals. Connect an input signal to an output one.

void dynamicgraph::Interpreter::cmdRun ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Run a script.

void dynamicgraph::Interpreter::cmdSetSignal ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Set a signal <obj.signal> to a value with cmdArg = "<obj.signal> <value>".

void dynamicgraph::Interpreter::cmdUnloadPlugin ( const std::string &  cmdLine,
std::istringstream &  cmdArg,
std::ostream &  os 
)

Unload a dynamic library which includes a plugin. Extracts the name to unload the dynamic library.

bool dynamicgraph::Interpreter::deregisterFunction ( const std::string &  funname  ) 
static bool dynamicgraph::Interpreter::objectNameParser ( std::istringstream &  cmdparse,
std::string &  objName,
std::string &  funName 
) [static]

Extract the object name and the function name from a command.

void dynamicgraph::Interpreter::referencePluginLoader ( PluginLoader dl__  )  [inline]

Set the reference of the plugin loader.

void dynamicgraph::Interpreter::registerFunction ( const std::string &  funname,
const ShellBasicFunction fun 
)

Register a function at the upper level of the shell.

[in] funname: The function's name,
[in] fun: The pointer to the function.
void dynamicgraph::Interpreter::shell ( std::istream &  sin,
std::ostream &  sout,
const std::string &  prompt = "" 
)

Method to start the shell.

[in] sin: The input stream from which the command will be extracted.
[out] sout: The output stream to which the result will be displayed.
[in] prompt: The prompt to be displayed.
void dynamicgraph::Interpreter::writeCompletionList ( std::ostream &  os  ) 

Member Data Documentation

The plugin loader.

Instance of this type.

const std::string dynamicgraph::Interpreter::PROMPT_DEFAULT [static]




dynamicGraph library documentation