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, const TypesafePtr &val, const std::size_t *shape)
 
void cmd (const std::string &key, const TypesafePtr &val, std::size_t nelem, const std::size_t *shape=nullptr)
 
void cmd (const std::string &key, const TypesafePtr &val=nullptr) override
 Send messages to the CLToolMain. 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...
 
Communicatorcomm =*comm_fwd
 
ForwardDecl< Communicatorcomm_fwd
 
FILE * in
 
FILE * out
 

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/3]

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

◆ cmd() [2/3]

void PLMD::WithCmd::cmd ( const std::string &  key,
const TypesafePtr val,
std::size_t  nelem,
const std::size_t *  shape = nullptr 
)
inlineinherited

◆ cmd() [3/3]

void PLMD::CLToolMain::cmd ( const std::string &  key,
const TypesafePtr val = nullptr 
)
overridevirtual

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 =*comm_fwd
private

◆ comm_fwd

ForwardDecl<Communicator> PLMD::CLToolMain::comm_fwd
private

◆ in

FILE* PLMD::CLToolMain::in
private

◆ out

FILE* PLMD::CLToolMain::out
private

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