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 TBaseSet<std::string>& rOtherSet);
89
90 /**
91 * Construct from file. Uses the Read(TokenReader&, const std::string&) function to read.
92 * a SymbolSet from section rLabel in file rFilename.
93 *
94 * @param rFilename
95 * Name of file to read
96 * @param rLabel
97 * Section to read
98 *
99 * @exception Exception
100 * - IO Errors (id 1)
101 * - token musmatch (id 50, 51, 52)
102 */
103 SymbolSet(const std::string& rFilename, const std::string& rLabel = "SymbolSet");
104
105 /**
106 * Virtual destructor
107 */
108 virtual ~SymbolSet(void) {};
109
110 /**
111 * Test whether the given string is a valid faudes symbol
112 * @param symbol
113 * Symbol to test
114 * @return
115 * True if valid
116 */
117 bool Valid(const std::string& symbol) const;
118
119 /**
120 * Iterators on indexset.
121 */
123
124 /**
125 * Insert specified symbol
126 *
127 * @param symbol
128 * Symbol to insert
129 * @return
130 * True if symbol was new to set
131 */
132 bool Insert(const std::string& symbol);
133
134 /**
135 * Compute an Idx type signature for a Set. This method
136 * is currently not implemented.
137 *
138 * @return
139 * Idx type set signature
140 */
141 Idx Signature(void) const {return 0;};
142
143 /**
144 * Return pretty printable symbol.
145 *
146 * @param symbol
147 * Symbol to print
148 *
149 * @return
150 * String
151 */
152 std::string Str(const std::string& symbol) const {return symbol; };
153
154 protected:
155
156
157
158 /**
159 * Assign my members. This method calls the base class to assign its members.
160 *
161 * @param rSource
162 * Source to copy from
163 */
164 void DoAssign(const SymbolSet& rSource);
165
166 /**
167 * Write to TokenWriter, see TBaseSet for public wrappers.
168 *
169 * @param tw
170 * Reference to TokenWriter
171 * @param rLabel
172 * Label of section to write, defaults to name of set
173 * @param pContext
174 * Write context for contextual information
175 *
176 * @exception Exception
177 * - IO errors (id 2)
178 */
179 void DoWrite(TokenWriter& tw, const std::string& rLabel="", const Type* pContext=0) const;
180
181 /**
182 * Read from TokenReader, see TBaseSet for public wrappers.
183 *
184 * @param rTr
185 * Reference to tokenreader
186 * @param rLabel
187 * Section to read
188 * @param pContext
189 * Read context for contextual information
190 *
191 * @exception Exception
192 * - IO errors (id 1)
193 * - token mismatch (id 50, 51, 52)
194 */
195 void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
196
197
198};
199
200
201/** @} doxygen group */
202
203
204} // namespace faudes
205
206#endif
Class TBaseSet.
#define FAUDES_API
Class SymbolTable.
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:879
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.33k --- 2025.09.16 --- c++ api documentaion by doxygen