cfl_symbolset.h
Go to the documentation of this file.
1/** @file cfl_symbolset.h @brief Class SymbolSet, TaSymbolSet */
2
3
4/* FAU Discrete Event Systems Library (libfaudes)
5
6 Copyright (C) 2006 Bernd Opitz
7 Copyright (C) 2007 Thomas Moor
8 Exclusive copyright is granted to Klaus Schmidt
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24
25
26#ifndef FAUDES_SYMBOLSET_H
27#define FAUDES_SYMBOLSET_H
28
29
30#include "cfl_definitions.h"
31#include "cfl_attributes.h"
32#include "cfl_symboltable.h"
33#include "cfl_baseset.h"
34#include <set>
35#include <map>
36#include <algorithm>
37
38namespace faudes {
39
40/** @addtogroup ContainerClasses */
41/** @{ */
42
43/**
44 * Set of symbols.
45 *
46 * The class is built on top of the faudes version
47 * TBaseSet of STL sets. It provides the essentials of the STL interface and
48 * plus token based file IO.
49 * Invalid iterators throw an exception (id 62) when used as an argument to a SymbolSet function.
50 * If the macro FAUDES_CHECKED is defined, the attempt to insert an invalid symbol
51 * an exception (id 61).
52 *
53 * Note that a symbol set holds a plain set of valid faudes symbols with no indices
54 * or symboltable associated. If you are looking for a set of items with
55 * mandatory symbolic names you most likely are better of with a NameSet or a
56 * TaNameSet. Currently, there is no attributed version of a SymbolSet.
57 *
58 * The token IO format is demonstrated by the following example
59 * of a set with name "MySymbols"
60 * \code
61 * <MySymbols>
62 * "ASymbol"
63 * "AnotherSymbol"
64 * </MySymbols>
65 * \endcode
66 * Note that you can read SymbolSet files to NameSets and vice versa.
67 *
68 */
69
70class FAUDES_API SymbolSet : public TBaseSet<std::string> {
71
73
74public:
75
76 using TBaseSet<std::string>::operator=;
77 using TBaseSet<std::string>::operator==;
78 using TBaseSet<std::string>::operator!=;
79
80 /**
81 * Constructor.
82 */
83 SymbolSet(void);
84
85 /**
86 * Copy-constructor.
87 */
88 SymbolSet(const SymbolSet& rOtherSet);
89
90 /**
91 * Copy-constructor.
92 */
93 SymbolSet(const TBaseSet<std::string>& rOtherSet);
94
95 /**
96 * Construct from file. Uses the Read(TokenReader&, const std::string&) function to read.
97 * a SymbolSet from section rLabel in file rFilename.
98 *
99 * @param rFilename
100 * Name of file to read
101 * @param rLabel
102 * Section to read
103 *
104 * @exception Exception
105 * - IO Errors (id 1)
106 * - token musmatch (id 50, 51, 52)
107 */
108 SymbolSet(const std::string& rFilename, const std::string& rLabel = "SymbolSet");
109
110 /**
111 * Virtual destructor
112 */
113 virtual ~SymbolSet(void) {};
114
115 /**
116 * Test whether the given string is a valid faudes symbol
117 * @param symbol
118 * Symbol to test
119 * @return
120 * True if valid
121 */
122 bool Valid(const std::string& symbol) const;
123
124 /**
125 * Iterators on indexset.
126 */
128
129 /**
130 * Insert specified symbol
131 *
132 * @param symbol
133 * Symbol to insert
134 * @return
135 * True if symbol was new to set
136 */
137 bool Insert(const std::string& symbol);
138
139 /**
140 * Compute an Idx type signature for a Set. This method
141 * is currently not implemented.
142 *
143 * @return
144 * Idx type set signature
145 */
146 Idx Signature(void) const {return 0;};
147
148 /**
149 * Return pretty printable symbol.
150 *
151 * @param symbol
152 * Symbol to print
153 *
154 * @return
155 * String
156 */
157 std::string Str(const std::string& symbol) const {return symbol; };
158
159 protected:
160
161
162
163 /**
164 * Copy my members. This method calls the base class to assign its members.
165 *
166 * @param rSource
167 * Source to copy from
168 */
169 void DoCopy(const SymbolSet& rSource);
170
171 /**
172 * Write to TokenWriter, see TBaseSet for public wrappers.
173 *
174 * @param tw
175 * Reference to TokenWriter
176 * @param rLabel
177 * Label of section to write, defaults to name of set
178 * @param pContext
179 * Write context for contextual information
180 *
181 * @exception Exception
182 * - IO errors (id 2)
183 */
184 void DoWrite(TokenWriter& tw, const std::string& rLabel="", const Type* pContext=0) const;
185
186 /**
187 * Read from TokenReader, see TBaseSet for public wrappers.
188 *
189 * @param rTr
190 * Reference to tokenreader
191 * @param rLabel
192 * Section to read
193 * @param pContext
194 * Read context for contextual information
195 *
196 * @exception Exception
197 * - IO errors (id 1)
198 * - token mismatch (id 50, 51, 52)
199 */
200 void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
201
202
203};
204
205
206/** @} doxygen group */
207
208
209} // namespace faudes
210
211#endif
Class TBaseSet.
#define FAUDES_API
Class SymbolTable.
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:918
TBaseSet< std::string >::Iterator Iterator
virtual ~SymbolSet(void)
Idx Signature(void) const
std::string Str(const std::string &symbol) const
uint32_t Idx

libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen