take advantage of having the common Command base class to unify code paths
This commit is contained in:
@ -59,31 +59,25 @@ Members of ``lammpsplugin_t``
|
|||||||
* - author
|
* - author
|
||||||
- String with the name and email of the author
|
- String with the name and email of the author
|
||||||
* - creator.v1
|
* - creator.v1
|
||||||
- Pointer to factory function for pair, bond, angle, dihedral, or improper styles
|
- Pointer to factory function for pair, bond, angle, dihedral, improper or command styles
|
||||||
* - creator.v2
|
* - creator.v2
|
||||||
- Pointer to factory function for compute, fix, or region styles
|
- Pointer to factory function for compute, fix, or region styles
|
||||||
* - creator.v3
|
|
||||||
- Pointer to factory function for command styles
|
|
||||||
* - handle
|
* - handle
|
||||||
- Pointer to the open DSO file handle
|
- Pointer to the open DSO file handle
|
||||||
|
|
||||||
Only one of the three alternate creator entries can be used at a time
|
Only one of the three alternate creator entries can be used at a time
|
||||||
and which of those is determined by the style of plugin. The "creator.v1"
|
and which of those is determined by the style of plugin. The
|
||||||
element is for factory functions of supported styles computing forces (i.e.
|
"creator.v1" element is for factory functions of supported styles
|
||||||
pair, bond, angle, dihedral, or improper styles) and the function takes
|
computing forces (i.e. command, pair, bond, angle, dihedral, or
|
||||||
as single argument the pointer to the LAMMPS instance. The factory function
|
improper styles) and the function takes as single argument the pointer
|
||||||
is cast to the ``lammpsplugin_factory1`` type before assignment. The
|
to the LAMMPS instance. The factory function is cast to the
|
||||||
"creator.v2" element is for factory functions creating an instance of
|
``lammpsplugin_factory1`` type before assignment. The "creator.v2"
|
||||||
a fix, compute, or region style and takes three arguments: a pointer to
|
element is for factory functions creating an instance of a fix, compute,
|
||||||
the LAMMPS instance, an integer with the length of the argument list and
|
or region style and takes three arguments: a pointer to the LAMMPS
|
||||||
a ``char **`` pointer to the list of arguments. The factory function pointer
|
instance, an integer with the length of the argument list and a ``char
|
||||||
needs to be cast to the ``lammpsplugin_factory2`` type before assignment.
|
**`` pointer to the list of arguments. The factory function pointer
|
||||||
The "creator.v3" element takes the same arguments as "creator.v3" but is
|
needs to be cast to the ``lammpsplugin_factory2`` type before
|
||||||
specific to creating command styles: the factory function has to instantiate
|
assignment.
|
||||||
the command style locally passing the LAMMPS pointer as argument and then
|
|
||||||
call its "command" member function with the number and list of arguments.
|
|
||||||
The factory function pointer needs to be cast to the
|
|
||||||
``lammpsplugin_factory3`` type before assignment.
|
|
||||||
|
|
||||||
Pair style example
|
Pair style example
|
||||||
^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^
|
||||||
@ -123,12 +117,12 @@ function would look like this:
|
|||||||
|
|
||||||
The factory function in this example is called ``morse2creator()``. It
|
The factory function in this example is called ``morse2creator()``. It
|
||||||
receives a pointer to the LAMMPS class as only argument and thus has to
|
receives a pointer to the LAMMPS class as only argument and thus has to
|
||||||
be assigned to the *creator.v1* member of the plugin struct and cast to the
|
be assigned to the *creator.v1* member of the plugin struct and cast to
|
||||||
``lammpsplugin_factory1`` pointer type. It returns a
|
the ``lammpsplugin_factory1`` function pointer type. It returns a
|
||||||
pointer to the allocated class instance derived from the ``Pair`` class.
|
pointer to the allocated class instance derived from the ``Pair`` class.
|
||||||
This function may be declared static to avoid clashes with other plugins.
|
This function may be declared static to avoid clashes with other
|
||||||
The name of the derived class, ``PairMorse2``, must be unique inside
|
plugins. The name of the derived class, ``PairMorse2``, however must be
|
||||||
the entire LAMMPS executable.
|
unique inside the entire LAMMPS executable.
|
||||||
|
|
||||||
Fix style example
|
Fix style example
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
@ -169,9 +163,9 @@ Below is an example for that:
|
|||||||
|
|
||||||
Command style example
|
Command style example
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
For command styles there is a third variant of factory function as
|
Command styles also use the first variant of factory function as
|
||||||
demonstrated in the following example, which also shows that the
|
demonstrated in the following example, which also shows that the
|
||||||
implementation of the plugin class may also be within the same
|
implementation of the plugin class may be within the same source
|
||||||
file as the plugin interface code:
|
file as the plugin interface code:
|
||||||
|
|
||||||
.. code-block:: C++
|
.. code-block:: C++
|
||||||
@ -180,15 +174,15 @@ file as the plugin interface code:
|
|||||||
|
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "pointers.h"
|
#include "command.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
class Hello : protected Pointers {
|
class Hello : public Command {
|
||||||
public:
|
public:
|
||||||
Hello(class LAMMPS *lmp) : Pointers(lmp) {};
|
Hello(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -202,10 +196,9 @@ file as the plugin interface code:
|
|||||||
utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0]));
|
utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hellocreator(LAMMPS *lmp, int argc, char **argv)
|
static void hellocreator(LAMMPS *lmp)
|
||||||
{
|
{
|
||||||
Hello hello(lmp);
|
return new Hello(lmp);
|
||||||
hello.command(argc,argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
||||||
@ -216,9 +209,9 @@ file as the plugin interface code:
|
|||||||
plugin.version = LAMMPS_VERSION;
|
plugin.version = LAMMPS_VERSION;
|
||||||
plugin.style = "command";
|
plugin.style = "command";
|
||||||
plugin.name = "hello";
|
plugin.name = "hello";
|
||||||
plugin.info = "Hello world command v1.0";
|
plugin.info = "Hello world command v1.1";
|
||||||
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
|
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
|
||||||
plugin.creator.v3 = (lammpsplugin_factory3 *) &hellocreator;
|
plugin.creator.v1 = (lammpsplugin_factory1 *) &hellocreator;
|
||||||
plugin.handle = handle;
|
plugin.handle = handle;
|
||||||
(*register_plugin)(&plugin,lmp);
|
(*register_plugin)(&plugin,lmp);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
class Hello : protected Command {
|
class Hello : public Command {
|
||||||
public:
|
public:
|
||||||
Hello(class LAMMPS *lmp) : Command(lmp) {};
|
Hello(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
@ -25,10 +25,9 @@ void Hello::command(int argc, char **argv)
|
|||||||
utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0]));
|
utils::logmesg(lmp,fmt::format("Hello, {}!\n",argv[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hellocreator(LAMMPS *lmp, int argc, char **argv)
|
static Command *hellocreator(LAMMPS *lmp)
|
||||||
{
|
{
|
||||||
Hello hello(lmp);
|
return new Hello(lmp);
|
||||||
hello.command(argc,argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
||||||
@ -39,9 +38,9 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
|||||||
plugin.version = LAMMPS_VERSION;
|
plugin.version = LAMMPS_VERSION;
|
||||||
plugin.style = "command";
|
plugin.style = "command";
|
||||||
plugin.name = "hello";
|
plugin.name = "hello";
|
||||||
plugin.info = "Hello world command v1.0";
|
plugin.info = "Hello world command v1.1";
|
||||||
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
|
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
|
||||||
plugin.creator.v3 = (lammpsplugin_factory3 *) &hellocreator;
|
plugin.creator.v1 = (lammpsplugin_factory1 *) &hellocreator;
|
||||||
plugin.handle = handle;
|
plugin.handle = handle;
|
||||||
(*register_plugin)(&plugin,lmp);
|
(*register_plugin)(&plugin,lmp);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ CommandStyle(kim,KimCommand)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class KimCommand : protected Command {
|
class KimCommand : public Command {
|
||||||
public:
|
public:
|
||||||
KimCommand(class LAMMPS *lmp) : Command(lmp) {};
|
KimCommand(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(message,Message)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Message : protected Command {
|
class Message : public Command {
|
||||||
public:
|
public:
|
||||||
Message(class LAMMPS *lmp) : Command(lmp) {};
|
Message(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(server,Server)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Server : protected Command {
|
class Server : public Command {
|
||||||
public:
|
public:
|
||||||
Server(class LAMMPS *lmp) : Command(lmp) {};
|
Server(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -257,7 +257,7 @@ namespace LAMMPS_NS
|
|||||||
"style {} from plugin",
|
"style {} from plugin",
|
||||||
plugin->name));
|
plugin->name));
|
||||||
}
|
}
|
||||||
(*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v3;
|
(*command_map)[plugin->name] = (Input::CommandCreator)plugin->creator.v1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
utils::logmesg(lmp,fmt::format("Loading plugin for {} styles not "
|
utils::logmesg(lmp,fmt::format("Loading plugin for {} styles not "
|
||||||
|
|||||||
@ -26,7 +26,7 @@ CommandStyle(plugin,Plugin)
|
|||||||
namespace LAMMPS_NS
|
namespace LAMMPS_NS
|
||||||
{
|
{
|
||||||
|
|
||||||
class Plugin : protected Command {
|
class Plugin : public Command {
|
||||||
public:
|
public:
|
||||||
Plugin(class LAMMPS *);
|
Plugin(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(hyper,Hyper)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Hyper : protected Command {
|
class Hyper : public Command {
|
||||||
public:
|
public:
|
||||||
Hyper(class LAMMPS *);
|
Hyper(class LAMMPS *);
|
||||||
~Hyper() {}
|
~Hyper() {}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(neb,NEB)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class NEB : protected Command {
|
class NEB : public Command {
|
||||||
public:
|
public:
|
||||||
NEB(class LAMMPS *);
|
NEB(class LAMMPS *);
|
||||||
NEB(class LAMMPS *, double, double, int, int, int, double *, double *);
|
NEB(class LAMMPS *, double, double, int, int, int, double *, double *);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(prd,PRD)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class PRD : protected Command {
|
class PRD : public Command {
|
||||||
public:
|
public:
|
||||||
PRD(class LAMMPS *);
|
PRD(class LAMMPS *);
|
||||||
~PRD() {}
|
~PRD() {}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(tad,TAD)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class TAD : protected Command {
|
class TAD : public Command {
|
||||||
public:
|
public:
|
||||||
TAD(class LAMMPS *);
|
TAD(class LAMMPS *);
|
||||||
~TAD();
|
~TAD();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(temper,Temper)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Temper : protected Command {
|
class Temper : public Command {
|
||||||
public:
|
public:
|
||||||
Temper(class LAMMPS *);
|
Temper(class LAMMPS *);
|
||||||
~Temper();
|
~Temper();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(neb/spin,NEBSpin)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class NEBSpin : protected Command {
|
class NEBSpin : public Command {
|
||||||
public:
|
public:
|
||||||
NEBSpin(class LAMMPS *);
|
NEBSpin(class LAMMPS *);
|
||||||
~NEBSpin();
|
~NEBSpin();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ CommandStyle(group2ndx,Group2Ndx)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Group2Ndx : protected Command {
|
class Group2Ndx : public Command {
|
||||||
public:
|
public:
|
||||||
Group2Ndx(class LAMMPS *lmp) : Command(lmp) {};
|
Group2Ndx(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -27,7 +27,7 @@ CommandStyle(ndx2group,Ndx2Group)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Ndx2Group : protected Command {
|
class Ndx2Group : public Command {
|
||||||
public:
|
public:
|
||||||
Ndx2Group(class LAMMPS *lmp) : Command(lmp) {};
|
Ndx2Group(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(temper/grem,TemperGrem)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class TemperGrem : protected Command {
|
class TemperGrem : public Command {
|
||||||
public:
|
public:
|
||||||
TemperGrem(class LAMMPS *);
|
TemperGrem(class LAMMPS *);
|
||||||
~TemperGrem();
|
~TemperGrem();
|
||||||
|
|||||||
@ -25,7 +25,7 @@ CommandStyle(temper/npt,TemperNPT)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class TemperNPT : protected Command {
|
class TemperNPT : public Command {
|
||||||
public:
|
public:
|
||||||
TemperNPT(class LAMMPS *);
|
TemperNPT(class LAMMPS *);
|
||||||
~TemperNPT();
|
~TemperNPT();
|
||||||
|
|||||||
@ -15,7 +15,7 @@ CommandStyle(dynamical_matrix,DynamicalMatrix)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class DynamicalMatrix : protected Command {
|
class DynamicalMatrix : public Command {
|
||||||
public:
|
public:
|
||||||
DynamicalMatrix(class LAMMPS *);
|
DynamicalMatrix(class LAMMPS *);
|
||||||
virtual ~DynamicalMatrix();
|
virtual ~DynamicalMatrix();
|
||||||
|
|||||||
@ -16,7 +16,7 @@ CommandStyle(third_order,ThirdOrder)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ThirdOrder : protected Command {
|
class ThirdOrder : public Command {
|
||||||
public:
|
public:
|
||||||
ThirdOrder(class LAMMPS *);
|
ThirdOrder(class LAMMPS *);
|
||||||
virtual ~ThirdOrder();
|
virtual ~ThirdOrder();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(balance,Balance)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Balance : protected Command {
|
class Balance : public Command {
|
||||||
public:
|
public:
|
||||||
class RCB *rcb;
|
class RCB *rcb;
|
||||||
class FixStore *fixstore; // per-atom weights stored in FixStore
|
class FixStore *fixstore; // per-atom weights stored in FixStore
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(change_box,ChangeBox)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ChangeBox : protected Command {
|
class ChangeBox : public Command {
|
||||||
public:
|
public:
|
||||||
ChangeBox(class LAMMPS *);
|
ChangeBox(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(create_atoms,CreateAtoms)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class CreateAtoms : protected Command {
|
class CreateAtoms : public Command {
|
||||||
public:
|
public:
|
||||||
CreateAtoms(class LAMMPS *);
|
CreateAtoms(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(create_bonds,CreateBonds)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class CreateBonds : protected Command {
|
class CreateBonds : public Command {
|
||||||
public:
|
public:
|
||||||
CreateBonds(class LAMMPS *);
|
CreateBonds(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(create_box,CreateBox)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class CreateBox : protected Command {
|
class CreateBox : public Command {
|
||||||
public:
|
public:
|
||||||
CreateBox(class LAMMPS *);
|
CreateBox(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -25,7 +25,7 @@ CommandStyle(delete_atoms,DeleteAtoms)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class DeleteAtoms : protected Command {
|
class DeleteAtoms : public Command {
|
||||||
public:
|
public:
|
||||||
DeleteAtoms(class LAMMPS *);
|
DeleteAtoms(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(delete_bonds,DeleteBonds)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class DeleteBonds : protected Command {
|
class DeleteBonds : public Command {
|
||||||
public:
|
public:
|
||||||
DeleteBonds(class LAMMPS *);
|
DeleteBonds(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -30,7 +30,7 @@ CommandStyle(kim_query,Deprecated)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Deprecated : protected Command {
|
class Deprecated : public Command {
|
||||||
public:
|
public:
|
||||||
Deprecated(class LAMMPS *lmp) : Command(lmp) {};
|
Deprecated(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(displace_atoms,DisplaceAtoms)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class DisplaceAtoms : protected Command {
|
class DisplaceAtoms : public Command {
|
||||||
public:
|
public:
|
||||||
DisplaceAtoms(class LAMMPS *);
|
DisplaceAtoms(class LAMMPS *);
|
||||||
~DisplaceAtoms();
|
~DisplaceAtoms();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ CommandStyle(info,Info)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Info : protected Command {
|
class Info : public Command {
|
||||||
public:
|
public:
|
||||||
Info(class LAMMPS *lmp) : Command(lmp) {};
|
Info(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "comm_brick.h"
|
#include "comm_brick.h"
|
||||||
#include "comm_tiled.h"
|
#include "comm_tiled.h"
|
||||||
|
#include "command.h"
|
||||||
#include "compute.h"
|
#include "compute.h"
|
||||||
#include "dihedral.h"
|
#include "dihedral.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
@ -82,7 +83,7 @@ command line flags, holds the factory of commands and creates and
|
|||||||
initializes an instance of the Variable class.
|
initializes an instance of the Variable class.
|
||||||
|
|
||||||
To execute a command, a specific class instance, derived from
|
To execute a command, a specific class instance, derived from
|
||||||
:cpp:class:`Pointers`, is created, then its ``command()`` member
|
:cpp:class:`Command`, is created, then its ``command()`` member
|
||||||
function executed, and finally the class instance is deleted.
|
function executed, and finally the class instance is deleted.
|
||||||
|
|
||||||
\endverbatim
|
\endverbatim
|
||||||
@ -789,7 +790,8 @@ int Input::execute_command()
|
|||||||
|
|
||||||
if (command_map->find(command) != command_map->end()) {
|
if (command_map->find(command) != command_map->end()) {
|
||||||
CommandCreator &command_creator = (*command_map)[command];
|
CommandCreator &command_creator = (*command_map)[command];
|
||||||
command_creator(lmp,narg,arg);
|
Command *cmd = command_creator(lmp);
|
||||||
|
cmd->command(narg,arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,10 +805,9 @@ int Input::execute_command()
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Input::command_creator(LAMMPS *lmp, int narg, char **arg)
|
Command *Input::command_creator(LAMMPS *lmp)
|
||||||
{
|
{
|
||||||
T cmd(lmp);
|
return new T(lmp);
|
||||||
cmd.command(narg,arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
class Command;
|
||||||
|
|
||||||
class Input : protected Pointers {
|
class Input : protected Pointers {
|
||||||
friend class Info;
|
friend class Info;
|
||||||
@ -59,12 +60,12 @@ class Input : protected Pointers {
|
|||||||
FILE **infiles; // list of open input files
|
FILE **infiles; // list of open input files
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef void (*CommandCreator)(LAMMPS *, int, char **);
|
typedef Command * (*CommandCreator)(LAMMPS *);
|
||||||
typedef std::map<std::string,CommandCreator> CommandCreatorMap;
|
typedef std::map<std::string,CommandCreator> CommandCreatorMap;
|
||||||
CommandCreatorMap *command_map;
|
CommandCreatorMap *command_map;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <typename T> static void command_creator(LAMMPS *, int, char **);
|
template <typename T> static Command *command_creator(LAMMPS *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parse(); // parse an input text line
|
void parse(); // parse an input text line
|
||||||
|
|||||||
@ -20,7 +20,6 @@ extern "C" {
|
|||||||
|
|
||||||
typedef void *(lammpsplugin_factory1)(void *);
|
typedef void *(lammpsplugin_factory1)(void *);
|
||||||
typedef void *(lammpsplugin_factory2)(void *, int, char **);
|
typedef void *(lammpsplugin_factory2)(void *, int, char **);
|
||||||
typedef void (lammpsplugin_factory3)(void *, int, char **);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *version;
|
const char *version;
|
||||||
@ -31,7 +30,6 @@ extern "C" {
|
|||||||
union {
|
union {
|
||||||
lammpsplugin_factory1 *v1;
|
lammpsplugin_factory1 *v1;
|
||||||
lammpsplugin_factory2 *v2;
|
lammpsplugin_factory2 *v2;
|
||||||
lammpsplugin_factory3 *v3;
|
|
||||||
} creator;
|
} creator;
|
||||||
void *handle;
|
void *handle;
|
||||||
} lammpsplugin_t;
|
} lammpsplugin_t;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(minimize,Minimize)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Minimize : protected Command {
|
class Minimize : public Command {
|
||||||
public:
|
public:
|
||||||
Minimize(class LAMMPS *);
|
Minimize(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(read_data,ReadData)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ReadData : protected Command {
|
class ReadData : public Command {
|
||||||
public:
|
public:
|
||||||
ReadData(class LAMMPS *);
|
ReadData(class LAMMPS *);
|
||||||
~ReadData();
|
~ReadData();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ CommandStyle(read_dump,ReadDump)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ReadDump : protected Command {
|
class ReadDump : public Command {
|
||||||
public:
|
public:
|
||||||
ReadDump(class LAMMPS *);
|
ReadDump(class LAMMPS *);
|
||||||
~ReadDump();
|
~ReadDump();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(read_restart,ReadRestart)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ReadRestart : protected Command {
|
class ReadRestart : public Command {
|
||||||
public:
|
public:
|
||||||
ReadRestart(class LAMMPS *);
|
ReadRestart(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(replicate,Replicate)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Replicate : protected Command {
|
class Replicate : public Command {
|
||||||
public:
|
public:
|
||||||
Replicate(class LAMMPS *);
|
Replicate(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(rerun,Rerun)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Rerun : protected Command {
|
class Rerun : public Command {
|
||||||
public:
|
public:
|
||||||
Rerun(class LAMMPS *);
|
Rerun(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(reset_atom_ids,ResetIDs)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ResetIDs : protected Command {
|
class ResetIDs : public Command {
|
||||||
public:
|
public:
|
||||||
struct AtomRvous {
|
struct AtomRvous {
|
||||||
bigint ibin;
|
bigint ibin;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(reset_mol_ids,ResetMolIDs)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class ResetMolIDs : protected Command {
|
class ResetMolIDs : public Command {
|
||||||
public:
|
public:
|
||||||
ResetMolIDs(class LAMMPS *);
|
ResetMolIDs(class LAMMPS *);
|
||||||
~ResetMolIDs();
|
~ResetMolIDs();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(run,Run)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Run : protected Command {
|
class Run : public Command {
|
||||||
public:
|
public:
|
||||||
Run(class LAMMPS *);
|
Run(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(set,Set)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Set : protected Command {
|
class Set : public Command {
|
||||||
public:
|
public:
|
||||||
Set(class LAMMPS *lmp) : Command(lmp) {};
|
Set(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(velocity,Velocity)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class Velocity : protected Command {
|
class Velocity : public Command {
|
||||||
public:
|
public:
|
||||||
Velocity(class LAMMPS *);
|
Velocity(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(write_coeff,WriteCoeff)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class WriteCoeff : protected Command {
|
class WriteCoeff : public Command {
|
||||||
public:
|
public:
|
||||||
WriteCoeff(class LAMMPS *lmp) : Command(lmp) {};
|
WriteCoeff(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(write_data,WriteData)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class WriteData : protected Command {
|
class WriteData : public Command {
|
||||||
public:
|
public:
|
||||||
WriteData(class LAMMPS *);
|
WriteData(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(write_dump,WriteDump)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class WriteDump : protected Command {
|
class WriteDump : public Command {
|
||||||
public:
|
public:
|
||||||
WriteDump(class LAMMPS *lmp) : Command(lmp) {};
|
WriteDump(class LAMMPS *lmp) : Command(lmp) {};
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ CommandStyle(write_restart,WriteRestart)
|
|||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class WriteRestart : protected Command {
|
class WriteRestart : public Command {
|
||||||
public:
|
public:
|
||||||
WriteRestart(class LAMMPS *);
|
WriteRestart(class LAMMPS *);
|
||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
|
|||||||
Reference in New Issue
Block a user