1 /* -*- c++ -*- ----------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3    https://www.lammps.org/, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13 
14 #ifndef LMP_ARG_INFO_H
15 #define LMP_ARG_INFO_H
16 
17 /*! \file arg_info.h */
18 
19 #include <string>
20 
21 namespace LAMMPS_NS {
22 class ArgInfo {
23  public:
24   // clang-format off
25   /*! constants for argument types */
26   enum ArgTypes {
27     ERROR          =-2,
28     UNKNOWN        =-1,
29     NONE           = 0,
30     X              = 1<<0,
31     V              = 1<<1,
32     F              = 1<<2,
33     COMPUTE        = 1<<3,
34     FIX            = 1<<4,
35     VARIABLE       = 1<<5,
36     KEYWORD        = 1<<6,
37     TYPE           = 1<<7,
38     MOLECULE       = 1<<8,
39     DNAME          = 1<<9,
40     INAME          = 1<<10,
41     DENSITY_NUMBER = 1<<11,
42     DENSITY_MASS   = 1<<12,
43     MASS           = 1<<13,
44     TEMPERATURE    = 1<<14,
45     BIN1D          = 1<<15,
46     BIN2D          = 1<<16,
47     BIN3D          = 1<<17,
48     BINSPHERE      = 1<<18,
49     BINCYLINDER    = 1<<19
50   };
51   // clang-format on
52   ArgInfo(const std::string &arg, int allowed = COMPUTE | FIX | VARIABLE);
~ArgInfo()53   virtual ~ArgInfo() {}
54 
55  public:
56   /*! get type of reference
57      *
58      * Return a type constant for the reference. This may be either
59      * COMPUTE, FIX, VARIABLE (if not restricted to a subset of those
60      * by the "allowed" argument of the constructor) or NONE, if it
61      * if not a recognized or allowed reference, or UNKNOWN, in case
62      * some error happened identifying or parsing the values of the indices
63      *
64      * \return  integer with a constant from ArgTypes enumerator */
65 
get_type()66   int get_type() const { return type; }
67 
68   /*! get dimension of reference
69      *
70      * This will return either 0, 1, 2 depending on whether the
71      * reference has no, one or two "[{number}]" postfixes.
72      *
73      * \return  integer with the dimensionality of the reference */
get_dim()74   int get_dim() const { return dim; }
75 
76   /*! get index of first dimension
77      *
78      * This will return the number in the first "[{number}]"
79      * postfix or 0 if there is no postfix.
80      *
81      * \return  integer with index or the postfix or 0 */
get_index1()82   int get_index1() const { return index1; }
83 
84   /*! get index of second dimension
85      *
86      * This will return the number in the second "[{number}]"
87      * postfix or -1 if there is no second postfix.
88      *
89      * \return  integer with index of the postfix or -1 */
get_index2()90   int get_index2() const { return index2; }
91 
92   /*! return reference to the ID or name of the reference
93      *
94      * This string is pointing to an internal storage element and
95      * is only valid to use while the ArgInfo class instance is
96      * in scope. If you need a long-lived string make a copy
97      * with copy_name().
98      *
99      * \return  C-style char * string */
get_name()100   const char *get_name() const { return name.c_str(); }
101 
102   char *copy_name();
103 
104  private:
105   std::string name;
106   int type, dim, index1, index2;
107 
108   // disabled standard methods
ArgInfo()109   ArgInfo() {}
ArgInfo(const ArgInfo &)110   ArgInfo(const ArgInfo &) {}
111   void operator=(const ArgInfo &) {}
112 };
113 }    // namespace LAMMPS_NS
114 #endif
115