Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
PLMD::CLToolMain Class Reference


Class providing cmd() access to command line tools. More...

#include <CLToolMain.h>

Inheritance diagram for PLMD::CLToolMain:
Inheritance graph
[legend]

Public Member Functions

 CLToolMain ()
 
 ~CLToolMain ()
 
void cmd (const std::string &key, void *val=NULL)
 
Send messages to the CLToolMain. More...
 
void cmd (const std::string &key, const void *val)
 Const val version, which indeed just overrides the const and call the virtual method. More...
 

Static Private Member Functions

static int run (int argc, char **argv, FILE *in, FILE *out, Communicator &pc)
 
This is the entry point to the command line tools included in the plumed library. More...
 

Private Attributes

int argc
 arguments for command-line mode: More...
 
std::vector< std::string > argv
 arguments for command-line mode: More...
 
FILE * in
 
FILE * out
 
Communicatorcomm
 

Detailed Description


Class providing cmd() access to command line tools.

This class provides an interface using the "cmd()" syntax to all the command-line tools. It is only accessed via the cmd() function, which can be used to set the arguments, communicators and IO descriptors and to run the tool. It can run all the tools registered via the PLUMED_REGISTER_CLTOOL macro, or the scripts which are located in PLUMED_ROOT/scripts.

A typical usage is:

#include "CLToolMain.h"
int main(int argc,char**argv){
  PLMD::CLToolMain cltoolMain;
  cltoolMain.cmd("setArgc",&argc);
  cltoolMain.cmd("setArgv",argv);
  int ret;
  cltoolMain.cmd("run",&ret);
  return ret;
}

This will run the tool registered with name argv[1] with options argv[2]...argv[argc-1].

This class is also used in the PlumedMain class to provide the same functionalities through the external plumed interface, which is available also for C and FORTRAN. Thus, the preferred approach is to do something like

#include "Plumed.h"
int main(int argc,char**argv){
  PLMD::Plumed p;
  p.cmd("CLTool setArgc",&argc);
  p.cmd("CLTool setArgv",argv);
  int ret;
  p.cmd("CLTool run",&ret);
  return ret;
}

See the file main.cpp for a similar example.

Constructor & Destructor Documentation

◆ CLToolMain()

PLMD::CLToolMain::CLToolMain ( )

◆ ~CLToolMain()

PLMD::CLToolMain::~CLToolMain ( )

Member Function Documentation

◆ cmd() [1/2]

void PLMD::WithCmd::cmd ( const std::string &  key,
const void *  val 
)
inlineinherited

Const val version, which indeed just overrides the const and call the virtual method.

◆ cmd() [2/2]

void PLMD::CLToolMain::cmd ( const std::string &  key,
void *  val = NULL 
)
virtual


Send messages to the CLToolMain.

Implements PLMD::WithCmd.

◆ run()

int PLMD::CLToolMain::run ( int  argc,
char **  argv,
FILE *  in,
FILE *  out,
Communicator pc 
)
staticprivate


This is the entry point to the command line tools included in the plumed library.

Member Data Documentation

◆ argc

int PLMD::CLToolMain::argc
private

arguments for command-line mode:

◆ argv

std::vector<std::string> PLMD::CLToolMain::argv
private

arguments for command-line mode:

◆ comm

Communicator& PLMD::CLToolMain::comm
private

◆ in

FILE* PLMD::CLToolMain::in
private

◆ out

FILE* PLMD::CLToolMain::out
private

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