24 #ifndef FAUDES_CGENERATOR_H
25 #define FAUDES_CGENERATOR_H
62 using AttributeFlags::operator=;
63 using AttributeFlags::operator==;
64 using AttributeFlags::operator!=;
88 bool Controllable(
void)
const {
return ( (mFlags & mControllableFlag) != 0 ); }
104 bool Observable(
void)
const {
return ( (mFlags & mObservableFlag) != 0 ); }
121 bool Forcible(
void)
const {
return ( (mFlags & mForcibleFlag) != 0 ); }
137 bool Highlevel(
void)
const {
return ( (mFlags & mAbstractionFlag) != 0 ); }
142 bool Lowlevel(
void)
const {
return ( (mFlags & mAbstractionFlag) == 0 ); }
148 virtual bool IsDefault(
void)
const {
return mFlags==mDefCFlags;};
151 const static fType mControllableFlag =0x01;
152 const static fType mObservableFlag =0x02;
153 const static fType mForcibleFlag =0x04;
154 const static fType mAbstractionFlag =0x08;
158 const static fType mDefCFlags =0x0a;
161 const static fType mAllCFlags =0x0f;
199 virtual void DoRead(
TokenReader& rTr,
const std::string& rLabel=
"",
const Type* pContext=0);
215 virtual void DoWrite(
TokenWriter& rTw,
const std::string& rLabel=
"",
const Type* pContext=0)
const;
232 virtual void DoXWrite(
TokenWriter& rTw,
const std::string& rLabel=
"",
const Type* pContext=0)
const;
251 #ifdef FAUDES_COMPATIBILITY
277 template <
class GlobalAttr,
class StateAttr,
class EventAttr,
class TransAttr>
340 return dynamic_cast< const TcGenerator*
> (pOther); };
381 void InsControllableEvent(
Idx index);
393 Idx InsControllableEvent(
const std::string& rName);
402 void InsUncontrollableEvent(
Idx index);
414 Idx InsUncontrollableEvent(
const std::string& rName);
422 void SetControllable(
Idx index);
430 void SetControllable(
const std::string& rName);
438 void SetControllable(
const EventSet& rEvents);
446 void ClrControllable(
Idx index);
454 void ClrControllable(
const std::string& rName);
462 void ClrControllable(
const EventSet& rEvents);
473 bool Controllable(
Idx index)
const;
484 bool Controllable(
const std::string& rName)
const;
492 EventSet ControllableEvents(
void)
const;
500 EventSet UncontrollableEvents(
void)
const;
509 void InsObservableEvent(
Idx index);
521 Idx InsObservableEvent(
const std::string& rName);
530 void InsUnobservableEvent(
Idx index);
542 Idx InsUnobservableEvent(
const std::string& rName);
550 void SetObservable(
Idx index);
558 void SetObservable(
const std::string& rName);
566 void SetObservable(
const EventSet& rEvents);
574 void ClrObservable(
Idx index);
582 void ClrObservable(
const std::string& rName);
590 void ClrObservable(
const EventSet& rEvents);
601 bool Observable(
Idx index)
const;
612 bool Observable(
const std::string& rName)
const;
620 EventSet ObservableEvents(
void)
const;
628 EventSet UnobservableEvents(
void)
const;
637 void InsForcibleEvent(
Idx index);
649 Idx InsForcibleEvent(
const std::string& rName);
658 void InsUnforcibleEvent(
Idx index);
670 Idx InsUnforcibleEvent(
const std::string& rName);
678 void SetForcible(
Idx index);
686 void SetForcible(
const std::string& rName);
694 void SetForcible(
const EventSet& rEvents);
702 void ClrForcible(
Idx index);
710 void ClrForcible(
const std::string& rName);
718 void ClrForcible(
const EventSet& rEvents);
729 bool Forcible(
Idx index)
const;
740 bool Forcible(
const std::string& rName)
const;
748 EventSet ForcibleEvents(
void)
const;
756 EventSet UnforcibleEvents(
void)
const;
765 void InsHighlevelEvent(
Idx index);
777 Idx InsHighlevelEvent(
const std::string& rName);
786 void InsLowlevelEvent(
Idx index);
798 Idx InsLowlevelEvent(
const std::string& rName);
806 void SetHighlevel(
Idx index);
814 void SetHighlevel(
const std::string& rName);
822 void SetHighlevel(
const EventSet& rEvents);
830 void SetLowlevel(
Idx index);
838 void SetLowlevel(
const std::string& rName);
846 void SetLowlevel(
const EventSet& rEvents);
857 bool Highlevel(
Idx index)
const;
868 bool Highlevel(
const std::string& rName)
const;
879 bool Lowlevel(
Idx index)
const;
890 bool Lowlevel(
const std::string& rName)
const;
898 EventSet HighlevelEvents(
void)
const;
906 EventSet LowlevelEvents(
void)
const;
930 #ifdef FAUDES_COMPATIBILITY
950 #define THIS TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
951 #define BASE TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
952 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
957 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator()");
962 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator(rOtherGen)");
967 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator(rOtherGen)");
971 TEMP THIS::TcGenerator(
const std::string& rFileName) :
BASE(rFileName) {
972 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator(rFilename) : done");
977 FD_DG(
"TcGenerator(" <<
this <<
")::operator = [v]" << &rOtherGen);
978 return Assign(rOtherGen);
983 FD_DG(
"TcGenerator(" <<
this <<
")::Assign([type] " << &rSrc <<
")");
985 if(&rSrc==
static_cast<const Type*
>(
this))
return *
this;
1000 FD_DG(
"TcGenerator(" <<
this <<
")::Assign([type] " << &rSrc <<
"): call base");
1010 res->EventSymbolTablep(BASE::mpEventSymbolTable);
1011 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
1012 res->mReindexOnWrite=BASE::mReindexOnWrite;
1027 THIS res= BASE::NewAGen();
1041 EventAttr attr=BASE::EventAttribute(index);
1042 return attr.Controllable();
1046 TEMP bool THIS::Controllable(
const std::string& rName)
const {
1047 EventAttr attr=BASE::EventAttribute(rName);
1048 return attr.Controllable();
1053 FD_DG(
"TcGenerator(" <<
this <<
")::InsControllableEvent(" << index <<
")");
1055 attr.SetControllable();
1056 BASE::InsEvent(index,attr);
1060 TEMP Idx THIS::InsControllableEvent(
const std::string& rName) {
1061 FD_DG(
"TcGenerator(" <<
this <<
")::InsControllableEvent(" << rName <<
")");
1063 attr.SetControllable();
1064 return BASE::InsEvent(rName,attr);
1068 TEMP void THIS::InsUncontrollableEvent(
Idx index) {
1069 FD_DG(
"TcGenerator(" <<
this <<
")::InsUncontrollableEvent(" << index <<
")");
1071 attr.ClrControllable();
1072 BASE::InsEvent(index,attr);
1076 TEMP Idx THIS::InsUncontrollableEvent(
const std::string& rName) {
1077 FD_DG(
"TcGenerator(" <<
this <<
")::InsUncontrollableEvent(" << rName <<
")");
1079 attr.ClrControllable();
1080 return BASE::InsEvent(rName,attr);
1085 FD_DG(
"TcGenerator(" <<
this <<
")::SetControllable(" << index <<
")");
1086 EventAttr attr=BASE::EventAttribute(index);
1087 attr.SetControllable();
1088 BASE::pAlphabet->Attribute(index,attr);
1092 TEMP void THIS::SetControllable(
const std::string& rName) {
1093 FD_DG(
"TcGenerator(" <<
this <<
")::SetControllable(" << rName <<
")");
1094 Idx index = BASE::EventIndex(rName);
1095 SetControllable(index);
1100 FD_DG(
"TcGenerator(" <<
this <<
")::SetControllable(rEvents)");
1101 EventSet::Iterator it;
1102 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1103 SetControllable(*it);
1109 FD_DG(
"TcGenerator(" <<
this <<
")::ClrControllable(" << index <<
")");
1110 EventAttr attr=BASE::EventAttribute(index);
1111 attr.ClrControllable();
1112 BASE::pAlphabet->Attribute(index,attr);
1116 TEMP void THIS::ClrControllable(
const std::string& rName) {
1117 FD_DG(
"TcGenerator(" <<
this <<
")::ClrControllable(" << rName <<
")");
1118 Idx index = BASE::EventIndex(rName);
1119 ClrControllable(index);
1124 FD_DG(
"TcGenerator(" <<
this <<
")::ClrControllable(rEvents)");
1125 EventSet::Iterator it;
1126 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1127 ClrControllable(*it);
1133 FD_DG(
"TcGenerator(" <<
this <<
")::ControllableEvents()");
1135 EventSet::Iterator it;
1136 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1137 if(Controllable(*it)) res.
Insert(*it);
1145 FD_DG(
"TcGenerator(" <<
this <<
")::UncontrollableEvents()");
1147 EventSet::Iterator it;
1148 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1149 if(!Controllable(*it)) res.
Insert(*it);
1156 EventAttr attr=BASE::EventAttribute(index);
1157 return attr.Observable();
1161 TEMP bool THIS::Observable(
const std::string& rName)
const {
1162 EventAttr attr=BASE::EventAttribute(rName);
1163 return attr.Observable();
1168 FD_DG(
"TcGenerator(" <<
this <<
")::InsObservableEvent(" << index <<
")");
1170 attr.SetObservable();
1171 BASE::InsEvent(index,attr);
1175 TEMP Idx THIS::InsObservableEvent(
const std::string& rName) {
1176 FD_DG(
"TcGenerator(" <<
this <<
")::InsObservableEvent(" << rName <<
")");
1178 attr.SetObservable();
1179 return BASE::InsEvent(rName,attr);
1184 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnobservableEvent(" << index <<
")");
1186 attr.ClrObservable();
1187 BASE::InsEvent(index,attr);
1191 TEMP Idx THIS::InsUnobservableEvent(
const std::string& rName) {
1192 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnobservableEvent(" << rName <<
")");
1194 attr.ClrObservable();
1195 return BASE::InsEvent(rName,attr);
1200 FD_DG(
"TcGenerator(" <<
this <<
")::SetObservable(" << index <<
")");
1201 EventAttr attr=BASE::EventAttribute(index);
1202 attr.SetObservable();
1203 BASE::pAlphabet->Attribute(index,attr);
1207 TEMP void THIS::SetObservable(
const std::string& rName) {
1208 FD_DG(
"TcGenerator(" <<
this <<
")::SetObservable(" << rName <<
")");
1209 Idx index = BASE::EventIndex(rName);
1210 SetObservable(index);
1215 FD_DG(
"TcGenerator(" <<
this <<
")::SetObservable(rEvents)");
1216 EventSet::Iterator it;
1217 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1224 FD_DG(
"TcGenerator(" <<
this <<
")::ClrObservable(" << index <<
")");
1225 EventAttr attr=BASE::EventAttribute(index);
1226 attr.ClrObservable();
1227 BASE::pAlphabet->Attribute(index,attr);
1231 TEMP void THIS::ClrObservable(
const std::string& rName) {
1232 FD_DG(
"TcGenerator(" <<
this <<
")::ClrObservable(" << rName <<
")");
1233 Idx index = BASE::EventIndex(rName);
1234 ClrObservable(index);
1239 FD_DG(
"TcGenerator(" <<
this <<
")::ClrObservable(rEvents)");
1240 EventSet::Iterator it;
1241 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1248 FD_DG(
"TcGenerator(" <<
this <<
")::ObservableEvents()");
1250 EventSet::Iterator it;
1251 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1252 if(Observable(*it)) res.
Insert(*it);
1260 FD_DG(
"TcGenerator(" <<
this <<
")::UnobservableEvents()");
1262 EventSet::Iterator it;
1263 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1264 if(!Observable(*it)) res.
Insert(*it);
1272 EventAttr attr=BASE::EventAttribute(index);
1273 return attr.Forcible();
1277 TEMP bool THIS::Forcible(
const std::string& rName)
const {
1278 EventAttr attr=BASE::EventAttribute(rName);
1279 return attr.Forcible();
1284 FD_DG(
"TcGenerator(" <<
this <<
")::InsForcibleEvent(" << index <<
")");
1287 BASE::InsEvent(index,attr);
1291 TEMP Idx THIS::InsForcibleEvent(
const std::string& rName) {
1292 FD_DG(
"TcGenerator(" <<
this <<
")::InsForcibleEvent(" << rName <<
")");
1295 return BASE::InsEvent(rName,attr);
1300 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnforcibleEvent(" << index <<
")");
1303 BASE::InsEvent(index,attr);
1307 TEMP Idx THIS::InsUnforcibleEvent(
const std::string& rName) {
1308 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnforcibleEvent(" << rName <<
")");
1311 return BASE::InsEvent(rName,attr);
1316 FD_DG(
"TcGenerator(" <<
this <<
")::SetForcible(" << index <<
")");
1317 EventAttr attr=BASE::EventAttribute(index);
1319 BASE::pAlphabet->Attribute(index,attr);
1323 TEMP void THIS::SetForcible(
const std::string& rName) {
1324 FD_DG(
"TcGenerator(" <<
this <<
")::SetForcible(" << rName <<
")");
1325 Idx index = BASE::EventIndex(rName);
1331 FD_DG(
"TcGenerator(" <<
this <<
")::SetForcible(rEvents)");
1332 EventSet::Iterator it;
1333 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1340 FD_DG(
"TcGenerator(" <<
this <<
")::ClrForcible(" << index <<
")");
1341 EventAttr attr=BASE::EventAttribute(index);
1343 BASE::pAlphabet->Attribute(index,attr);
1347 TEMP void THIS::ClrForcible(
const std::string& rName) {
1348 FD_DG(
"TcGenerator(" <<
this <<
")::ClrForcible(" << rName <<
")");
1349 Idx index = BASE::EventIndex(rName);
1355 FD_DG(
"TcGenerator(" <<
this <<
")::ClrForcible(rEvents)");
1356 EventSet::Iterator it;
1357 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1364 FD_DG(
"TcGenerator(" <<
this <<
")::ForcibleEvents()");
1366 EventSet::Iterator it;
1367 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1368 if(Forcible(*it)) res.
Insert(*it);
1376 FD_DG(
"TcGenerator(" <<
this <<
")::UnforcibleEvents()");
1378 EventSet::Iterator it;
1379 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1380 if(!Forcible(*it)) res.
Insert(*it);
1388 EventAttr attr=BASE::EventAttribute(index);
1389 return attr.Highlevel();
1393 TEMP bool THIS::Highlevel(
const std::string& rName)
const {
1394 EventAttr attr=BASE::EventAttribute(rName);
1395 return attr.Highlevel();
1400 EventAttr attr=BASE::EventAttribute(index);
1401 return attr.Lowlevel();
1405 TEMP bool THIS::Lowlevel(
const std::string& rName)
const {
1406 EventAttr attr=BASE::EventAttribute(rName);
1407 return attr.Lowlevel();
1412 FD_DG(
"TcGenerator(" <<
this <<
")::InsHighlevelEvent(" << index <<
")");
1414 attr.SetHighlevel();
1415 BASE::InsEvent(index,attr);
1419 TEMP Idx THIS::InsHighlevelEvent(
const std::string& rName) {
1420 FD_DG(
"TcGenerator(" <<
this <<
")::InsHighlevelEvent(" << rName <<
")");
1422 attr.SetHighlevel();
1423 return BASE::InsEvent(rName,attr);
1428 FD_DG(
"TcGenerator(" <<
this <<
")::InsLowlevelEvent(" << index <<
")");
1431 BASE::InsEvent(index,attr);
1435 TEMP Idx THIS::InsLowlevelEvent(
const std::string& rName) {
1436 FD_DG(
"TcGenerator(" <<
this <<
")::InsLowlevelEvent(" << rName <<
")");
1439 return BASE::InsEvent(rName,attr);
1444 FD_DG(
"TcGenerator(" <<
this <<
")::SetHighlevel(" << index <<
")");
1445 EventAttr attr=BASE::EventAttribute(index);
1446 attr.SetHighlevel();
1447 BASE::pAlphabet->Attribute(index,attr);
1451 TEMP void THIS::SetHighlevel(
const std::string& rName) {
1452 FD_DG(
"TcGenerator(" <<
this <<
")::SetHighlevel(" << rName <<
")");
1453 Idx index = BASE::EventIndex(rName);
1454 SetHighlevel(index);
1459 FD_DG(
"TcGenerator(" <<
this <<
")::SetHighlevel(rEvents)");
1460 EventSet::Iterator it;
1461 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1468 FD_DG(
"TcGenerator(" <<
this <<
")::SetLowlevel(" << index <<
")");
1469 EventAttr attr=BASE::EventAttribute(index);
1471 BASE::pAlphabet->Attribute(index,attr);
1475 TEMP void THIS::SetLowlevel(
const std::string& rName) {
1476 FD_DG(
"TcGenerator(" <<
this <<
")::SetLowlevel(" << rName <<
")");
1477 Idx index = BASE::EventIndex(rName);
1483 FD_DG(
"TcGenerator(" <<
this <<
")::SetLowlevel(rEvents)");
1484 EventSet::Iterator it;
1485 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1492 FD_DG(
"TcGenerator(" <<
this <<
")::HighlevelEvents()");
1494 EventSet::Iterator it;
1495 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1496 if(Highlevel(*it)) res.
Insert(*it);
1504 FD_DG(
"TcGenerator(" <<
this <<
")::LowlevelEvents()");
1506 EventSet::Iterator it;
1507 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1508 if(Lowlevel(*it)) res.
Insert(*it);
Attributed generator class TaGenerator.
#define FD_DG(message)
Debug: optional report on generator operations.
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
faudes type declaration macro
Attribute class to model event controllability properties.
void SetHighlevel(void)
Set abstraction flag.
bool Lowlevel(void) const
Query abstaction flag.
void SetForcible(void)
Set forcible flag.
void ClrControllable(void)
Clear controllable flag.
bool Forcible(void) const
Query forcibility.
void ClrForcible(void)
Clear forcible flag.
virtual ~AttributeCFlags(void)
Destructor.
bool Controllable(void) const
Query controllablility.
void ClrObservable(void)
Clear observable flag.
bool Highlevel(void) const
Query abstaction flag.
virtual bool IsDefault(void) const
Test for default value.
void SetControllable(void)
Set controllable flag.
bool Observable(void) const
Query observablility.
void SetLowlevel(void)
Clear abstraction flag.
AttributeCFlags(void)
Default constructor.
void SetObservable(void)
Set observable flag.
Set of indices with symbolic names.
bool Insert(const Idx &rIndex)
Add an element by index.
Generator with specified attribute types.
Set of indices with symbolic names and attributes.
Generator with controllability attributes.
virtual const Type * Cast(const Type *pOther) const
Type test.
A TokenReader reads sequential tokens from a file or string.
A TokenWriter writes sequential tokens to a file, a string or stdout.
Base class of all libFAUDES objects that participate in the run-time interface.
Base class of all FAUDES generators.
TaNameSet< AttributeCFlags > Alphabet
Convenience typedef for event sets with controllability attributes.
Iterator End(void) const
Iterator to the end of set.
Iterator Begin(void) const
Iterator to the begin of set.
TBaseVector< System > SystemVector
Convenience typedef for vectors of systems.
TcGenerator< AttributeVoid, AttributeVoid, AttributeCFlags, AttributeVoid > System
Convenience typedef for std System.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
TBaseVector< Alphabet > AlphaberVector
Convenience typedef.
TcGenerator< AttributeVoid, AttributeVoid, AttributeCFlags, AttributeVoid > cGenerator
Compatibility: pre 2.20b used cGenerator as C++ class name.
unsigned long int fType
Convenience typdef flag data.
TBaseVector< cGenerator > cGeneratorVector
TaNameSet< AttributeCFlags > cEventSet
Compatibility: pre 2.20b used cEventSet as C++ class name.
TBaseVector< cEventSet > cEventSetVector