This class implements the first level interpretor to control basic functionnalities of the plugins. More...
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 PluginLoader * | sotPluginLoaderPTR |
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. |
This class implements the first level interpretor to control basic functionnalities of the plugins.
It provides a shell allowing to :
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:
dynamicgraph::Interpreter::Interpreter | ( | PluginLoader * | dlPtr = NULL |
) |
Default constructor.
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.
void dynamicgraph::Interpreter::shell | ( | std::istream & | sin, | |
std::ostream & | sout, | |||
const std::string & | prompt = "" | |||
) |
Method to start the shell.
void dynamicgraph::Interpreter::writeCompletionList | ( | std::ostream & | os | ) |
The plugin loader.
FunctionMap dynamicgraph::Interpreter::functionMap [protected] |
Instance of this type.
bool dynamicgraph::Interpreter::initDone [protected] |
std::string dynamicgraph::Interpreter::prompt |
const std::string dynamicgraph::Interpreter::PROMPT_DEFAULT [static] |