#include <TclCommand.h>
Register commands with Command::instance()->reg() or use the AutoTclCommand class.
The "set" command is automatically defined for a module. Set is used to change the value of variable which are bound using the bind_* functions defined below.
Definition at line 241 of file TclCommand.h.
Public Member Functions | |
TclCommand (const char *name, const char *theNamespace=0) | |
Constructor. | |
virtual | ~TclCommand () |
virtual int | exec (int objc, Tcl_Obj **objv, Tcl_Interp *interp) |
Override this to get the arguments as raw tcl objects. | |
virtual int | exec (int argc, const char **argv, Tcl_Interp *interp) |
Override this to parse the list of arguments as strings. | |
virtual int | cmd_info (Tcl_Interp *interp) |
Handles the "info" command which prints out the value of the bound variables for a TclCommand. | |
virtual int | cmd_set (int objc, Tcl_Obj **objv, Tcl_Interp *interp) |
Internal handling of the "set" command. | |
const char * | name () const |
Get the name of the module. | |
virtual const char * | help_string () |
Return the help string for this command. | |
bool | hasBindings () |
Does this command have any bindings? | |
Protected Types | |
typedef std::map < std::string, Opt * > | BindingTable |
Type for the table of variable bindings. | |
Protected Member Functions | |
void | bind_var (Opt *opt) |
Bind an option to the set command. | |
void | unbind (const char *name) |
Unbind a variable. | |
void | set_result (const char *result) |
Set the TclResult string. | |
void | set_objresult (Tcl_Obj *obj) |
Set a Tcl_Obj as the result. | |
void | append_result (const char *result) |
Append the TclResult string. | |
void | resultf (const char *fmt,...) |
Format and set the TclResult string. | |
void | append_resultf (const char *fmt,...) |
Format and set the TclResult string. | |
void | wrong_num_args (int objc, const char **objv, int parsed, int min, int max) |
Useful function for generating error strings indicating that the wrong number of arguments were passed to the command. | |
void | wrong_num_args (int objc, Tcl_Obj **objv, int parsed, int min, int max) |
Useful function for generating error strings indicating that the wrong number of arguments were passed to the command. | |
void | add_to_help (const char *subcmd, const char *help_str) |
Append the given information to the current help string, typically used for a set of alternatives for subcommands. | |
Protected Attributes | |
std::string | name_ |
Name of the module. | |
StringBuffer | help_ |
Help string. | |
bool | do_builtins_ |
Set to false if a module doesn't want builtin commands like "set". | |
BindingTable | bindings_ |
The table of registered bindings. | |
Friends | |
class | TclCommandInterp |
typedef std::map<std::string, Opt*> oasys::TclCommand::BindingTable [protected] |
oasys::TclCommand::TclCommand | ( | const char * | name, | |
const char * | theNamespace = 0 | |||
) |
Constructor.
name | Name of the module | |
theNamespace | Optional tcl namespace |
Definition at line 738 of file TclCommand.cc.
oasys::TclCommand::~TclCommand | ( | ) | [virtual] |
Definition at line 751 of file TclCommand.cc.
int oasys::TclCommand::exec | ( | int | objc, | |
Tcl_Obj ** | objv, | |||
Tcl_Interp * | interp | |||
) | [virtual] |
Override this to get the arguments as raw tcl objects.
objc | Argument count | |
objv | Argument values | |
interp | Tcl interpreter |
Reimplemented in dtn::BundleCommand.
Definition at line 761 of file TclCommand.cc.
int oasys::TclCommand::exec | ( | int | argc, | |
const char ** | argv, | |||
Tcl_Interp * | interp | |||
) | [virtual] |
Override this to parse the list of arguments as strings.
argc | Argument count | |
argv | Argument values | |
interp | Tcl interpreter |
Reimplemented in DTNOpenCommand, DTNCloseCommand, DTNRegisterCommand, DTNUnregisterCommand, DTNSendCommand, DTNBindCommand, DTNUnbindCommand, DTNRecvCommand, ShutdownCommand, oasys::DebugCommand, oasys::HelpCommand, oasys::LogCommand, dtn::DiscoveryCommand, dtn::InterfaceCommand, dtn::LinkCommand, dtn::ProphetCommand, dtn::RegistrationCommand, dtn::RouteCommand, dtn::ShutdownCommand, dtn::StorageCommand, dtn::TestCommand, dtnsim::ConnCommand, dtnsim::NodeCommand, dtnsim::SimCommand, and dtnsim::Simdtn2Command.
Definition at line 775 of file TclCommand.cc.
int oasys::TclCommand::cmd_info | ( | Tcl_Interp * | interp | ) | [virtual] |
Handles the "info" command which prints out the value of the bound variables for a TclCommand.
interp | Tcl interperter |
Definition at line 802 of file TclCommand.cc.
int oasys::TclCommand::cmd_set | ( | int | objc, | |
Tcl_Obj ** | objv, | |||
Tcl_Interp * | interp | |||
) | [virtual] |
Internal handling of the "set" command.
objc | Argument count | |
objv | Argument values | |
interp | Tcl interpreter |
Definition at line 819 of file TclCommand.cc.
const char* oasys::TclCommand::name | ( | ) | const [inline] |
Get the name of the module.
Definition at line 296 of file TclCommand.h.
References name_.
Referenced by add_to_help(), dtnsim::SimCommand::exec(), dtn::RouteCommand::exec(), dtnsim::NodeCommand::exec(), dtn::LinkCommand::exec(), dtn::InterfaceCommand::exec(), and dtn::DiscoveryCommand::exec().
virtual const char* oasys::TclCommand::help_string | ( | ) | [inline, virtual] |
Return the help string for this command.
Definition at line 301 of file TclCommand.h.
References oasys::StringBuffer::c_str(), and help_.
bool oasys::TclCommand::hasBindings | ( | ) | [inline] |
Does this command have any bindings?
Definition at line 306 of file TclCommand.h.
References bindings_.
void oasys::TclCommand::bind_var | ( | Opt * | opt | ) | [protected] |
Bind an option to the set command.
Definition at line 863 of file TclCommand.cc.
Referenced by dtn::APICommand::APICommand(), dtn::TestCommand::bind_vars(), dtnsim::ConnCommand::ConnCommand(), oasys::ConsoleCommand::ConsoleCommand(), oasys::LogCommand::LogCommand(), dtn::ParamCommand::ParamCommand(), dtn::ProphetCommand::ProphetCommand(), dtn::RouteCommand::RouteCommand(), dtnsim::SimCommand::SimCommand(), and dtn::StorageCommand::StorageCommand().
void oasys::TclCommand::unbind | ( | const char * | name | ) | [protected] |
void oasys::TclCommand::set_result | ( | const char * | result | ) | [inline, protected] |
Set the TclResult string.
Definition at line 339 of file TclCommand.h.
References oasys::TclCommandInterp::instance(), and oasys::TclCommandInterp::set_result().
Referenced by dtn::RouteCommand::exec(), dtn::RegistrationCommand::exec(), dtnsim::NodeCommand::exec(), oasys::LogCommand::exec(), dtn::LinkCommand::exec(), dtn::InterfaceCommand::exec(), oasys::HelpCommand::exec(), dtn::DiscoveryCommand::exec(), and dtn::BundleCommand::exec().
void oasys::TclCommand::set_objresult | ( | Tcl_Obj * | obj | ) | [inline, protected] |
Set a Tcl_Obj as the result.
Definition at line 347 of file TclCommand.h.
References oasys::TclCommandInterp::instance(), and oasys::TclCommandInterp::set_objresult().
Referenced by dtn::RegistrationCommand::exec(), and dtn::BundleCommand::exec().
void oasys::TclCommand::append_result | ( | const char * | result | ) | [inline, protected] |
Append the TclResult string.
Definition at line 355 of file TclCommand.h.
References oasys::TclCommandInterp::append_result(), and oasys::TclCommandInterp::instance().
Referenced by oasys::HelpCommand::exec().
void oasys::TclCommand::resultf | ( | const char * | fmt, | |
... | ||||
) | [protected] |
Format and set the TclResult string.
Definition at line 785 of file TclCommand.cc.
Referenced by dtn::TestCommand::exec(), dtn::StorageCommand::exec(), dtnsim::SimCommand::exec(), dtn::RouteCommand::exec(), dtn::RegistrationCommand::exec(), dtn::ProphetCommand::exec(), dtnsim::NodeCommand::exec(), oasys::LogCommand::exec(), dtn::LinkCommand::exec(), dtn::InterfaceCommand::exec(), oasys::HelpCommand::exec(), DTNRecvCommand::exec(), DTNUnbindCommand::exec(), DTNBindCommand::exec(), DTNSendCommand::exec(), DTNUnregisterCommand::exec(), DTNRegisterCommand::exec(), DTNCloseCommand::exec(), DTNOpenCommand::exec(), dtn::DiscoveryCommand::exec(), oasys::DebugCommand::exec(), dtnsim::ConnCommand::exec(), and dtn::BundleCommand::exec().
void oasys::TclCommand::append_resultf | ( | const char * | fmt, | |
... | ||||
) | [protected] |
Format and set the TclResult string.
Definition at line 793 of file TclCommand.cc.
Referenced by dtn::LinkCommand::exec(), and oasys::HelpCommand::exec().
void oasys::TclCommand::wrong_num_args | ( | int | objc, | |
const char ** | objv, | |||
int | parsed, | |||
int | min, | |||
int | max | |||
) | [inline, protected] |
Useful function for generating error strings indicating that the wrong number of arguments were passed to the command.
objc | original argument count to the command | |
objv | original argument vector to the command | |
parsed | number of args to include in error string | |
min | minimum number of expected args | |
max | maximum number of expected args (or INT_MAX) |
Definition at line 380 of file TclCommand.h.
References oasys::TclCommandInterp::instance().
Referenced by dtnsim::Simdtn2Command::exec(), dtnsim::SimCommand::exec(), dtn::ShutdownCommand::exec(), dtn::RouteCommand::exec(), dtn::RegistrationCommand::exec(), dtnsim::NodeCommand::exec(), oasys::LogCommand::exec(), dtn::LinkCommand::exec(), dtn::InterfaceCommand::exec(), oasys::HelpCommand::exec(), DTNRecvCommand::exec(), DTNUnbindCommand::exec(), DTNBindCommand::exec(), DTNSendCommand::exec(), DTNUnregisterCommand::exec(), DTNRegisterCommand::exec(), DTNCloseCommand::exec(), DTNOpenCommand::exec(), dtn::DiscoveryCommand::exec(), dtnsim::ConnCommand::exec(), dtn::BundleCommand::exec(), and wrong_num_args().
void oasys::TclCommand::wrong_num_args | ( | int | objc, | |
Tcl_Obj ** | objv, | |||
int | parsed, | |||
int | min, | |||
int | max | |||
) | [inline, protected] |
Useful function for generating error strings indicating that the wrong number of arguments were passed to the command.
objc | original argument count to the command | |
objv | original argument vector to the command | |
parsed | number of args to include in error string | |
min | minimum number of expected args | |
max | maximum number of expected args (or INT_MAX) |
Definition at line 397 of file TclCommand.h.
References oasys::TclCommandInterp::instance(), and wrong_num_args().
void oasys::TclCommand::add_to_help | ( | const char * | subcmd, | |
const char * | help_str | |||
) | [inline, protected] |
Append the given information to the current help string, typically used for a set of alternatives for subcommands.
Definition at line 408 of file TclCommand.h.
References oasys::StringBuffer::append(), oasys::StringBuffer::appendf(), help_, and name().
Referenced by dtn::BundleCommand::BundleCommand(), dtnsim::ConnCommand::ConnCommand(), oasys::DebugCommand::DebugCommand(), dtn::DiscoveryCommand::DiscoveryCommand(), oasys::HelpCommand::HelpCommand(), dtn::InterfaceCommand::InterfaceCommand(), dtn::LinkCommand::LinkCommand(), oasys::LogCommand::LogCommand(), dtnsim::NodeCommand::NodeCommand(), dtn::ProphetCommand::ProphetCommand(), dtn::RegistrationCommand::RegistrationCommand(), dtn::RouteCommand::RouteCommand(), dtn::ShutdownCommand::ShutdownCommand(), dtn::StorageCommand::StorageCommand(), and dtn::TestCommand::TestCommand().
friend class TclCommandInterp [friend] |
Definition at line 309 of file TclCommand.h.
std::string oasys::TclCommand::name_ [protected] |
StringBuffer oasys::TclCommand::help_ [protected] |
Help string.
Definition at line 312 of file TclCommand.h.
Referenced by add_to_help(), and help_string().
bool oasys::TclCommand::do_builtins_ [protected] |
Set to false if a module doesn't want builtin commands like "set".
Definition at line 313 of file TclCommand.h.
BindingTable oasys::TclCommand::bindings_ [protected] |
The table of registered bindings.
Definition at line 324 of file TclCommand.h.
Referenced by hasBindings().