openrave.org

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
OpenRAVE::InterfaceBase Class Referenceabstract

[interface] Base class for all interfaces that OpenRAVE provides. See Base Interface Concepts. More...

#include <interface.h>

Inheritance diagram for OpenRAVE::InterfaceBase:
Inheritance graph
[legend]
Collaboration diagram for OpenRAVE::InterfaceBase:
Collaboration graph
[legend]

Classes

class  InterfaceCommand
 

Public Types

typedef std::map< std::string,
XMLReadablePtr,
CaseInsensitiveCompare
READERSMAP
 

Public Member Functions

 InterfaceBase (InterfaceType type, EnvironmentBasePtr penv)
 
virtual ~InterfaceBase ()
 
InterfaceType GetInterfaceType () const
 
const std::string & GetXMLId () const
 
const std::string & GetPluginName () const
 
EnvironmentBasePtr GetEnv () const
 
const READERSMAPGetReadableInterfaces () const
 Returns the raw map reference, this is not multithread safe and the GetInterfaceMutex should be locked before using.
 
virtual XMLReadablePtr GetReadableInterface (const std::string &xmltag) const
 Returns the readable interface. [multi-thread safe]
 
virtual XMLReadablePtr SetReadableInterface (const std::string &xmltag, XMLReadablePtr readable)
 Set a new readable interface and return the previously set interface if it exists. [multi-thread safe]
 
virtual const std::string & GetDescription () const
 Documentation of the interface in reStructuredText format. See Documenting Interfaces. [multi-thread safe]
 
virtual void SetDescription (const std::string &description)
 sets a description [multi-thread safe]
 
virtual void SetUserData (const std::string &key, UserDataPtr data) const
 set user data for a specific key. [multi-thread safe]
 
virtual UserDataPtr GetUserData (const std::string &key=std::string()) const
 return the user custom data [multi-thread safe]
 
virtual bool RemoveUserData (const std::string &key) const
 removes a user data pointer. if user data pointer does not exist, then return 0, otherwise 1. [multi-thread safe]
 
virtual void SetUserData (UserDataPtr data) RAVE_DEPRECATED
 
virtual const std::string & GetURI () const
 the URI used to load the interface (sometimes this is not possible if the definition lies inside an environment file). [multi-thread safe]
 
virtual const std::string & GetXMLFilename () const
 
virtual void Clone (InterfaceBaseConstPtr preference, int cloningoptions)
 Clone the contents of an interface to the current interface.
 
virtual bool SendCommand (std::ostream &os, std::istream &is)
 Used to send special commands to the interface and receive output.
 
virtual void Serialize (BaseXMLWriterPtr writer, int options=0) const
 serializes the interface
 

Protected Types

typedef boost::function< bool(std::ostream
&, std::istream &)> 
InterfaceCommandFn
 The function to be executed for every command.
 

Protected Member Functions

virtual void RegisterCommand (const std::string &cmdname, InterfaceCommandFn fncmd, const std::string &strhelp)
 Registers a command and its help string. [multi-thread safe]
 
virtual void UnregisterCommand (const std::string &cmdname)
 Unregisters the command. [multi-thread safe]
 
virtual const char * GetHash () const =0
 
virtual boost::shared_mutex & GetInterfaceMutex () const
 

Protected Attributes

std::string __description
 

Detailed Description

[interface] Base class for all interfaces that OpenRAVE provides. See Base Interface Concepts.

Definition at line 42 of file interface.h.

Member Typedef Documentation

typedef boost::function<bool (std::ostream&, std::istream&)> OpenRAVE::InterfaceBase::InterfaceCommandFn
protected

The function to be executed for every command.

Parameters
sinput- input of the command
sout- output of the command
Returns
If false, there was an error with the command, true if successful

Definition at line 161 of file interface.h.

Definition at line 45 of file interface.h.

Constructor & Destructor Documentation

OpenRAVE::InterfaceBase::InterfaceBase ( InterfaceType  type,
EnvironmentBasePtr  penv 
)

Definition at line 20 of file interface.cpp.

OpenRAVE::InterfaceBase::~InterfaceBase ( )
virtual

Definition at line 27 of file interface.cpp.

Member Function Documentation

void OpenRAVE::InterfaceBase::Clone ( InterfaceBaseConstPtr  preference,
int  cloningoptions 
)
virtual

Clone the contents of an interface to the current interface.

Parameters
preferencethe interface whose information to clone
cloningoptionsmask of CloningOptions
Exceptions
openrave_exceptionif command doesn't succeed

Reimplemented in OpenRAVE::KinBody, OpenRAVE::RobotBase, and OpenRAVE::TrajectoryBase.

Definition at line 80 of file interface.cpp.

virtual const std::string& OpenRAVE::InterfaceBase::GetDescription ( ) const
inlinevirtual

Documentation of the interface in reStructuredText format. See Documenting Interfaces. [multi-thread safe]

Definition at line 84 of file interface.h.

EnvironmentBasePtr OpenRAVE::InterfaceBase::GetEnv ( ) const
inline
Returns
The environment that this interface is attached to. [multi-thread safe]

Definition at line 68 of file interface.h.

virtual const char* OpenRAVE::InterfaceBase::GetHash ( ) const
protectedpure virtual
virtual boost::shared_mutex& OpenRAVE::InterfaceBase::GetInterfaceMutex ( ) const
inlineprotectedvirtual
See Also
GetDescription()

Definition at line 187 of file interface.h.

InterfaceType OpenRAVE::InterfaceBase::GetInterfaceType ( ) const
inline

Definition at line 50 of file interface.h.

const std::string& OpenRAVE::InterfaceBase::GetPluginName ( ) const
inline

set internally by RaveDatabase [multi-thread safe]

Returns
the pluginname this interface was loaded from

Definition at line 63 of file interface.h.

XMLReadablePtr OpenRAVE::InterfaceBase::GetReadableInterface ( const std::string &  xmltag) const
virtual

Returns the readable interface. [multi-thread safe]

Definition at line 198 of file interface.cpp.

const READERSMAP& OpenRAVE::InterfaceBase::GetReadableInterfaces ( ) const
inline

Returns the raw map reference, this is not multithread safe and the GetInterfaceMutex should be locked before using.

Definition at line 73 of file interface.h.

virtual const std::string& OpenRAVE::InterfaceBase::GetURI ( ) const
inlinevirtual

the URI used to load the interface (sometimes this is not possible if the definition lies inside an environment file). [multi-thread safe]

Definition at line 110 of file interface.h.

UserDataPtr OpenRAVE::InterfaceBase::GetUserData ( const std::string &  key = std::string()) const
virtual

return the user custom data [multi-thread safe]

Definition at line 53 of file interface.cpp.

virtual const std::string& OpenRAVE::InterfaceBase::GetXMLFilename ( ) const
inlinevirtual

Definition at line 113 of file interface.h.

const std::string& OpenRAVE::InterfaceBase::GetXMLId ( ) const
inline

set internally by RaveDatabase [multi-thread safe]

Returns
the unique identifier that describes this class type, case is ignored should be the same id used to create the object

Definition at line 57 of file interface.h.

void OpenRAVE::InterfaceBase::RegisterCommand ( const std::string &  cmdname,
InterfaceBase::InterfaceCommandFn  fncmd,
const std::string &  strhelp 
)
protectedvirtual

Registers a command and its help string. [multi-thread safe]

Parameters
cmdname- command name, converted to lower case
fncmdfunction to execute for the command
strhelp- help string in reStructuredText, see Documenting Interfaces.
Exceptions
openrave_exceptionThrow if there exists a registered command already.

Definition at line 121 of file interface.cpp.

bool OpenRAVE::InterfaceBase::RemoveUserData ( const std::string &  key) const
virtual

removes a user data pointer. if user data pointer does not exist, then return 0, otherwise 1. [multi-thread safe]

Definition at line 63 of file interface.cpp.

bool OpenRAVE::InterfaceBase::SendCommand ( std::ostream &  os,
std::istream &  is 
)
virtual

Used to send special commands to the interface and receive output.

The command must be registered by RegisterCommand. A special command 'help' is always supported and provides a way for the user to query the current commands and the help string. The format of the returned help commands are in reStructuredText. The following commands are possible:

  • 'help [command name]' - get the help string of just that command.
  • 'help commands' - return the names of all the possible commands
Parameters
isthe input stream containing the command
osthe output stream containing the output
Exceptions
openrave_exceptionThrow if the command is not supported.
Returns
true if the command is successfully processed, otherwise false.

Definition at line 91 of file interface.cpp.

void OpenRAVE::InterfaceBase::Serialize ( BaseXMLWriterPtr  writer,
int  options = 0 
) const
virtual

serializes the interface

The readable interfaces are also serialized within the tag, for example:

<sometag> <!-- root writer -->
<interface> <!-- first child -->
<readableinterface/> <!-- readable interface -->
</interface>
</sometag>

Depending on the writer format, extra tags might be created.

Reimplemented in OpenRAVE::KinBody.

Definition at line 114 of file interface.cpp.

virtual void OpenRAVE::InterfaceBase::SetDescription ( const std::string &  description)
inlinevirtual

sets a description [multi-thread safe]

Definition at line 89 of file interface.h.

XMLReadablePtr OpenRAVE::InterfaceBase::SetReadableInterface ( const std::string &  xmltag,
XMLReadablePtr  readable 
)
virtual

Set a new readable interface and return the previously set interface if it exists. [multi-thread safe]

Definition at line 205 of file interface.cpp.

void OpenRAVE::InterfaceBase::SetUserData ( const std::string &  key,
UserDataPtr  data 
) const
virtual

set user data for a specific key. [multi-thread safe]

Because user data can be used for caching objects, it is necessary to allow functions taking const pointers of the interface can reset the pointers.

Definition at line 36 of file interface.cpp.

virtual void OpenRAVE::InterfaceBase::SetUserData ( UserDataPtr  data)
inlinevirtual
Deprecated:
(12/12/11)

Definition at line 105 of file interface.h.

void OpenRAVE::InterfaceBase::UnregisterCommand ( const std::string &  cmdname)
protectedvirtual

Unregisters the command. [multi-thread safe]

Definition at line 133 of file interface.cpp.

Member Data Documentation

std::string OpenRAVE::InterfaceBase::__description
protected

Definition at line 185 of file interface.h.


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