Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::TclBind Class Reference

A wrapper class for a Tcl interpreter. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/command/TclBind.h>

Inheritance diagram for orxonox::TclBind:
orxonox::Singleton< TclBind >

Public Member Functions

 TclBind (const std::string &datapath)
 Constructor: Initializes the Tcl-interpreter with a given data path. More...
 
 ~TclBind ()
 Destructor: Deletes the Tcl-interpreter. More...
 
const std::string & getTclDataPath () const
 Returns the path to the Orxonox-specific Tcl-files. More...
 
Tcl::interpreter * getTclInterpreter () const
 Returns the Tcl-interpreter. More...
 
void initializeTclInterpreter ()
 Creates and initializes the Tcl-interpreter by registering all callbacks and defining some useful functions. More...
 
void setDataPath (const std::string &datapath)
 Defines the path to the directory that contains the Orxonox-specific Tcl-files and initializes the Tcl-interpreter accordingly. More...
 

Static Public Member Functions

static void bgerror (const std::string &error)
 Console command and implementation of the Tcl-feature "bgerror" which is called if an error occurred in the background of a Tcl-script. More...
 
static Tcl::interpreter * createTclInterpreter ()
 Creates and initializes a new Tcl-interpreter and calls the Orxonox-specific init.tcl script that defines some special functions which are required by Orxonox. More...
 
static std::string eval (const std::string &tclcode, int *error=nullptr)
 Executes Tcl-code and returns the return-value. More...
 
static std::string getTclLibraryPath ()
 Returns the path to the Tcl-library (not the Orxonox-specific Tcl-files). More...
 
static std::string tcl (const std::string &tclcode)
 Console command, executes Tcl code. More...
 
static void tcl_execute (Tcl::object const &args)
 Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor. More...
 
static std::string tcl_query (Tcl::object const &args)
 Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor and to send its result back to Tcl. More...
 
- Static Public Member Functions inherited from orxonox::Singleton< TclBind >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static TclBindgetInstance ()
 Returns a reference to the singleton instance. More...
 

Private Member Functions

 TclBind (const TclBind &)=delete
 
TclBindoperator= (const TclBind &)=delete
 

Static Private Member Functions

static std::string tcl_helper (Tcl::object const &args, bool bQuery)
 Helper function, used by tcl_query() and tcl_execute(). More...
 

Private Attributes

bool bSetTclDataPath_
 True if tclDataPath_ was defined (after a call to setDataPath()) More...
 
Tcl::interpreter * interpreter_
 The wrapped Tcl interpreter. More...
 
std::string tclDataPath_
 The path to the directory that contains the Orxonox-specific Tcl-files. More...
 

Static Private Attributes

static TclBindsingletonPtr_s = nullptr
 The singleton pointer. More...
 

Friends

class Singleton< TclBind >
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::Singleton< TclBind >
 Singleton ()
 Constructor sets the singleton instance pointer. More...
 
virtual ~Singleton ()
 Destructor resets the singleton instance pointer. More...
 

Detailed Description

A wrapper class for a Tcl interpreter.

Used to execute Tcl commands.

TclBind is used to execute Tcl commands, for example if sent to CommandExecutor::execute(). It also defines different callbacks for Tcl, which allows to combine Orxonox-console-commands and Tcl-function without problems.

See also
See TclBind.h for more information and an example.

Constructor & Destructor Documentation

orxonox::TclBind::TclBind ( const std::string &  datapath)

Constructor: Initializes the Tcl-interpreter with a given data path.

Parameters
datapathPath to the directory that contains the Orxonox-specific Tcl-files
orxonox::TclBind::~TclBind ( )

Destructor: Deletes the Tcl-interpreter.

orxonox::TclBind::TclBind ( const TclBind )
privatedelete

Member Function Documentation

void orxonox::TclBind::bgerror ( const std::string &  error)
static

Console command and implementation of the Tcl-feature "bgerror" which is called if an error occurred in the background of a Tcl-script.

Tcl::interpreter * orxonox::TclBind::createTclInterpreter ( )
static

Creates and initializes a new Tcl-interpreter and calls the Orxonox-specific init.tcl script that defines some special functions which are required by Orxonox.

std::string orxonox::TclBind::eval ( const std::string &  tclcode,
int *  error = nullptr 
)
static

Executes Tcl-code and returns the return-value.

Parameters
tclcodeA string that contains Tcl-code
errorA pointer to an integer (or nullptr) that is used to write an error-code (see CommandExecutor error codes)
Returns
Returns the return-value of the executed code (or an empty string if there's no return-value)
const std::string& orxonox::TclBind::getTclDataPath ( ) const
inline

Returns the path to the Orxonox-specific Tcl-files.

Tcl::interpreter* orxonox::TclBind::getTclInterpreter ( ) const
inline

Returns the Tcl-interpreter.

std::string orxonox::TclBind::getTclLibraryPath ( )
static

Returns the path to the Tcl-library (not the Orxonox-specific Tcl-files).

void orxonox::TclBind::initializeTclInterpreter ( )

Creates and initializes the Tcl-interpreter by registering all callbacks and defining some useful functions.

TclBind& orxonox::TclBind::operator= ( const TclBind )
privatedelete
void orxonox::TclBind::setDataPath ( const std::string &  datapath)

Defines the path to the directory that contains the Orxonox-specific Tcl-files and initializes the Tcl-interpreter accordingly.

std::string orxonox::TclBind::tcl ( const std::string &  tclcode)
static

Console command, executes Tcl code.

Can be used to bind Tcl-commands to a key, because native Tcl-commands can not be evaluated and are thus not supported by the key-binder.

void orxonox::TclBind::tcl_execute ( Tcl::object const &  args)
static

Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor.

std::string orxonox::TclBind::tcl_helper ( Tcl::object const &  args,
bool  bQuery 
)
staticprivate

Helper function, used by tcl_query() and tcl_execute().

std::string orxonox::TclBind::tcl_query ( Tcl::object const &  args)
static

Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor and to send its result back to Tcl.

Friends And Related Function Documentation

friend class Singleton< TclBind >
friend

Member Data Documentation

bool orxonox::TclBind::bSetTclDataPath_
private

True if tclDataPath_ was defined (after a call to setDataPath())

Tcl::interpreter* orxonox::TclBind::interpreter_
private

The wrapped Tcl interpreter.

TclBind * orxonox::TclBind::singletonPtr_s = nullptr
staticprivate

The singleton pointer.

std::string orxonox::TclBind::tclDataPath_
private

The path to the directory that contains the Orxonox-specific Tcl-files.


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