ios_1_system.cpp
Go to the documentation of this file.
1/** @file ios_1_system.cpp
2
3Tutorial, I/O systems
4
5
6@ingroup Tutorials
7
8@include ios_1_system.cpp
9
10*/
11
12#include "libfaudes.h"
13
14// make the faudes namespace available to our program
15using namespace faudes;
16
17
18
19/////////////////
20// main program
21/////////////////
22
23int main() {
24
25 ////////////////////////////////////////////
26 // Constructors
27 ////////////////////////////////////////////
28
29 // construct from file
30 IoSystem sys1("data/ios_system1.gen");
31
32 // copy construct
33 IoSystem sys2(sys1);
34
35 // assign
36 IoSystem sys3 = sys2;
37
38 // inspect result on console
39 std::cout << "################################\n";
40 std::cout << "# tutorial, io system 1 \n";
41 sys3.Write();
42 std::cout << "################################\n";
43
44 // graph output requires, "dot" binary in $PATH
45 try {
46 sys1.GraphWrite("tmp_ios_system1.svg");
47 } catch(faudes::Exception& exception) {
48 std::cout << "warning: cannot execute graphviz' dot. " << std::endl;
49 }
50
51 // output for doku
52 sys1.Write("tmp_ios_system1.gen");
53
54
55 ///////////////////////////////////////////////
56 // Inspect/Edit I/O attributes
57 ///////////////////////////////////////////////
58
59 // events, result on console
60 std::cout << "################################\n";
61 std::cout << "# input events, output events\n";
62 sys3.InputEvents().Write();
63 sys3.OutputEvents().Write();
64 std::cout << "################################\n";
65
66 // maniputlate some state attributes
67 // (to configure set state, see also IoSystem())
68 sys3.SetOutputState("s1");
69 sys3.SetInputState("s3");
70 sys3.ClrOutputState("s2");
71
72 // swap event status all together
73 EventSet inevs = sys3.InputEvents();
74 EventSet outevs = sys3.OutputEvents();
75 sys3.ClrOutputEvent(outevs);
76 sys3.SetInputEvent(outevs);
77 sys3.ClrInputEvent(inevs);
78 sys3.SetOutputEvent(inevs);
79
80 // inspect result on console
81 std::cout << "################################\n";
82 std::cout << "# tutorial, manipulated io system 1 \n";
83 sys3.Write();
84 std::cout << "################################\n";
85
86 ///////////////////////////////////////////////
87 // Test I/O structure
88 ///////////////////////////////////////////////
89
90 // the test will set the state attributes accordingly
91 bool isio=IsIoSystem(sys1);
92
93 // sys1 from file will pass the test
94 if(!isio) std::cout << "#### test FAILED (test case error) \n";
95
96 // report
97 std::cout << "################################\n";
98 std::cout << "# tutorial, sys1 test io properties \n";
99 sys1.InputStates().Write();
100 sys1.OutputStates().Write();
101 std::cout << "################################\n";
102
103 // however, the input is not free
104 bool isfree=IsInputLocallyFree(sys1);
105 if(isfree) std::cout << "#### test PASSED (test case error) \n";
106 IoFreeInput(sys1);
107
108 // report
109 std::cout << "################################\n";
110 std::cout << "# tutorial, sys1 with free input\n";
111 sys1.Write();
112 std::cout << "################################\n";
113
114 // output for doku
115 sys1.Write("tmp_ios_system1f.gen");
116
117 // however, the input is still not omega-free
118 StateSet qerr;
119 bool iswfree=IsInputOmegaFree(sys1,qerr);
120 if(iswfree) std::cout << "#### test PASSED (test case error) \n";
121
122 // report
123 std::cout << "################################\n";
124 std::cout << "# tutorial, sys1 error states\n";
125 sys1.WriteStateSet(qerr);
126 std::cout << "################################\n";
127
128 // Record testcase
129 FAUDES_TEST_DUMP("sys1", sys1);
130 FAUDES_TEST_DUMP("isio", isio);
131 FAUDES_TEST_DUMP("isfree", isfree);
132 FAUDES_TEST_DUMP("iswfree", iswfree);
133 FAUDES_TEST_DUMP("qerr", qerr);
134
135 return 0 ;
136
137}
138
139
140
141
#define FAUDES_TEST_DUMP(mes, dat)
Definition cfl_utils.h:505
StateSet InputStates(void) const
void ClrInputEvent(Idx index)
StateSet OutputStates(void) const
void SetInputState(Idx index)
void ClrOutputEvent(Idx index)
Definition ios_system.h:923
void ClrOutputState(Idx index)
void SetOutputEvent(Idx index)
Definition ios_system.h:900
EventSet OutputEvents(void) const
Definition ios_system.h:870
EventSet InputEvents(void) const
Definition ios_system.h:946
void SetOutputState(Idx index)
void SetInputEvent(Idx index)
Definition ios_system.h:977
void Write(const Type *pContext=0) const
void WriteStateSet(const StateSet &rStateSet) const
void GraphWrite(const std::string &rFileName, const std::string &rOutFormat="", const std::string &rDotExec="dot") const
bool IsInputOmegaFree(IoSystem &rIoSystem)
bool IsInputLocallyFree(IoSystem &rIoSystem)
bool IsIoSystem(const IoSystem &rIoSystem, StateSet &rQU, StateSet &rQY, StateSet &rQErr)
void IoFreeInput(IoSystem &rIoSystem)
int main()

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen