tcl::command Class Reference

#include <tcl/command.h>

Collaboration diagram for tcl::command:
Collaboration graph
[legend]

List of all members.

Classes

class  impl

Public Member Functions

 command (rutz::shared_ptr< tcl::function > callback, const char *usage, const arg_spec &spec)
 Build a tcl::command object.
 ~command () throw ()
 Non-virtual destructor since this class is not for use as a base class.
rutz::fstring usage_string () const
 Returns a string describing the arguments expected by this command.
bool allows_argc (unsigned int objc) const
 Check if the given argument count is acceptable.
bool rejects_argc (unsigned int objc) const
 Check if the given argument count is unacceptable.
void call (tcl::interpreter &interp, unsigned int objc, Tcl_Obj *const objv[])
 Send arguments to its tcl::function via its tcl::arg_dispatcher.
rutz::shared_ptr< arg_dispatcherget_dispatcher () const
 Get the current tcl::arg_dispatcher for this command.
void set_dispatcher (rutz::shared_ptr< arg_dispatcher > dpx)
 Change the tcl::arg_dispatcher for this command.

Detailed Description

tcl::command provides a way to wrap Tcl commands in C++ classes. The tcl::command class itself takes care of such things as checking the argument count, and issuing an error message if the argument count is incorrect.

tcl::command uses class tcl::call_context to represent the set of Tcl command arguments and the interpreter's result.

If more than one tcl::command is created with the same name, an overloading sequence is created. Overloading is done by argument counts. The first tcl::command in an overload sequence to match the argument count of the context will be used.

Most clients of tcl::command will be able to simply use tcl::make_command() or tcl::make_vec_command(), which detect the types of C++ functions and build generic tcl::command's that call the functions appropriately, or use tcl::pkg::def() and related functions, which call tcl::make_command() but in addition help to relate the commands to a particular package.

Definition at line 102 of file command.h.


Constructor & Destructor Documentation

tcl::command::command ( rutz::shared_ptr< tcl::function callback,
const char *  usage,
const arg_spec spec 
)

Build a tcl::command object.

BUT, you almost certainly don't want to use this function directly, but should instead call tcl::command_group::make(). If you just create a tcl::command on its own, it won't do anything (it won't be registered with the tcl interpreter). The tcl::command needs to be hooked into a tcl::command_group, and the way to do that is by creating it through tcl::command_group::make().

Definition at line 128 of file command.cc.

tcl::command::~command (  )  throw ()

Non-virtual destructor since this class is not for use as a base class.

Definition at line 136 of file command.cc.


Member Function Documentation

bool tcl::command::allows_argc ( unsigned int  objc  )  const

Check if the given argument count is acceptable.

Definition at line 143 of file command.cc.

Referenced by rejects_argc().

void tcl::command::call ( tcl::interpreter interp,
unsigned int  objc,
Tcl_Obj *const   objv[] 
)

Send arguments to its tcl::function via its tcl::arg_dispatcher.

Definition at line 168 of file command.cc.

shared_ptr< tcl::arg_dispatcher > tcl::command::get_dispatcher (  )  const

Get the current tcl::arg_dispatcher for this command.

Definition at line 174 of file command.cc.

bool tcl::command::rejects_argc ( unsigned int  objc  )  const

Check if the given argument count is unacceptable.

Definition at line 149 of file command.cc.

References allows_argc().

void tcl::command::set_dispatcher ( rutz::shared_ptr< arg_dispatcher dpx  ) 

Change the tcl::arg_dispatcher for this command.

Definition at line 180 of file command.cc.

rutz::fstring tcl::command::usage_string (  )  const

Returns a string describing the arguments expected by this command.

Definition at line 154 of file command.cc.

References rutz::fstring::c_str(), and rutz::sfmt().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:31:33 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3