24 #ifndef FAUDES_CGENERATOR_H
25 #define FAUDES_CGENERATOR_H
83 bool Controllable(
void)
const {
return ( (mFlags & mControllableFlag) != 0 ); }
99 bool Observable(
void)
const {
return ( (mFlags & mObservableFlag) != 0 ); }
116 bool Forcible(
void)
const {
return ( (mFlags & mForcibleFlag) != 0 ); }
132 bool Highlevel(
void)
const {
return ( (mFlags & mAbstractionFlag) != 0 ); }
137 bool Lowlevel(
void)
const {
return ( (mFlags & mAbstractionFlag) == 0 ); }
143 virtual bool IsDefault(
void)
const {
return mFlags==mDefCFlags;};
146 const static fType mControllableFlag =0x01;
147 const static fType mObservableFlag =0x02;
148 const static fType mForcibleFlag =0x04;
149 const static fType mAbstractionFlag =0x08;
153 const static fType mDefCFlags =0x0a;
156 const static fType mAllCFlags =0x0f;
194 virtual void DoRead(
TokenReader& rTr,
const std::string& rLabel=
"",
const Type* pContext=0);
210 virtual void DoWrite(
TokenWriter& rTw,
const std::string& rLabel=
"",
const Type* pContext=0)
const;
227 virtual void DoXWrite(
TokenWriter& rTw,
const std::string& rLabel=
"",
const Type* pContext=0)
const;
246 #ifdef FAUDES_COMPATIBILITY
272 template <
class GlobalAttr,
class StateAttr,
class EventAttr,
class TransAttr>
333 return dynamic_cast< const TcGenerator*
> (pOther); };
373 void InsControllableEvent(
Idx index);
385 Idx InsControllableEvent(
const std::string& rName);
394 void InsUncontrollableEvent(
Idx index);
406 Idx InsUncontrollableEvent(
const std::string& rName);
414 void SetControllable(
Idx index);
422 void SetControllable(
const std::string& rName);
430 void SetControllable(
const EventSet& rEvents);
438 void ClrControllable(
Idx index);
446 void ClrControllable(
const std::string& rName);
454 void ClrControllable(
const EventSet& rEvents);
465 bool Controllable(
Idx index)
const;
476 bool Controllable(
const std::string& rName)
const;
484 EventSet ControllableEvents(
void)
const;
492 EventSet UncontrollableEvents(
void)
const;
501 void InsObservableEvent(
Idx index);
513 Idx InsObservableEvent(
const std::string& rName);
522 void InsUnobservableEvent(
Idx index);
534 Idx InsUnobservableEvent(
const std::string& rName);
542 void SetObservable(
Idx index);
550 void SetObservable(
const std::string& rName);
558 void SetObservable(
const EventSet& rEvents);
566 void ClrObservable(
Idx index);
574 void ClrObservable(
const std::string& rName);
582 void ClrObservable(
const EventSet& rEvents);
593 bool Observable(
Idx index)
const;
604 bool Observable(
const std::string& rName)
const;
612 EventSet ObservableEvents(
void)
const;
620 EventSet UnobservableEvents(
void)
const;
629 void InsForcibleEvent(
Idx index);
641 Idx InsForcibleEvent(
const std::string& rName);
650 void InsUnforcibleEvent(
Idx index);
662 Idx InsUnforcibleEvent(
const std::string& rName);
670 void SetForcible(
Idx index);
678 void SetForcible(
const std::string& rName);
686 void SetForcible(
const EventSet& rEvents);
694 void ClrForcible(
Idx index);
702 void ClrForcible(
const std::string& rName);
710 void ClrForcible(
const EventSet& rEvents);
721 bool Forcible(
Idx index)
const;
732 bool Forcible(
const std::string& rName)
const;
740 EventSet ForcibleEvents(
void)
const;
748 EventSet UnforcibleEvents(
void)
const;
757 void InsHighlevelEvent(
Idx index);
769 Idx InsHighlevelEvent(
const std::string& rName);
778 void InsLowlevelEvent(
Idx index);
790 Idx InsLowlevelEvent(
const std::string& rName);
798 void SetHighlevel(
Idx index);
806 void SetHighlevel(
const std::string& rName);
814 void SetHighlevel(
const EventSet& rEvents);
822 void SetLowlevel(
Idx index);
830 void SetLowlevel(
const std::string& rName);
838 void SetLowlevel(
const EventSet& rEvents);
849 bool Highlevel(
Idx index)
const;
860 bool Highlevel(
const std::string& rName)
const;
871 bool Lowlevel(
Idx index)
const;
882 bool Lowlevel(
const std::string& rName)
const;
890 EventSet HighlevelEvents(
void)
const;
898 EventSet LowlevelEvents(
void)
const;
922 #ifdef FAUDES_COMPATIBILITY
942 #define THIS TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
943 #define BASE TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
944 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
949 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator()");
954 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator(rOtherGen)");
959 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator(rOtherGen)");
963 TEMP THIS::TcGenerator(
const std::string& rFileName) :
BASE(rFileName) {
964 FD_DG(
"TcGenerator(" <<
this <<
")::TcGenerator(rFilename) : done");
969 FD_DG(
"TcGenerator(" <<
this <<
")::operator = [v]" << &rOtherGen);
970 return Assign(rOtherGen);
975 FD_DG(
"TcGenerator(" <<
this <<
")::Assign([type] " << &rSrc <<
")");
977 if(&rSrc==
static_cast<const Type*
>(
this))
return *
this;
992 FD_DG(
"TcGenerator(" <<
this <<
")::Assign([type] " << &rSrc <<
"): call base");
1002 res->EventSymbolTablep(BASE::mpEventSymbolTable);
1003 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
1004 res->mReindexOnWrite=BASE::mReindexOnWrite;
1019 THIS res= BASE::NewAGen();
1033 EventAttr attr=BASE::EventAttribute(index);
1034 return attr.Controllable();
1038 TEMP bool THIS::Controllable(
const std::string& rName)
const {
1039 EventAttr attr=BASE::EventAttribute(rName);
1040 return attr.Controllable();
1045 FD_DG(
"TcGenerator(" <<
this <<
")::InsControllableEvent(" << index <<
")");
1047 attr.SetControllable();
1048 BASE::InsEvent(index,attr);
1052 TEMP Idx THIS::InsControllableEvent(
const std::string& rName) {
1053 FD_DG(
"TcGenerator(" <<
this <<
")::InsControllableEvent(" << rName <<
")");
1055 attr.SetControllable();
1056 return BASE::InsEvent(rName,attr);
1060 TEMP void THIS::InsUncontrollableEvent(
Idx index) {
1061 FD_DG(
"TcGenerator(" <<
this <<
")::InsUncontrollableEvent(" << index <<
")");
1063 attr.ClrControllable();
1064 BASE::InsEvent(index,attr);
1068 TEMP Idx THIS::InsUncontrollableEvent(
const std::string& rName) {
1069 FD_DG(
"TcGenerator(" <<
this <<
")::InsUncontrollableEvent(" << rName <<
")");
1071 attr.ClrControllable();
1072 return BASE::InsEvent(rName,attr);
1077 FD_DG(
"TcGenerator(" <<
this <<
")::SetControllable(" << index <<
")");
1078 EventAttr attr=BASE::EventAttribute(index);
1079 attr.SetControllable();
1080 BASE::pAlphabet->Attribute(index,attr);
1084 TEMP void THIS::SetControllable(
const std::string& rName) {
1085 FD_DG(
"TcGenerator(" <<
this <<
")::SetControllable(" << rName <<
")");
1086 Idx index = BASE::EventIndex(rName);
1087 SetControllable(index);
1092 FD_DG(
"TcGenerator(" <<
this <<
")::SetControllable(rEvents)");
1093 EventSet::Iterator it;
1094 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1095 SetControllable(*it);
1101 FD_DG(
"TcGenerator(" <<
this <<
")::ClrControllable(" << index <<
")");
1102 EventAttr attr=BASE::EventAttribute(index);
1103 attr.ClrControllable();
1104 BASE::pAlphabet->Attribute(index,attr);
1108 TEMP void THIS::ClrControllable(
const std::string& rName) {
1109 FD_DG(
"TcGenerator(" <<
this <<
")::ClrControllable(" << rName <<
")");
1110 Idx index = BASE::EventIndex(rName);
1111 ClrControllable(index);
1116 FD_DG(
"TcGenerator(" <<
this <<
")::ClrControllable(rEvents)");
1117 EventSet::Iterator it;
1118 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1119 ClrControllable(*it);
1125 FD_DG(
"TcGenerator(" <<
this <<
")::ControllableEvents()");
1127 EventSet::Iterator it;
1128 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1129 if(Controllable(*it)) res.
Insert(*it);
1137 FD_DG(
"TcGenerator(" <<
this <<
")::UncontrollableEvents()");
1139 EventSet::Iterator it;
1140 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1141 if(!Controllable(*it)) res.
Insert(*it);
1148 EventAttr attr=BASE::EventAttribute(index);
1149 return attr.Observable();
1153 TEMP bool THIS::Observable(
const std::string& rName)
const {
1154 EventAttr attr=BASE::EventAttribute(rName);
1155 return attr.Observable();
1160 FD_DG(
"TcGenerator(" <<
this <<
")::InsObservableEvent(" << index <<
")");
1162 attr.SetObservable();
1163 BASE::InsEvent(index,attr);
1167 TEMP Idx THIS::InsObservableEvent(
const std::string& rName) {
1168 FD_DG(
"TcGenerator(" <<
this <<
")::InsObservableEvent(" << rName <<
")");
1170 attr.SetObservable();
1171 return BASE::InsEvent(rName,attr);
1176 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnobservableEvent(" << index <<
")");
1178 attr.ClrObservable();
1179 BASE::InsEvent(index,attr);
1183 TEMP Idx THIS::InsUnobservableEvent(
const std::string& rName) {
1184 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnobservableEvent(" << rName <<
")");
1186 attr.ClrObservable();
1187 return BASE::InsEvent(rName,attr);
1192 FD_DG(
"TcGenerator(" <<
this <<
")::SetObservable(" << index <<
")");
1193 EventAttr attr=BASE::EventAttribute(index);
1194 attr.SetObservable();
1195 BASE::pAlphabet->Attribute(index,attr);
1199 TEMP void THIS::SetObservable(
const std::string& rName) {
1200 FD_DG(
"TcGenerator(" <<
this <<
")::SetObservable(" << rName <<
")");
1201 Idx index = BASE::EventIndex(rName);
1202 SetObservable(index);
1207 FD_DG(
"TcGenerator(" <<
this <<
")::SetObservable(rEvents)");
1208 EventSet::Iterator it;
1209 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1216 FD_DG(
"TcGenerator(" <<
this <<
")::ClrObservable(" << index <<
")");
1217 EventAttr attr=BASE::EventAttribute(index);
1218 attr.ClrObservable();
1219 BASE::pAlphabet->Attribute(index,attr);
1223 TEMP void THIS::ClrObservable(
const std::string& rName) {
1224 FD_DG(
"TcGenerator(" <<
this <<
")::ClrObservable(" << rName <<
")");
1225 Idx index = BASE::EventIndex(rName);
1226 ClrObservable(index);
1231 FD_DG(
"TcGenerator(" <<
this <<
")::ClrObservable(rEvents)");
1232 EventSet::Iterator it;
1233 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1240 FD_DG(
"TcGenerator(" <<
this <<
")::ObservableEvents()");
1242 EventSet::Iterator it;
1243 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1244 if(Observable(*it)) res.
Insert(*it);
1252 FD_DG(
"TcGenerator(" <<
this <<
")::UnobservableEvents()");
1254 EventSet::Iterator it;
1255 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1256 if(!Observable(*it)) res.
Insert(*it);
1264 EventAttr attr=BASE::EventAttribute(index);
1265 return attr.Forcible();
1269 TEMP bool THIS::Forcible(
const std::string& rName)
const {
1270 EventAttr attr=BASE::EventAttribute(rName);
1271 return attr.Forcible();
1276 FD_DG(
"TcGenerator(" <<
this <<
")::InsForcibleEvent(" << index <<
")");
1279 BASE::InsEvent(index,attr);
1283 TEMP Idx THIS::InsForcibleEvent(
const std::string& rName) {
1284 FD_DG(
"TcGenerator(" <<
this <<
")::InsForcibleEvent(" << rName <<
")");
1287 return BASE::InsEvent(rName,attr);
1292 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnforcibleEvent(" << index <<
")");
1295 BASE::InsEvent(index,attr);
1299 TEMP Idx THIS::InsUnforcibleEvent(
const std::string& rName) {
1300 FD_DG(
"TcGenerator(" <<
this <<
")::InsUnforcibleEvent(" << rName <<
")");
1303 return BASE::InsEvent(rName,attr);
1308 FD_DG(
"TcGenerator(" <<
this <<
")::SetForcible(" << index <<
")");
1309 EventAttr attr=BASE::EventAttribute(index);
1311 BASE::pAlphabet->Attribute(index,attr);
1315 TEMP void THIS::SetForcible(
const std::string& rName) {
1316 FD_DG(
"TcGenerator(" <<
this <<
")::SetForcible(" << rName <<
")");
1317 Idx index = BASE::EventIndex(rName);
1323 FD_DG(
"TcGenerator(" <<
this <<
")::SetForcible(rEvents)");
1324 EventSet::Iterator it;
1325 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1332 FD_DG(
"TcGenerator(" <<
this <<
")::ClrForcible(" << index <<
")");
1333 EventAttr attr=BASE::EventAttribute(index);
1335 BASE::pAlphabet->Attribute(index,attr);
1339 TEMP void THIS::ClrForcible(
const std::string& rName) {
1340 FD_DG(
"TcGenerator(" <<
this <<
")::ClrForcible(" << rName <<
")");
1341 Idx index = BASE::EventIndex(rName);
1347 FD_DG(
"TcGenerator(" <<
this <<
")::ClrForcible(rEvents)");
1348 EventSet::Iterator it;
1349 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1356 FD_DG(
"TcGenerator(" <<
this <<
")::ForcibleEvents()");
1358 EventSet::Iterator it;
1359 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1360 if(Forcible(*it)) res.
Insert(*it);
1368 FD_DG(
"TcGenerator(" <<
this <<
")::UnforcibleEvents()");
1370 EventSet::Iterator it;
1371 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1372 if(!Forcible(*it)) res.
Insert(*it);
1380 EventAttr attr=BASE::EventAttribute(index);
1381 return attr.Highlevel();
1385 TEMP bool THIS::Highlevel(
const std::string& rName)
const {
1386 EventAttr attr=BASE::EventAttribute(rName);
1387 return attr.Highlevel();
1392 EventAttr attr=BASE::EventAttribute(index);
1393 return attr.Lowlevel();
1397 TEMP bool THIS::Lowlevel(
const std::string& rName)
const {
1398 EventAttr attr=BASE::EventAttribute(rName);
1399 return attr.Lowlevel();
1404 FD_DG(
"TcGenerator(" <<
this <<
")::InsHighlevelEvent(" << index <<
")");
1406 attr.SetHighlevel();
1407 BASE::InsEvent(index,attr);
1411 TEMP Idx THIS::InsHighlevelEvent(
const std::string& rName) {
1412 FD_DG(
"TcGenerator(" <<
this <<
")::InsHighlevelEvent(" << rName <<
")");
1414 attr.SetHighlevel();
1415 return BASE::InsEvent(rName,attr);
1420 FD_DG(
"TcGenerator(" <<
this <<
")::InsLowlevelEvent(" << index <<
")");
1423 BASE::InsEvent(index,attr);
1427 TEMP Idx THIS::InsLowlevelEvent(
const std::string& rName) {
1428 FD_DG(
"TcGenerator(" <<
this <<
")::InsLowlevelEvent(" << rName <<
")");
1431 return BASE::InsEvent(rName,attr);
1436 FD_DG(
"TcGenerator(" <<
this <<
")::SetHighlevel(" << index <<
")");
1437 EventAttr attr=BASE::EventAttribute(index);
1438 attr.SetHighlevel();
1439 BASE::pAlphabet->Attribute(index,attr);
1443 TEMP void THIS::SetHighlevel(
const std::string& rName) {
1444 FD_DG(
"TcGenerator(" <<
this <<
")::SetHighlevel(" << rName <<
")");
1445 Idx index = BASE::EventIndex(rName);
1446 SetHighlevel(index);
1451 FD_DG(
"TcGenerator(" <<
this <<
")::SetHighlevel(rEvents)");
1452 EventSet::Iterator it;
1453 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1460 FD_DG(
"TcGenerator(" <<
this <<
")::SetLowlevel(" << index <<
")");
1461 EventAttr attr=BASE::EventAttribute(index);
1463 BASE::pAlphabet->Attribute(index,attr);
1467 TEMP void THIS::SetLowlevel(
const std::string& rName) {
1468 FD_DG(
"TcGenerator(" <<
this <<
")::SetLowlevel(" << rName <<
")");
1469 Idx index = BASE::EventIndex(rName);
1475 FD_DG(
"TcGenerator(" <<
this <<
")::SetLowlevel(rEvents)");
1476 EventSet::Iterator it;
1477 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
1484 FD_DG(
"TcGenerator(" <<
this <<
")::HighlevelEvents()");
1486 EventSet::Iterator it;
1487 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1488 if(Highlevel(*it)) res.
Insert(*it);
1496 FD_DG(
"TcGenerator(" <<
this <<
")::LowlevelEvents()");
1498 EventSet::Iterator it;
1499 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
1500 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