ios_1_system.cpp File Reference


More...

#include "libfaudes.h"

Go to the source code of this file.

Functions

int main ()
 

Detailed Description


Tutorial, I/O systems

/** @file ios_1_system.cpp
Tutorial, I/O systems
@ingroup Tutorials
@include ios_1_system.cpp
*/
#include "libfaudes.h"
// make the faudes namespace available to our program
using namespace faudes;
/////////////////
// main program
/////////////////
int main() {
////////////////////////////////////////////
// Constructors
////////////////////////////////////////////
// construct from file
IoSystem sys1("data/ios_system1.gen");
// copy construct
IoSystem sys2(sys1);
// assign
IoSystem sys3 = sys2;
// inspect result on console
std::cout << "################################\n";
std::cout << "# tutorial, io system 1 \n";
sys3.Write();
std::cout << "################################\n";
// graph output requires, "dot" binary in $PATH
try {
sys1.GraphWrite("tmp_ios_system1.svg");
} catch(faudes::Exception& exception) {
std::cout << "warning: cannot execute graphviz' dot. " << std::endl;
}
// output for doku
sys1.Write("tmp_ios_system1.gen");
///////////////////////////////////////////////
// Inspect/Edit I/O attributes
///////////////////////////////////////////////
// events, result on console
std::cout << "################################\n";
std::cout << "# input events, output events\n";
sys3.InputEvents().Write();
sys3.OutputEvents().Write();
std::cout << "################################\n";
// maniputlate some state attributes
// (to configure set state, see also IoSystem())
sys3.SetOutputState("s1");
sys3.SetInputState("s3");
sys3.ClrOutputState("s2");
// swap event status all together
EventSet inevs = sys3.InputEvents();
EventSet outevs = sys3.OutputEvents();
sys3.ClrOutputEvent(outevs);
sys3.SetInputEvent(outevs);
sys3.ClrInputEvent(inevs);
sys3.SetOutputEvent(inevs);
// inspect result on console
std::cout << "################################\n";
std::cout << "# tutorial, manipulated io system 1 \n";
sys3.Write();
std::cout << "################################\n";
///////////////////////////////////////////////
// Test I/O structure
///////////////////////////////////////////////
// the test will set the state attributes accordingly
bool isio=IsIoSystem(sys1);
// sys1 from file will pass the test
if(!isio) std::cout << "#### test FAILED (test case error) \n";
// report
std::cout << "################################\n";
std::cout << "# tutorial, sys1 test io properties \n";
sys1.InputStates().Write();
sys1.OutputStates().Write();
std::cout << "################################\n";
// however, the input is not free
bool isfree=IsInputLocallyFree(sys1);
if(isfree) std::cout << "#### test PASSED (test case error) \n";
IoFreeInput(sys1);
// report
std::cout << "################################\n";
std::cout << "# tutorial, sys1 with free input\n";
sys1.Write();
std::cout << "################################\n";
// output for doku
sys1.Write("tmp_ios_system1f.gen");
// however, the input is still not omega-free
StateSet qerr;
bool iswfree=IsInputOmegaFree(sys1,qerr);
if(iswfree) std::cout << "#### test PASSED (test case error) \n";
// report
std::cout << "################################\n";
std::cout << "# tutorial, sys1 error states\n";
sys1.WriteStateSet(qerr);
std::cout << "################################\n";
// Record testcase
FAUDES_TEST_DUMP("sys1", sys1);
FAUDES_TEST_DUMP("isio", isio);
FAUDES_TEST_DUMP("isfree", isfree);
FAUDES_TEST_DUMP("iswfree", iswfree);
FAUDES_TEST_DUMP("qerr", qerr);
return 0 ;
}
#define FAUDES_TEST_DUMP(mes, dat)
Test protocol record macro ("mangle" filename for platform independance)
Definition: cfl_helper.h:483
Faudes exception class.
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
int main(int argc, char *argv[])
IndexSet StateSet
Definition: cfl_indexset.h:271
NameSet EventSet
Convenience typedef for plain event sets.
Definition: cfl_nameset.h:531
bool IsInputOmegaFree(IoSystem &rIoSystem)
Test whether the system behaviour has exhibits a free input.
bool IsInputLocallyFree(IoSystem &rIoSystem)
Test whether the system has a locally free input.
bool IsIoSystem(const IoSystem &rIoSystem, StateSet &rQU, StateSet &rQY, StateSet &rQErr)
Test whether the system satisfies basic I/O conditions.
void IoFreeInput(IoSystem &rIoSystem)
Enable all input events for each input state.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
TioGenerator< AttributeVoid, AttributeIosState, AttributeIosEvent, AttributeVoid > IoSystem
Definition: ios_system.h:777

Definition in file ios_1_system.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 23 of file ios_1_system.cpp.

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen