Loading...
Searching...
No Matches
gamssymbol.h
1/*
2 * GAMS - General Algebraic Modeling System C++ API
3 *
4 * Copyright (c) 2017-2023 GAMS Software GmbH <support@gams.com>
5 * Copyright (c) 2017-2023 GAMS Development Corp. <support@gams.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26#ifndef GAMSSYMBOL_H
27#define GAMSSYMBOL_H
28
29#include "gamsenum.h"
30#include "gamssymboliter.h"
31#include <string>
32#include <memory>
33#include <vector>
34
35namespace gams {
36
37class GAMSSet;
38class GAMSVariable;
39class GAMSSymbolRecord;
40class GAMSDatabase;
41class GAMSDomain;
42class GAMSSymbolImpl;
43class GAMSSymbolDomainViolation;
44
48class LIBSPEC GAMSSymbol
49{
50public:
52
55
58 GAMSSymbol(const GAMSSymbol &symbol);
59
61 virtual ~GAMSSymbol();
62
67
71 bool operator!=(const GAMSSymbol& other) const;
72
76 bool operator==(const GAMSSymbol& other) const;
77
80 bool isValid() const;
81
85
89
93 GAMSSymbolRecord addRecord(const std::vector<std::string>& keys);
94
98
102 GAMSSymbolRecord addRecord(const std::string& key1);
103
108 GAMSSymbolRecord addRecord(const std::string& key1, const std::string& key2);
109
115 GAMSSymbolRecord addRecord(const std::string& key1, const std::string& key2, const std::string& key3);
116
119 void deleteRecord(const std::vector<std::string>& keys);
120
121 // TODO(JM) missing overloads for ::deleteRecord
122
125 bool clear();
126
129 std::vector<GAMSDomain> domains();
130
134
138 std::vector<GAMSSymbolDomainViolation> getSymbolDVs(int maxViol = 0);
139
143 GAMSSymbolRecord firstRecord(const std::vector<std::string>& slice);
144
148
152 GAMSSymbolRecord firstRecord(const std::string& key1);
153
158 GAMSSymbolRecord firstRecord(const std::string& key1, const std::string& key2);
159
165 GAMSSymbolRecord firstRecord(const std::string& key1, const std::string& key2, const std::string& key3);
166
170 GAMSSymbolRecord lastRecord(const std::vector<std::string>& slice);
171
175
179 GAMSSymbolRecord lastRecord(const std::string& key1);
180
185 GAMSSymbolRecord lastRecord(const std::string& key1, const std::string& key2);
186
192 GAMSSymbolRecord lastRecord(const std::string& key1, const std::string& key2, const std::string& key3);
193
197 GAMSSymbolRecord findRecord(const std::vector<std::string>& keys);
198
202
206 GAMSSymbolRecord findRecord(const std::string& key1);
207
212 GAMSSymbolRecord findRecord(const std::string& key1, const std::string& key2);
213
219 GAMSSymbolRecord findRecord(const std::string& key1, const std::string& key2, const std::string& key3);
220
224 GAMSSymbolRecord mergeRecord(const std::vector<std::string>& keys);
225
229
233 GAMSSymbolRecord mergeRecord(const std::string& key1);
234
239 GAMSSymbolRecord mergeRecord(const std::string& key1, const std::string& key2);
240
246 GAMSSymbolRecord mergeRecord(const std::string& key1, const std::string& key2, const std::string& key3);
247
251 void copySymbol(const GAMSSymbol& target);
252
255
257 std::string text() const;
258
260 std::string& name() const;
261
263 int dim() const;
264
266 int numberRecords() const;
267
270 LogId logID();
271
274
275protected:
276 friend class GAMSSymbolRecordImpl;
277 friend class GAMSModelInstanceImpl;
278 friend class GAMSDatabaseImpl;
279 friend class GAMSSymbolIter<GAMSSymbol>;
280
281 GAMSSymbol(const std::shared_ptr<GAMSSymbolImpl> impl);
282
283 GAMSSymbol(GAMSDatabase &database, int dim, std::string name, std::string text,
285 GAMSEnum::SetType setType = GAMSEnum::SetType::Multi);
286
287 GAMSSymbol(GAMSDatabase &database, std::string name, std::string text, GAMSEnum::SymbolType symType,
288 GAMSEnum::VarType varType, GAMSEnum::EquType equType, const std::vector<GAMSDomain>& domains,
289 GAMSEnum::SetType setType = GAMSEnum::SetType::Multi);
290
291 GAMSSymbol(GAMSDatabase &database, void *symPtr, int dim, std::string name, std::string text,
293 GAMSEnum::SetType setType = GAMSEnum::SetType::Multi);
294
295 GAMSSymbol(const GAMSDatabase &database, void *symPtr);
296
297 void *symPtr() const;
298
299 std::vector<GAMSSymbolDomainViolation> getSymbolDVs(bool skipCleanup, int maxViol = 0);
300
301protected:
302 std::shared_ptr<GAMSSymbolImpl> mImpl;
303};
304
305} // namespace gams
306
307#endif // GAMSSYMBOL_H
VarType
Variable subtype.
Definition: gamsenum.h:83
EquType
Equation subtype.
Definition: gamsenum.h:58
SetType
Set subtype.
Definition: gamsenum.h:73
SymbolType
This enum defines the type of a symbol (The type Alias is not supported and shows as Set).
Definition: gamsenum.h:44
GAMSSymbolRecord lastRecord(const std::string &key1, const std::string &key2)
GAMSSymbolRecord findRecord(const std::string &key1, const std::string &key2)
GAMSSymbolRecord firstRecord(const std::string &key1)
GAMSSymbolRecord addRecord(const std::string &key1)
GAMSSymbolRecord addRecord(const std::string &key1, const std::string &key2, const std::string &key3)
int dim() const
Get GAMSSymbol dimension.
GAMSSymbolRecord firstRecord()
GAMSSymbolRecord addRecord(const std::string &key1, const std::string &key2)
GAMSSymbolRecord mergeRecord()
GAMSSymbolRecord lastRecord()
std::vector< GAMSSymbolDomainViolation > getSymbolDVs(int maxViol=0)
GAMSSymbolRecord findRecord()
std::string & name() const
Get GAMSSymbol name.
void copySymbol(const GAMSSymbol &target)
void deleteRecord(const std::vector< std::string > &keys)
int numberRecords() const
Retrieve the number of records of the GAMSSymbol.
GAMSSymbol(const GAMSSymbol &symbol)
GAMSSymbolIter< GAMSSymbol > begin()
GAMSSymbolRecord mergeRecord(const std::string &key1, const std::string &key2, const std::string &key3)
GAMSSymbolRecord mergeRecord(const std::vector< std::string > &keys)
GAMSSymbol operator=(const GAMSSymbol &other)
GAMSSymbolRecord findRecord(const std::vector< std::string > &keys)
std::string text() const
Get explanatory text of GAMSSymbol.
std::vector< GAMSDomain > domains()
gams::GAMSDatabase & database() const
Get GAMSDatabase containing the GAMSSymbol.
GAMSEnum::SymbolType type() const
Get the symbol type.
bool isValid() const
GAMSSymbolRecord lastRecord(const std::vector< std::string > &slice)
GAMSSymbolIter< GAMSSymbol > end()
GAMSSymbolRecord firstRecord(const std::string &key1, const std::string &key2)
GAMSSymbolRecord findRecord(const std::string &key1)
virtual ~GAMSSymbol()
Destructor.
GAMSSymbolRecord firstRecord(const std::string &key1, const std::string &key2, const std::string &key3)
bool operator==(const GAMSSymbol &other) const
GAMSSymbolRecord mergeRecord(const std::string &key1)
GAMSSymbolRecord firstRecord(const std::vector< std::string > &slice)
GAMSSymbolRecord lastRecord(const std::string &key1)
GAMSSymbolRecord addRecord()
GAMSSymbolRecord lastRecord(const std::string &key1, const std::string &key2, const std::string &key3)
bool operator!=(const GAMSSymbol &other) const
GAMSSymbolRecord mergeRecord(const std::string &key1, const std::string &key2)
GAMSSymbolRecord addRecord(const std::vector< std::string > &keys)
GAMSSymbol()
Standard constructor.
GAMSSymbolRecord findRecord(const std::string &key1, const std::string &key2, const std::string &key3)
Definition: gams.h:91