Instruction Class Reference
[libipsaViewer classesIPSRV remote instructions]

Parent class of all IPSRV instructions. More...

#include <Instruction.h>

Inheritance diagram for Instruction:

Inheritance graph
[legend]
Collaboration diagram for Instruction:

Collaboration graph
[legend]

List of all members.

Public Types


Public Member Functions

bool findAndExecute (std::vector< std::string > &instr, std::ostringstream &answer, unsigned int &numberOfReturnValues)
std::string getCmdHelpString ()
std::string getCmdString ()
unsigned int getCommandParameterCount ()
 Instruction (const std::string &code)
virtual ~Instruction ()

Static Public Member Functions

template<typename T >
static std::map< std::string,
std::string > 
GetAllNodesOfTypeFromViewer (IpsaSimulator *simulator)
template<typename T >
static T GetNodeOfTypeByName (const std::string &name)

Protected Member Functions

virtual tExecResultType vExecute (std::vector< std::string > &Instr, std::ostringstream &answer, unsigned int &numberOfReturnValues)

Protected Attributes

const std::string I_CODE
std::vector< std::string > instrdata


Detailed Description

Parent class of all IPSRV instructions.

Every instruction available for IPSRV is a subclass of Instruction. All instructions are stored in $(IPSA_HOME)/include/IPSA/viewer/instructions and $(IPSA_HOME)/source/viewer/instructions.

See How to create new IPSRV instructions on how to create new IPSRV instructions.

Definition at line 39 of file Instruction.h.


Member Enumeration Documentation

Enumerator:
eOK 
eUNKNOWN_ERROR 
eJOINT_NOT_FOUND 
eBODY_NOT_FOUND 
eJOINT_TYPE_INCOMPATIBLE 
eNODE_IS_NOT_A_BODY 
eNO_ODE_BODY_FOUND 
eBAD_FILENAME 

Definition at line 46 of file Instruction.h.


Constructor & Destructor Documentation

Instruction::Instruction ( const std::string &  code  ) 

Parameters:
code name and parameters of the IPSRV command of format "commandName <parameter1> <parameter2> ... <parameterN>"

Definition at line 151 of file Instruction.cpp.

References I_CODE, and instrdata.

virtual Instruction::~Instruction (  )  [inline, virtual]

Definition at line 43 of file Instruction.h.


Member Function Documentation

bool Instruction::findAndExecute ( std::vector< std::string > &  instr,
std::ostringstream &  answer,
unsigned int &  numberOfReturnValues 
)

Checks if there are enough parameter values and then calls Instruction::vExecute().

Parameters:
instr vector of strings where instr[0] is the command name and the rest are the parameter values
answer stringstream where the answer of the command gets written to
numberOfReturnValues stores the number expected return values
Returns:
true if the command was executed successfully and false otherwise

Definition at line 183 of file Instruction.cpp.

References eBODY_NOT_FOUND, eJOINT_NOT_FOUND, eJOINT_TYPE_INCOMPATIBLE, eNODE_IS_NOT_A_BODY, eOK, eUNKNOWN_ERROR, instrdata, and vExecute().

Referenced by IpsaDialog::getSetValue().

template<typename T >
std::map< std::string, std::string > Instruction::GetAllNodesOfTypeFromViewer ( IpsaSimulator simulator  )  [inline, static]

Definition at line 83 of file Instruction.h.

References IpsaSimulator::getSceneGraph().

std::string Instruction::getCmdHelpString (  ) 

Returns:
the full help string of the command including parameter hints (that is Instruction::I_CODE)

Definition at line 235 of file Instruction.cpp.

References I_CODE.

Referenced by ViewerHelp::vExecute().

std::string Instruction::getCmdString (  ) 

Returns:
the name of the command as string (Instruction::instrdata[0])

Definition at line 225 of file Instruction.cpp.

References instrdata.

Referenced by NVInstructions::AddEntry().

unsigned int Instruction::getCommandParameterCount (  ) 

Returns:
number of parameters needed by the command (Instruction::instrdata[0] - 1)

Definition at line 244 of file Instruction.cpp.

References instrdata.

Referenced by IpsaDialog::getSetValue().

template<typename T >
Instruction::GetNodeOfTypeByName ( const std::string &  name  )  [inline, static]

Calls SoNode::getByName() and returns a pointer which is dynamic_cast'ed to type T.

Template Parameters:
T the type into which the found node should be cast to
Parameters:
name name of the node to find.
Returns:
NULL if node was not found or not of type T and a pointer to the node of type T otherwise

Definition at line 76 of file Instruction.h.

Instruction::vExecute ( std::vector< std::string > &  Instr,
std::ostringstream &  answer,
unsigned int &  numberOfReturnValues 
) [inline, protected, virtual]

Virtual method which must be overridden by any subclass. It does the "real" execution of the command and is called by Instruction::findAndExecute().

Parameters:
Instr instruction vector which is build like Instruction::instrdata of the specific subclass of Instruction
answer a stringstream where the answer of Instruction::vExecute() gets written to
numberOfReturnValues tells the method how many values should be stored in answer.
Returns:
a value from the enum Instruction::tExecResultType

Reimplemented in GetBodyForce, GetBodyPosition, GetBodyRotation, GetBodyTorque, GetJointAngle, GetJointAngleRate, GetJointForce, GetJointPosition, GetJointPositionRate, GetJointTorque, ListAllBodies, ListAllJoints, ListBody2BodyContacts, ListBody2BodyForces, ListBodyContacts, QuitViewer, RemoveJoint, ResetIPSA, ResetViewer, SaveIVFile, ScheduleIPSA, SetBodyForce, SetBodyRelForce, SetBodyVelocity, SetDrawShape, SetJointForce, SetJointMaxForce, SetJointMaxForce2, SetJointSpeed, SetJointSpeed2, SetJointTorque, SetJointTorque2, SetStepsizeIPSA, SetVerbosity, ShowJoints, StepIPSA, UnscheduleIPSA, and ViewerHelp.

Definition at line 71 of file Instruction.h.

Referenced by findAndExecute().


Member Data Documentation

Instruction::I_CODE [protected]

One string which contains the name and parameters of the IPSRV command. The string is of the following format "commandName <parameter1> <parameter2> ... <parameterN>".

Definition at line 69 of file Instruction.h.

Referenced by getCmdHelpString(), and Instruction().

The parsed Instruction::I_CODE is stored in here and has the following format:
Instruction::instrdata[0] = "commandName"
Instruction::instrdata[1] = "parameter1"
Instruction::instrdata[2] = "parameter2"
...
Instruction::instrdata[N] = "parameterN"

Definition at line 70 of file Instruction.h.

Referenced by findAndExecute(), getCmdString(), getCommandParameterCount(), and Instruction().


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

Get IPSA - Inventor Physics Simulation API at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated on Sat Mar 10 20:00:19 2012 for IPSA by  doxygen 1.5.8