4_cgenerator.cpp

Go to the documentation of this file.
00001 /** @file 4_cgenerator.cpp
00002 
00003 Tutorial, generator with controllability attributes
00004 
00005 
00006 The faudes::System class is inherited from the faudes::Generator class and only
00007 differs by definition of the controllabilty flags for events. Because 
00008 of the inheritance, the System class's methods are a superset
00009 of the Generator.  This tutorial demonstrates  System specific methods.
00010 
00011 
00012 @ingroup Tutorials 
00013 
00014 @include 4_cgenerator.cpp
00015 
00016 */
00017 
00018 #include "libfaudes.h"
00019 
00020 
00021 // we make the faudes namespace available to our program
00022 using namespace faudes;
00023 
00024 
00025 /////////////////
00026 // main program
00027 /////////////////
00028 
00029 int main() {
00030 
00031 
00032   ////////////////////////////////////////////
00033   // Constructors & Assignment Operator
00034   ////////////////////////////////////////////
00035 
00036   // Create an empty System object
00037 
00038   System cgen1;
00039 
00040   // Create a System by reading a Generator file 
00041   // Events default to observable and uncontrollable
00042 
00043   System cgen2("data/simplemachine.gen");
00044 
00045   // Create a System by reading a System file 
00046 
00047   System cgen3("data/csimplemachine.gen");
00048 
00049   // Copy constructor & assignment operator
00050   // (same behaviour as in Generator class)
00051 
00052   System cgen4(cgen3); 
00053   cgen4 = cgen3;           
00054 
00055   // report
00056   cgen4.Write("tmp_csimplemachine.gen");
00057   cgen4.Write();
00058 
00059   ////////////////////////
00060   // Controllable events
00061   ////////////////////////
00062 
00063   // Insert an event and set it controllable 
00064 
00065   cgen1.InsControllableEvent(1); // by index
00066   cgen1.InsControllableEvent("newcevent1"); // by symbolic name
00067 
00068   // Insert an event and set it uncontrollable 
00069 
00070   cgen1.InsUncontrollableEvent(2); // by index
00071   cgen1.InsUncontrollableEvent("newcevent2"); // by symbolic name
00072 
00073   // Set an existing event controllable
00074 
00075   cgen1.SetControllable(2); // by index
00076   cgen1.SetControllable((const std::string&) "newcevent2"); // by symbolic name
00077 
00078   // Set an existing event uncontrollable
00079 
00080   cgen1.ClrControllable(1); // by index
00081   cgen1.ClrControllable((const std::string&) "newcevent1"); // by symbolic name
00082 
00083   // Test wether an event is controllable
00084 
00085   bool bool_eventcontrollable = cgen1.Controllable(1); // by index
00086   bool_eventcontrollable = cgen1.Controllable("newcevent1"); // by symbolic name
00087 
00088   // Retrieve an EventSet containing all the controllabe events of the
00089   // System
00090 
00091   EventSet eset_cevents = cgen2.ControllableEvents();
00092 
00093   // Retrieve an EventSet containing all the uncontrollabe events of the
00094   // System
00095 
00096   EventSet eset_ucevents = cgen2.UncontrollableEvents();
00097 
00098 
00099   return 0;
00100 }
00101 
00102 
00103 

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen