NSCL DDAS 12.2-009
Support for XIA DDAS at FRIB
Public Member Functions | Protected Member Functions | List of all members
CTclCommand Class Referenceabstract

#include <CTclCommand.h>

Inheritance diagram for CTclCommand:
Inheritance graph
[legend]

Public Member Functions

 CTclCommand (Tcl_Interp *pInterp, const char *cmdName)
 
virtual ~CTclCommand ()
 
virtual int operator() (std::vector< Tcl_Obj * > &argv)=0
 

Protected Member Functions

Tcl_Interp * getInterpreter ()
 
void requireExactly (std::vector< Tcl_Obj * > &objv, int nParams)
 
void requireAtMost (std::vector< Tcl_Obj * > &objv, int max)
 
void setResult (const char *result)
 
void setResult (Tcl_Obj *result)
 
void setResult (double value)
 
void setResult (int value)
 
int getInteger (Tcl_Obj *intObj)
 
double getDouble (Tcl_Obj *dblObj)
 

Detailed Description

This class is a light weight replacement for CTCLObjectCommand. in this project we don't have the libtcl++ library available but this makes object oriented command handlers somewhat simpler.

Constructor & Destructor Documentation

◆ CTclCommand()

CTclCommand::CTclCommand ( Tcl_Interp *  pInterp,
const char *  cmdName 
)

constructor

Parameters
pInterpInterpreter on which the command is registered.
cmdNameCommand name string.
Note
The client data will be a pointer to this object so that the static commandRelay method actually registered as the command handler can invoke operator().
We assume the registration works.

◆ ~CTclCommand()

CTclCommand::~CTclCommand ( )
virtual

destructor unregisters the command

Member Function Documentation

◆ getDouble()

double CTclCommand::getDouble ( Tcl_Obj *  dblObj)
protected

getDouble Get a double value from an object.

Parameters
dblObj- the object.
Returns
double - the value.
Exceptions
std::stringif the object does not have double rep.

◆ getInteger()

int CTclCommand::getInteger ( Tcl_Obj *  obj)
protected

getInteger Get an integer value from an object.

Parameters
objthe object.
Returns
int the value.
Exceptions
std::stringif the object does not have a valid integer.

◆ getInterpreter()

Tcl_Interp * CTclCommand::getInterpreter ( )
inlineprotected

◆ operator()()

virtual int CTclCommand::operator() ( std::vector< Tcl_Obj * > &  argv)
pure virtual

◆ requireAtMost()

void CTclCommand::requireAtMost ( std::vector< Tcl_Obj * > &  objv,
int  max 
)
protected

requireAtMost Require at most a specified number of command words.

Parameters
objv- the command words.
max- maximum number of words allowed.
Exceptions
std::stringerror message if there are too many params.

◆ requireExactly()

void CTclCommand::requireExactly ( std::vector< Tcl_Obj * > &  objv,
int  nParams 
)
protected

requireExactly Require an exact parameter count.

Parameters
objv- the parameter vector.
nParams- number required.
Exceptions
std::stringerror message if there's not a match.

◆ setResult() [1/4]

void CTclCommand::setResult ( const char *  result)
protected

setResult (String) Given a string, sets the Tcl intepreter result to it.

Parameters
resultthe string

◆ setResult() [2/4]

void CTclCommand::setResult ( double  value)
protected

setREsult (double)

◆ setResult() [3/4]

void CTclCommand::setResult ( int  value)
protected

◆ setResult() [4/4]

void CTclCommand::setResult ( Tcl_Obj *  obj)
protected

setResult (Tcl_Obj*)


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