4_cgenerator.cpp
Go to the documentation of this file.
1 /** @file 4_cgenerator.cpp
2 
3 Tutorial, generator with controllability attributes
4 
5 
6 The faudes::System class is inherited from the faudes::Generator class and only
7 differs by definition of the controllabilty flags for events. Because
8 of the inheritance, the System class's methods are a superset
9 of the Generator. This tutorial demonstrates System specific methods.
10 
11 
12 @ingroup Tutorials
13 
14 @include 4_cgenerator.cpp
15 
16 */
17 
18 #include "libfaudes.h"
19 
20 
21 // we make the faudes namespace available to our program
22 using namespace faudes;
23 
24 
25 /////////////////
26 // main program
27 /////////////////
28 
29 int main() {
30 
31 
32  ////////////////////////////////////////////
33  // Constructors & Assignment Operator
34  ////////////////////////////////////////////
35 
36  // Create an empty System object
37 
38  System cgen1;
39 
40  // Create a System by reading a Generator file
41  // Events default to observable and uncontrollable
42 
43  System cgen2("data/simplemachine.gen");
44 
45  // Create a System by reading a System file
46 
47  System cgen3("data/csimplemachine.gen");
48 
49  // Copy constructor & assignment operator
50  // (same behaviour as in Generator class)
51 
52  System cgen4(cgen3);
53  cgen4 = cgen3;
54 
55  // report
56  cgen4.Write("tmp_csimplemachine.gen");
57  cgen4.Write();
58 
59  ////////////////////////
60  // Controllable events
61  ////////////////////////
62 
63  // Insert an event and set it controllable
64 
65  cgen1.InsControllableEvent(1); // by index
66  cgen1.InsControllableEvent("newcevent1"); // by symbolic name
67 
68  // Insert an event and set it uncontrollable
69 
70  cgen1.InsUncontrollableEvent(2); // by index
71  cgen1.InsUncontrollableEvent("newcevent2"); // by symbolic name
72 
73  // Set an existing event controllable
74 
75  cgen1.SetControllable(2); // by index
76  cgen1.SetControllable((const std::string&) "newcevent2"); // by symbolic name
77 
78  // Set an existing event uncontrollable
79 
80  cgen1.ClrControllable(1); // by index
81  cgen1.ClrControllable((const std::string&) "newcevent1"); // by symbolic name
82 
83  // Test wether an event is controllable
84 
85  bool bool_eventcontrollable = cgen1.Controllable(1); // by index
86  bool_eventcontrollable = cgen1.Controllable("newcevent1"); // by symbolic name
87 
88  // Retrieve an EventSet containing all the controllabe events of the
89  // System
90 
91  EventSet eset_cevents = cgen2.ControllableEvents();
92 
93  // Retrieve an EventSet containing all the uncontrollabe events of the
94  // System
95 
96  EventSet eset_ucevents = cgen2.UncontrollableEvents();
97 
98 
99  return 0;
100 }
101 
102 
103 
int main()
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
Generator with controllability attributes.
void ClrControllable(Idx index)
Mark event uncontrollable (by index)
EventSet UncontrollableEvents(void) const
Get EventSet with uncontrollable events.
EventSet ControllableEvents(void) const
Get EventSet with controllable events.
void SetControllable(Idx index)
Mark event controllable (by index)
void InsUncontrollableEvent(Idx index)
Add an existing uncontrollable event to generator.
void InsControllableEvent(Idx index)
Add an existing controllable event to generator.
bool Controllable(Idx index) const
Is event controllable (by index)
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen