5_attributes.cpp

Go to the documentation of this file.
00001 
00019 #include "libfaudes.h"
00020 
00021 
00022 // for simplicity we make the faudes namespace available to our program
00023 
00024 using namespace faudes;
00025 
00026 
00028 // main program
00030 
00031 int main() {
00032 
00033   // need more text!!!
00034   // typedef for a generator with event flags
00035   typedef faudes::TaGenerator<AttributeVoid,AttributeVoid,AttributeFlags,AttributeVoid> fGenerator; 
00036   typedef faudes::TaEventSet<AttributeFlags> fEventSet;
00037 
00038 
00039   // instantiate generator object
00040   fGenerator fg1;
00041 
00042   // read from std generator file, all attributes take the default value
00043   fg1.Read("data/simplemachine.gen");
00044 
00045 
00046   // set a flag: 1. read the attribute (e.g. by event index)
00047   AttributeFlags aflag= fg1.EventAttribute(1); 
00048 
00049   // set a flag: 2. use attribute methods to manipulate
00050   aflag.Set(0x0000000f);
00051 
00052   // set a flag: 3. copy the new attribute to the generators alphabet
00053   // note: if the attribute turns out to be the default attribute, no
00054   // memory will be allocated
00055   fg1.EventAttribute(1,aflag);
00056 
00057   // set a flag: alternatively, use generator method 
00058   // note that even if the attrute became the default attribute, memory is allocated
00059 
00060   fg1.EventAttributep(1)->Set(0x00000f000);
00061 
00062   // get a flag: use generator method
00063 
00064   AttributeFlags bflag= fg1.EventAttribute(1); 
00065 
00066   // retrieve a const reference to the Generator's alphabet, includes attributes 
00067 
00068   TaEventSet<AttributeFlags>  eset_ref_alph = fg1.Alphabet();
00069 
00070   // Retrieve a copy of the Generator's alphabet without attributes
00071 
00072   EventSet eset_copy_alph = fg1.Alphabet();
00073 
00074 
00075   // report flag to console
00076       
00077   std::cout << "################################\n";
00078   std::cout << "# tutorial, show flags \n";
00079   std::cout << bflag.ToString() << "\n";
00080   std::cout << "################################\n";
00081 
00082 
00083   // write to generator file, incl attributes
00084 
00085   fg1.Write("tmp_fsimplemachine.gen");
00086 
00087   // read back
00088 
00089   fg1.Read("tmp_fsimplemachine.gen");
00090 
00091   // report to console
00092 
00093   std::cout << "################################\n";
00094   std::cout << "# tutorial, show generator with  flags \n";
00095   fg1.DWrite();
00096   std::cout << "################################\n";
00097 
00098 
00099   // when reading attributed files to std generator, attributes are ignored
00100 
00101   Generator g1;
00102   g1.Read("tmp_fsimplemachine.gen");
00103 
00104   // report to console
00105 
00106   std::cout << "################################\n";
00107   std::cout << "# tutorial, show generator without flags \n";
00108   g1.DWrite();
00109   std::cout << "################################\n";
00110 
00111 }
00112 

Generated on Fri May 9 11:26:47 2008 for libFAUDES 2.09b by  doxygen 1.4.4