Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarscript Class Reference

#include <colvarscript.h>

List of all members.

Public Types

enum  command {
  COMM, HELP, N_ARGS_MIN, N_ARGS_MAX,
  ARGS, cv_addenergy, VMD, add
}
 Commands available. More...

enum  Object_type { use_module, use_colvar, use_bias }
 Type of object handling a script command. More...


Public Methods

 colvarscript (colvarproxy *p, colvarmodule *m)
 ~colvarscript ()
int run (int objc, unsigned char *const objv[])
 Run a script command with space-separated positional arguments (objects). More...

std::string const & str_result () const
 Get the string result of the current scripting call. More...

std::string & modify_str_result ()
 Modify the string result of the current scripting call. More...

int set_result_str (std::string const &s)
 Set the return value to the given string. More...

int clear_str_result ()
 Clear the string result. More...

void add_error_msg (std::string const &s)
 Add the given string to the error message of the script interface. More...

std::string get_cmd_prefix (Object_type t)
 Return the prefix of the individual command for each object function. More...

template<Object_type T> unsigned char * get_cmd_arg (int iarg, int objc, unsigned char *const objv[])
 Get a pointer to the i-th argument of the command (NULL if not given). More...

unsigned char * get_module_cmd_arg (int iarg, int objc, unsigned char *const objv[])
 Instantiation of get_cmd_arg<> for module-level commands. More...

unsigned char * get_colvar_cmd_arg (int iarg, int objc, unsigned char *const objv[])
 Instantiation of get_cmd_arg<> for colvar-level commands. More...

unsigned char * get_bias_cmd_arg (int iarg, int objc, unsigned char *const objv[])
 Instantiation of get_cmd_arg<> for bias-level commands. More...

template<Object_type T> int check_cmd_nargs (char const *cmd, int objc, int n_args_min, int n_args_max)
 Check the argument count of the command. More...

int check_module_cmd_nargs (char const *cmd, int objc, int n_args_min, int n_args_max)
 Instantiation of check_cmd_nargs<> for module-level commands. More...

int check_colvar_cmd_nargs (char const *cmd, int objc, int n_args_min, int n_args_max)
 Instantiation of check_cmd_nargs<> for colvar-level commands. More...

int check_bias_cmd_nargs (char const *cmd, int objc, int n_args_min, int n_args_max)
 Instantiation of get_cmd_arg<> for bias-level commands. More...

template<colvarscript::Object_type T> int cmd_arg_shift ()
 Number of positional arguments to shift for each object type. More...

char const ** get_command_names () const
 Get names of all commands. More...

char const * get_command_help (char const *cmd)
 Get one-line help summary for a command
Parameters:
cmd  Name of the command's function (e.g. "cv_units").
More...


char const * get_command_rethelp (char const *cmd)
 Get description of the return value of a command
Parameters:
cmd  Name of the command's function (e.g. "cv_units").
More...


char const * get_command_arghelp (char const *cmd, int i)
 Get description of the argument of a command (excluding prefix)
Parameters:
cmd  Name of the command's function (e.g. "cv_units")
i  Index of the argument; 0 is the first argument after the prefix, e.g. "value" has an index of 0 in the array of arguments: { "cv", "colvar", "xi", "value" }.
More...


int get_command_n_args_min (char const *cmd)
 Get number of required arguments (excluding prefix)
Parameters:
cmd  Name of the command's function (e.g. "cv_units").
More...


int get_command_n_args_max (char const *cmd)
 Get number of total arguments (excluding prefix)
Parameters:
cmd  Name of the command's function (e.g. "cv_units").
More...


char const * get_command_full_help (char const *cmd)
 Get help string for a command (does not specify how it is launched)
Parameters:
cmd  Name of the command's function (e.g. "cv_units").
More...


std::string get_cmdline_help_summary (Object_type t)
 Get summary of command line syntax for all commands of a given context
Parameters:
t  One of use_module, use_colvar or use_bias.
More...


std::string get_command_cmdline_syntax (Object_type t, command c)
 Get a description of how the command should be used in a command line
Parameters:
t  One of use_module, use_colvar or use_bias
c  Value of the command enum.
More...


std::string get_command_cmdline_help (Object_type t, std::string const &cmd)
 Get the command line syntax following by the help string
Parameters:
t  One of use_module, use_colvar or use_bias
cmd  Name of the subcommand (e.g. "units").
More...


int unsupported_op ()
 Set error code for unsupported script operation. More...

colvarmodule * module ()
 Pointer to the Colvars main object. More...

colvarproxy * proxy ()
 Pointer to the colvarproxy object (interface with host engine). More...

char * obj_to_str (unsigned char *obj)
 Get the string representation of an object (by default, a simple cast). More...

std::vector< std::string > obj_to_str_vector (unsigned char *obj)
 Get a list of strings from an object (does not work with a simple cast). More...

int set_result_int (int const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_int_vec (std::vector< int > const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_long_int (long int const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_long_int_vec (std::vector< long int > const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_real (cvm::real const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_real_vec (std::vector< cvm::real > const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_rvector (cvm::rvector const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_rvector_vec (std::vector< cvm::rvector > const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_colvarvalue (colvarvalue const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int set_result_colvarvalue_vec (std::vector< colvarvalue > const &x, unsigned char *obj=NULL)
 Copy x into obj if not NULL, or into the script object's result otherwise. More...

int proc_features (colvardeps *obj, int argc, unsigned char *const argv[])
 Run subcommands on base colvardeps object (colvar, bias, ...). More...

template<> int set_result_text (int const &x, unsigned char *obj)
template<> int set_result_text (std::vector< int > const &x, unsigned char *obj)
template<> int set_result_text (long int const &x, unsigned char *obj)
template<> int set_result_text (std::vector< long int > const &x, unsigned char *obj)
template<> int set_result_text (cvm::real const &x, unsigned char *obj)
template<> int set_result_text (std::vector< cvm::real > const &x, unsigned char *obj)
template<> int set_result_text (std::vector< cvm::rvector > const &x, unsigned char *obj)
template<> int set_result_text (std::vector< colvarvalue > const &x, unsigned char *obj)

Public Attributes

std::string str_result_
 String representation of the result of a script call. More...


Friends

class colvarproxy


Member Enumeration Documentation

enum colvarscript::command
 

Commands available.

Enumeration values:
COMM 
HELP 
N_ARGS_MIN 
N_ARGS_MAX 
ARGS 
cv_addenergy 
VMD 
add 

Definition at line 73 of file colvarscript.h.

enum colvarscript::Object_type
 

Type of object handling a script command.

Enumeration values:
use_module 
use_colvar 
use_bias 

Definition at line 1186 of file colvarscript.h.


Constructor & Destructor Documentation

colvarscript::colvarscript (  colvarproxy *    p,
colvarmodule *    m
) 
 

Definition at line 34 of file colvarscript.C.

References colvarmodule::error, colvarproxy_tcl::get_tcl_interp, colvarproxy_tcl::init_tcl_pointers, colvarmodule::log, NULL, proxy, and tcl_run_colvarscript_command.

colvarscript::~colvarscript (    ) 
 

Definition at line 57 of file colvarscript.C.

References NULL.


Member Function Documentation

void colvarscript::add_error_msg (  std::string const &    s ) 
 

Add the given string to the error message of the script interface.

Definition at line 1689 of file colvarscript.C.

int colvarscript::check_bias_cmd_nargs (  char const *    cmd,
int    objc,
int    n_args_min,
int    n_args_max
)  [inline]
 

Instantiation of get_cmd_arg<> for bias-level commands.

Definition at line 1507 of file colvarscript.h.

template<colvarscript::Object_type T>
int colvarscript::check_cmd_nargs (  char const *    cmd,
int    objc,
int    n_args_min,
int    n_args_max
) 
 

Check the argument count of the command.

Definition at line 1467 of file colvarscript.h.

int colvarscript::check_colvar_cmd_nargs (  char const *    cmd,
int    objc,
int    n_args_min,
int    n_args_max
)  [inline]
 

Instantiation of check_cmd_nargs<> for colvar-level commands.

Definition at line 1498 of file colvarscript.h.

int colvarscript::check_module_cmd_nargs (  char const *    cmd,
int    objc,
int    n_args_min,
int    n_args_max
)  [inline]
 

Instantiation of check_cmd_nargs<> for module-level commands.

Definition at line 1489 of file colvarscript.h.

int colvarscript::clear_str_result (    ) 
 

Clear the string result.

Definition at line 1699 of file colvarscript.C.

template<colvarscript::Object_type T>
int colvarscript::cmd_arg_shift (    ) 
 

Number of positional arguments to shift for each object type.

Definition at line 1517 of file colvarscript.h.

unsigned char * colvarscript::get_bias_cmd_arg (  int    iarg,
int    objc,
unsigned char *const    objv[]
)  [inline]
 

Instantiation of get_cmd_arg<> for bias-level commands.

Definition at line 1459 of file colvarscript.h.

template<colvarscript::Object_type T>
unsigned char * colvarscript::get_cmd_arg (  int    iarg,
int    objc,
unsigned char *const    objv[]
) 
 

Get a pointer to the i-th argument of the command (NULL if not given).

Definition at line 1436 of file colvarscript.h.

std::string colvarscript::get_cmd_prefix (  Object_type    t ) 
 

Return the prefix of the individual command for each object function.

Definition at line 1268 of file colvarscript.C.

std::string colvarscript::get_cmdline_help_summary (  Object_type    t ) 
 

Get summary of command line syntax for all commands of a given context

Parameters:
t  One of use_module, use_colvar or use_bias.

Definition at line 1395 of file colvarscript.C.

unsigned char * colvarscript::get_colvar_cmd_arg (  int    iarg,
int    objc,
unsigned char *const    objv[]
)  [inline]
 

Instantiation of get_cmd_arg<> for colvar-level commands.

Definition at line 1452 of file colvarscript.h.

char const * colvarscript::get_command_arghelp (  char const *    cmd,
int    i
) 
 

Get description of the argument of a command (excluding prefix)

Parameters:
cmd  Name of the command's function (e.g. "cv_units")
i  Index of the argument; 0 is the first argument after the prefix, e.g. "value" has an index of 0 in the array of arguments: { "cv", "colvar", "xi", "value" }.

Definition at line 1309 of file colvarscript.C.

Referenced by cvscript_command_arghelp.

std::string colvarscript::get_command_cmdline_help (  Object_type    t,
std::string const &    cmd
) 
 

Get the command line syntax following by the help string

Parameters:
t  One of use_module, use_colvar or use_bias
cmd  Name of the subcommand (e.g. "units").

Definition at line 1427 of file colvarscript.C.

std::string colvarscript::get_command_cmdline_syntax (  Object_type    t,
command    c
) 
 

Get a description of how the command should be used in a command line

Parameters:
t  One of use_module, use_colvar or use_bias
c  Value of the command enum.

Definition at line 1357 of file colvarscript.C.

char const * colvarscript::get_command_full_help (  char const *    cmd ) 
 

Get help string for a command (does not specify how it is launched)

Parameters:
cmd  Name of the command's function (e.g. "cv_units").

Definition at line 1345 of file colvarscript.C.

Referenced by cvscript_command_full_help.

char const * colvarscript::get_command_help (  char const *    cmd ) 
 

Get one-line help summary for a command

Parameters:
cmd  Name of the command's function (e.g. "cv_units").

Definition at line 1285 of file colvarscript.C.

Referenced by cvscript_command_help.

int colvarscript::get_command_n_args_max (  char const *    cmd ) 
 

Get number of total arguments (excluding prefix)

Parameters:
cmd  Name of the command's function (e.g. "cv_units").

Definition at line 1333 of file colvarscript.C.

Referenced by cvscript_command_n_args_max.

int colvarscript::get_command_n_args_min (  char const *    cmd ) 
 

Get number of required arguments (excluding prefix)

Parameters:
cmd  Name of the command's function (e.g. "cv_units").

Definition at line 1321 of file colvarscript.C.

Referenced by cvscript_command_n_args_min.

char const** colvarscript::get_command_names (    )  const [inline]
 

Get names of all commands.

Definition at line 1233 of file colvarscript.h.

Referenced by cvscript_command_names.

char const * colvarscript::get_command_rethelp (  char const *    cmd ) 
 

Get description of the return value of a command

Parameters:
cmd  Name of the command's function (e.g. "cv_units").

Definition at line 1297 of file colvarscript.C.

Referenced by cvscript_command_rethelp.

unsigned char * colvarscript::get_module_cmd_arg (  int    iarg,
int    objc,
unsigned char *const    objv[]
)  [inline]
 

Instantiation of get_cmd_arg<> for module-level commands.

Definition at line 1445 of file colvarscript.h.

std::string& colvarscript::modify_str_result (    )  [inline]
 

Modify the string result of the current scripting call.

Definition at line 58 of file colvarscript.h.

References str_result_.

colvarmodule* colvarscript::module (    )  [inline]
 

Pointer to the Colvars main object.

Definition at line 1283 of file colvarscript.h.

char * colvarscript::obj_to_str (  unsigned char *    obj ) 
 

Get the string representation of an object (by default, a simple cast).

Definition at line 1545 of file colvarscript.C.

std::vector< std::string > colvarscript::obj_to_str_vector (  unsigned char *    obj ) 
 

Get a list of strings from an object (does not work with a simple cast).

Definition at line 1556 of file colvarscript.C.

int colvarscript::proc_features (  colvardeps *    obj,
int    argc,
unsigned char *const    argv[]
) 
 

Run subcommands on base colvardeps object (colvar, bias, ...).

Definition at line 1599 of file colvarscript.C.

colvarproxy* colvarscript::proxy (    )  [inline]
 

Pointer to the colvarproxy object (interface with host engine).

Definition at line 1289 of file colvarscript.h.

Referenced by colvarscript.

int colvarscript::run (  int    objc,
unsigned char *const    objv[]
) 
 

Run a script command with space-separated positional arguments (objects).

Definition at line 1441 of file colvarscript.C.

int colvarscript::set_result_colvarvalue (  colvarvalue const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 2006 of file colvarscript.C.

int colvarscript::set_result_colvarvalue_vec (  std::vector< colvarvalue > const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 2011 of file colvarscript.C.

int colvarscript::set_result_int (  int const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1966 of file colvarscript.C.

int colvarscript::set_result_int_vec (  std::vector< int > const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1970 of file colvarscript.C.

int colvarscript::set_result_long_int (  long int const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1976 of file colvarscript.C.

int colvarscript::set_result_long_int_vec (  std::vector< long int > const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1980 of file colvarscript.C.

int colvarscript::set_result_real (  cvm::real const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1986 of file colvarscript.C.

int colvarscript::set_result_real_vec (  std::vector< cvm::real > const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1990 of file colvarscript.C.

int colvarscript::set_result_rvector (  cvm::rvector const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 1996 of file colvarscript.C.

int colvarscript::set_result_rvector_vec (  std::vector< cvm::rvector > const &    x,
unsigned char *    obj = NULL
) 
 

Copy x into obj if not NULL, or into the script object's result otherwise.

Definition at line 2000 of file colvarscript.C.

int colvarscript::set_result_str (  std::string const &    s ) 
 

Set the return value to the given string.

Definition at line 1677 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  std::vector< colvarvalue > const &    x,
unsigned char *    obj
) 
 

Definition at line 1953 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  std::vector< cvm::rvector > const &    x,
unsigned char *    obj
) 
 

Definition at line 1942 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  std::vector< cvm::real > const &    x,
unsigned char *    obj
) 
 

Definition at line 1930 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  cvm::real const &    x,
unsigned char *    obj
) 
 

Definition at line 1924 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  std::vector< long int > const &    x,
unsigned char *    obj
) 
 

Definition at line 1915 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  long int const &    x,
unsigned char *    obj
) 
 

Definition at line 1909 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  std::vector< int > const &    x,
unsigned char *    obj
) 
 

Definition at line 1900 of file colvarscript.C.

template<>
int colvarscript::set_result_text (  int const &    x,
unsigned char *    obj
) 
 

Definition at line 1894 of file colvarscript.C.

std::string const& colvarscript::str_result (    )  const [inline]
 

Get the string result of the current scripting call.

Definition at line 52 of file colvarscript.h.

References str_result_.

int colvarscript::unsupported_op (    ) 
 

Set error code for unsupported script operation.

Definition at line 1670 of file colvarscript.C.


Friends And Related Function Documentation

friend class colvarproxy [friend]
 

Definition at line 39 of file colvarscript.h.


Member Data Documentation

std::string colvarscript::str_result_
 

String representation of the result of a script call.

Definition at line 46 of file colvarscript.h.

Referenced by modify_str_result, and str_result.


The documentation for this class was generated from the following files:
Generated on Fri Jan 23 01:52:41 2026 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002