68 std::cout <<
"################################\n";
69 std::cout <<
"# tutorial, alphabets A1,A2 and A3 \n";
73 std::cout <<
"################################\n";
77 EventSet::Iterator eit;
78 std::cout <<
"################################\n";
79 std::cout <<
"# tutorial, iterators \n";
80 for (eit = alphabet1.
Begin(); eit != alphabet1.
End(); eit++) {
81 std::cout << alphabet1.
SymbolicName(*eit) <<
": " << *eit << std::endl;
83 std::cout <<
"################################\n";
87 alphabet3.
Read(
"data/simplemachine.gen",
"Alphabet");
90 EventSet alphabet4(
"data/simplemachine.gen",
"Alphabet");
93 alphabet2.
Write(
"tmp_alphabet.txt");
96 std::cout <<
"################################\n";
97 std::cout <<
"# tutorial, alphabets of simple machine \n";
99 std::cout <<
"################################\n";
103 if(alphabet1 <= alphabet2) {
104 std::cout <<
"################################\n";
105 std::cout <<
"alphabet1 includes alphabet2" << std::endl;
106 std::cout <<
"################################\n";
109 std::cout <<
"################################\n";
110 std::cout <<
"alphabet1 does not include alphabet2" << std::endl;
111 std::cout <<
"################################\n";
115 alphabet2.
Erase(
"e");
124 if (alphabet2.
Exists(
"d")) {
125 std::cout <<
"alphabet2: event d exists" << std::endl;
130 std::cout <<
"################################\n";
131 std::cout <<
"# tutorial, updated alphabets 1 and 2 \n";
134 std::cout <<
"################################\n";
138 EventSet adifference = alphabet1 - alphabet2;
139 std::cout <<
"################################\n";
140 std::cout <<
"set difference: " << adifference.
ToString() << std::endl;
141 std::cout <<
"################################\n";
145 EventSet aunion = alphabet1 + alphabet2;
146 std::cout <<
"################################\n";
147 std::cout <<
"set union: " << aunion.
ToString() << std::endl;
148 std::cout <<
"################################\n";
151 EventSet aintersection = alphabet1 * alphabet2;
152 std::cout <<
"################################\n";
153 std::cout <<
"set intersection: " << aintersection.
ToString() << std::endl;
154 std::cout <<
"################################\n";
167 std::cout <<
"################################\n";
168 std::cout <<
"# tutorial, state sets \n";
179 for(
int i=0; i<25; i++) stateset1.
Insert();
183 StateSet::Iterator sit;
184 std::cout <<
"stateset1: ";
185 for (sit = stateset1.
Begin(); sit != stateset1.
End(); ++sit) {
186 std::cout << stateset1.
Str(*sit) <<
" ";
188 std::cout << std::endl;
191 std::cout <<
"stateset1: " << stateset1.
ToString() << std::endl;
194 stateset1.
Write(
"tmp_stateset.txt");
198 stateset2.
Read(
"tmp_stateset.txt");
204 stateset2.
Erase(state2);
213 if (stateset3.
Exists(state1)) {
214 std::cout <<
"stateset3: state " << state1 <<
" exists" << std::endl;
217 std::cout <<
"################################\n\n";
225 std::cout <<
"################################\n";
226 std::cout <<
"# tutorial, attributes \n";
232 FStateSet fstateset1(
"tmp_stateset.txt");
235 FStateSet fstateset3(stateset3);
238 std::cout <<
"fstateset3: " << fstateset3.ToString() << std::endl;
241 fstateset3.Attributep(60)->Set(0xff);
246 Idx fstate = fstateset3.Insert(fattr);
249 std::cout <<
"fstateset3: attribute of state 60: "
250 << fstateset3.Attribute(60).ToString() << std::endl;
251 std::cout <<
"fstateset3: attribute of state " << fstate
252 <<
": " << fstateset3.Attribute(fstate).ToString() << std::endl;
253 std::cout <<
"fstateset3: " << fstateset3.ToString() << std::endl;
256 fstateset3.Write(
"tmp_fstateset.txt");
259 stateset3 = fstateset3;
262 std::cout <<
"stateset3: " << stateset3.
ToString() << std::endl;
265 if(stateset3==fstateset3)
266 std::cout <<
"stateset3 indeed equals fstateset3 " << std::endl;
270 std::cout <<
"stateset3 indeed has different attributes as fstateset3 " << std::endl;
274 FStateSet fstateset4;
277 rfstateset4 = rfstateset3;
280 rfstateset3.
Erase(50);
283 if(fstateset4.EqualAttributes(fstateset3))
284 std::cout <<
"fstateset4 indeed has equal attributes with fstateset3 " << std::endl;
286 std::cout <<
"rfstateset4 indeed has equal attributes with rfstateset3 " << std::endl;
289 std::cout <<
"fstateset4: " << fstateset4.ToString() << std::endl;
290 std::cout <<
"################################\n\n";
295 FAUDES_TEST_DUMP(
"attrbibutes eq2", fstateset4.EqualAttributes(fstateset3));
303 std::cout <<
"################################\n";
304 std::cout <<
"# tutorial, vectors \n";
315 std::cout <<
"# event set no 1 (counting from 0):\n";
316 alphvect.
At(1).Write();
319 alphvect.
At(1).Insert(
"delta_1");
322 std::cout <<
"# all three event sets:\n";
329 alphvect.
Write(
"tmp_alphvect.txt");
336 std::cout <<
"# EventSetVector can take Generator elements [fail]\n";
338 std::cout <<
"# EventSetVector cannot take Generator elements [expected]\n";
345 std::cout <<
"################################\n";
353 std::cout <<
"################################\n";
354 std::cout <<
"# tutorial, deferred copy stress test \n";
358 for(
Idx state=1; state<45; state++) {
371 std::vector<StateSet::Iterator> edIts;
374 StateSet::Iterator cit=setB.
Begin();
375 for(;cit!=setB.
End(); cit++) {
376 if(*cit % 5 !=0)
continue;
377 edIts.push_back(cit);
392 for(;cit!=setB.
End(); cit++) {
393 if(*cit % 5 ==0)
continue;
394 if(*cit % 2 !=0)
continue;
395 edIts.push_back(cit);
408 std::vector<StateSet::Iterator>::iterator iit=edIts.begin();
409 for(;iit!=edIts.end(); iit++) {
410 Idx oldstate = **iit;
411 setC.
Erase(oldstate);
412 setC.
Insert(100+oldstate);
418 std::cout <<
"################################\n";
#define FAUDES_TEST_DUMP(mes, dat)
Test protocol record macro ("mangle" filename for platform independance)
void Set(fType mask)
Set multiple flags.
std::string Str(const Idx &rIndex) const
Return pretty printable index.
Idx Insert(void)
Insert new index to set.
Set of indices with symbolic names.
bool Exists(const Idx &rIndex) const
Test existence of index.
void SymbolicName(Idx index, const std::string &rName)
Set new name for existing index.
bool Insert(const Idx &rIndex)
Add an element by index.
Idx Index(const std::string &rName) const
Index lookup.
virtual bool Erase(const Idx &rIndex)
Delete element by index.
virtual bool ElementTry(const Type &rElement) const
Test whether the specified element is acceptebla for this vector.
virtual const T & At(const Position &pos) const
Access element.
Set of indices with attributes.
Generator with controllability attributes.
void DWrite(const Type *pContext=0) const
Write configuration data to console, debugging format.
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to a string.
void Write(const Type *pContext=0) const
Write configuration data to console.
void FilenameAt(const Position &pos, const std::string &rFileName)
Specify a filename.
virtual void PushBack(const Type &rElem)
Append specified entry.
void Lock(void) const
Detach and lock any further reallocation.
bool Exists(const T &rElem) const
Test existence of element.
virtual void Clear(void)
Clear all set.
Iterator End(void) const
Iterator to the end of set.
bool EqualAttributes(const TBaseSet &rOtherSet) const
Attribute access.
Iterator Begin(void) const
Iterator to the begin of set.
virtual bool Erase(const T &rElem)
Erase element by reference.
const std::string & Name(void) const
Return name of TBaseSet.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)