OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
SelectionToken.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#ifndef SELECTION_TOKEN_HPP
46#define SELECTION_TOKEN_HPP
47
48#include <any>
49
50namespace OpenMD {
51
52 /**
53 * @class Token
54 * @todo document
55 * @note translate from jmol
56 */
57 class Token {
58 public:
59 int tok {unknown};
60 int intValue {};
61 std::any value {};
62
63 Token() = default;
64 explicit Token(int myTok) : tok {myTok} {}
65 Token(int myTok, int myIntValue) : tok {myTok}, intValue {myIntValue} {}
66 Token(int myTok, const std::any& myValue) : tok {myTok}, value {myValue} {}
67 Token(int MyTok, int myIntValue, const std::any& myValue) :
68 tok {MyTok}, intValue {myIntValue}, value {myValue} {}
69
70 static constexpr int nada = 0;
71 static constexpr int identifier = 1;
72 static constexpr int integer = 2;
73 static constexpr int decimal = 3;
74 static constexpr int string = 4;
75 static constexpr int unknown = 5;
76 static constexpr int keyword = 6;
77 static constexpr int whitespace = 7;
78 static constexpr int comment = 8;
79 static constexpr int endofline = 9;
80 static constexpr int endofstatement = 10;
81
82 static constexpr int command = (1 << 8);
83 static constexpr int expressionCommand = (1 << 9); // expression command
84 static constexpr int expression = (1 << 10); /// expression term
85
86 // generally, the minus sign is used to denote atom ranges
87 // this property is used for the few commands which allow negative integers
88 static constexpr int negnums = (1 << 11);
89
90 // expression involves coordinates which will change every frame, such as
91 // withins
92 static constexpr int dynamic = (1 << 12);
93
94 // every property is also valid in an expression context
95 static constexpr int atomproperty = (1 << 12) | expression | negnums;
96 // every predefined is also valid in an expression context
97 static constexpr int comparator = (1 << 13) | expression;
98 static constexpr int predefinedset = (1 << 14) | expression;
99 static constexpr int embeddedExpression = (1 << 15); // embedded expression
100 static constexpr int index = (1 << 16) | expression;
101 // rasmol commands
102 static constexpr int define = command | expressionCommand | 1;
103 static constexpr int select = command | expressionCommand | 2;
104
105 // predefine
106 // static constexpr int selected = predefinedset |0;
107
108 // atom expression operators
109 static constexpr int leftparen = expression | 0;
110 static constexpr int rightparen = expression | 1;
111 static constexpr int to = expression | 2;
112 static constexpr int opAnd = expression | 3;
113 static constexpr int opOr = expression | 4;
114 static constexpr int opNot = expression | 5;
115 static constexpr int within = expression | dynamic | 6;
116 static constexpr int asterisk = expression | 7;
117 static constexpr int dot = expression | 8;
118 static constexpr int all = expression | 9;
119 static constexpr int none = expression | 10;
120 static constexpr int name = expression | 11;
121 static constexpr int hull = expression | dynamic | 12;
122 static constexpr int alphahull = expression | dynamic | 13;
123
124 // miguel 2005 01 01
125 // these are used to demark the beginning and end of expressions
126 // they do not exist in the source code, but are emitted by the
127 // expression compiler
128 static constexpr int expressionBegin = expression | 100;
129 static constexpr int expressionEnd = expression | 101;
130
131 static constexpr int mass = atomproperty | 0;
132 static constexpr int charge = atomproperty | dynamic | 1;
133 static constexpr int x = atomproperty | dynamic | 2;
134 static constexpr int y = atomproperty | dynamic | 3;
135 static constexpr int z = atomproperty | dynamic | 4;
136 static constexpr int r = atomproperty | dynamic | 5;
137 static constexpr int wrappedX = atomproperty | dynamic | 6;
138 static constexpr int wrappedY = atomproperty | dynamic | 7;
139 static constexpr int wrappedZ = atomproperty | dynamic | 8;
140 static constexpr int atomno = atomproperty | 9;
141
142 static constexpr int opGT = comparator | dynamic | 0;
143 static constexpr int opGE = comparator | dynamic | 1;
144 static constexpr int opLE = comparator | dynamic | 2;
145 static constexpr int opLT = comparator | dynamic | 3;
146 static constexpr int opEQ = comparator | dynamic | 4;
147 static constexpr int opNE = comparator | dynamic | 5;
148
149 static Token tokenExpressionBegin;
150 static Token tokenExpressionEnd;
151 };
152} // namespace OpenMD
153
154#endif
static constexpr int negnums
expression term
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.