11 #ifndef FAUDES_HIO_CONSTRAINT_H
12 #define FAUDES_HIO_CONSTRAINT_H
42 template <
class GlobalAttr,
class StateAttr,
class EventAttr,
class TransAttr>
182 void SetY(
const std::string& rName);
206 void SetU(
const std::string& rName);
236 bool IsY(
const std::string& rName)
const;
258 bool IsU(
const std::string& rName)
const;
292 void SetQY(
const std::string& rName);
315 void ClrQY(
const std::string& rName);
344 bool IsQY(
const std::string& rName)
const;
368 void SetQU(
const std::string& rName);
391 void ClrQU(
const std::string& rName);
420 bool IsQU(
const std::string& rName)
const;
496 bool IsErr(
const std::string& rName)
const;
525 #define THIS THioConstraint<GlobalAttr, StateAttr, EventAttr, TransAttr>
526 #define BASE TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
527 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
532 FD_DG(
"HioConstraint(" <<
this <<
")::HioConstraint()");
537 FD_DG(
"HioConstraint(" <<
this <<
")::HioConstraint(rOtherGen)");
542 FD_DG(
"HioConstraint(" <<
this <<
")::HioConstraint(rOtherGen)");
550 ) :
BASE(rOtherGen) {
551 FD_DG(
"HioConstraint(" <<
this <<
")::HioConstraint(rOtherGen)");
557 TEMP THIS::THioConstraint(
const std::string& rFileName) :
BASE(rFileName) {
558 FD_DG(
"HioConstraint(" <<
this <<
")::HioConstraint(rFilename) : done");
566 res->EventSymbolTablep(BASE::mpEventSymbolTable);
567 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
573 return new THIS(*
this);
579 THIS res= BASE::NewAGen();
587 EventAttr attr=BASE::EventAttribute(index);
592 TEMP bool THIS::IsY(
const std::string& rName)
const {
593 EventAttr attr=BASE::EventAttribute(rName);
599 EventAttr attr=BASE::EventAttribute(index);
604 TEMP bool THIS::IsU(
const std::string& rName)
const {
605 EventAttr attr=BASE::EventAttribute(rName);
611 FD_DG(
"HioConstraint(" <<
this <<
")::YEvents()");
613 EventSet::Iterator it;
614 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
615 if(IsY(*it)) res.
Insert(*it);
622 FD_DG(
"HioConstraint(" <<
this <<
")::UEvents()");
624 EventSet::Iterator it;
625 for(it=BASE::AlphabetBegin(); it!=BASE::AlphabetEnd(); it++) {
626 if(IsU(*it)) res.
Insert(*it);
635 FD_DG(
"HioConstraint(" <<
this <<
")::InsYEvent(" << index <<
")");
638 BASE::InsEvent(index,attr);
642 TEMP Idx THIS::InsYEvent(
const std::string& rName) {
643 FD_DG(
"HioConstraint(" <<
this <<
")::InsYEvent(" << rName <<
")");
646 return BASE::InsEvent(rName,attr);
651 FD_DG(
"HioConstraint(" <<
this <<
")::InsUEvent(" << index <<
")");
654 BASE::InsEvent(index,attr);
658 TEMP Idx THIS::InsUEvent(
const std::string& rName) {
659 FD_DG(
"HioConstraint(" <<
this <<
")::InsUEvent(" << rName <<
")");
662 return BASE::InsEvent(rName,attr);
667 FD_DG(
"HioConstraint(" <<
this <<
")::SetY(" << index <<
")");
668 EventAttr attr=BASE::EventAttribute(index);
670 BASE::pAlphabet->Attribute(index,attr);
674 TEMP void THIS::SetY(
const std::string& rName) {
675 FD_DG(
"HioConstraint(" <<
this <<
")::SetY(" << rName <<
")");
676 Idx index = BASE::EventIndex(rName);
682 FD_DG(
"HioConstraint(" <<
this <<
")::SetY(rEvents)");
683 EventSet::Iterator it;
684 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
691 FD_DG(
"HioConstraint(" <<
this <<
")::SetU(" << index <<
")");
692 EventAttr attr=BASE::EventAttribute(index);
694 BASE::pAlphabet->Attribute(index,attr);
698 TEMP void THIS::SetU(
const std::string& rName) {
699 FD_DG(
"HioConstraint(" <<
this <<
")::SetU(" << rName <<
")");
700 Idx index = BASE::EventIndex(rName);
706 FD_DG(
"HioConstraint(" <<
this <<
")::SetU(rEvents)");
707 EventSet::Iterator it;
708 for(it=rEvents.
Begin(); it!=rEvents.
End(); it++) {
719 FD_DG(
"HioConstraint(" <<
this <<
")::SetQY(" << index <<
")");
720 StateAttr attr=BASE::StateAttribute(index);
729 BASE::pStates->Attribute(index,attr);
733 TEMP void THIS::SetQY(
const std::string& rName) {
734 FD_DG(
"HioConstraint(" <<
this <<
")::SetQY(" << rName <<
")");
735 Idx index = BASE::StateIndex(rName);
741 FD_DG(
"HioConstraint(" <<
this <<
")::SetQY(rStates)");
742 StateSet::Iterator sit;
743 for(sit=rStates.
Begin(); sit!=rStates.
End(); sit++) {
750 FD_DG(
"HioConstraint(" <<
this <<
")::ClrQY(" << index <<
")");
751 StateAttr attr=BASE::StateAttribute(index);
753 BASE::pStates->Attribute(index,attr);
757 TEMP void THIS::ClrQY(
const std::string& rName) {
758 FD_DG(
"HioConstraint(" <<
this <<
")::ClrQY(" << rName <<
")");
759 Idx index = BASE::StateIndex(rName);
765 FD_DG(
"HioConstraint(" <<
this <<
")::ClrQY(rStates)");
766 StateSet::Iterator sit;
767 for(sit=rStates.
Begin(); sit!=rStates.
End(); sit++) {
774 StateAttr attr=BASE::StateAttribute(index);
779 TEMP bool THIS::IsQY(
const std::string& rName)
const {
780 Idx index = BASE::StateIndex(rName);
786 FD_DG(
"HioConstraint(" <<
this <<
")::QYStates()");
788 StateSet::Iterator sit;
789 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) {
790 if(IsQY(*sit)) res.
Insert(*sit);
798 FD_DG(
"HioConstraint(" <<
this <<
")::SetQU(" << index <<
")");
799 StateAttr attr=BASE::StateAttribute(index);
808 BASE::pStates->Attribute(index,attr);
812 TEMP void THIS::SetQU(
const std::string& rName) {
813 FD_DG(
"HioConstraint(" <<
this <<
")::SetQU(" << rName <<
")");
814 Idx index = BASE::StateIndex(rName);
820 FD_DG(
"HioConstraint(" <<
this <<
")::SetQU(rStates)");
821 StateSet::Iterator sit;
822 for(sit=rStates.
Begin(); sit!=rStates.
End(); sit++) {
829 FD_DG(
"HioConstraint(" <<
this <<
")::ClrQU(" << index <<
")");
830 StateAttr attr=BASE::StateAttribute(index);
832 BASE::pStates->Attribute(index,attr);
836 TEMP void THIS::ClrQU(
const std::string& rName) {
837 FD_DG(
"HioConstraint(" <<
this <<
")::ClrQU(" << rName <<
")");
838 Idx index = BASE::StateIndex(rName);
844 FD_DG(
"HioConstraint(" <<
this <<
")::ClrQU(rStates)");
845 StateSet::Iterator sit;
846 for(sit=rStates.
Begin(); sit!=rStates.
End(); sit++) {
853 StateAttr attr=BASE::StateAttribute(index);
858 TEMP bool THIS::IsQU(
const std::string& rName)
const {
859 Idx index = BASE::StateIndex(rName);
865 FD_DG(
"HioConstraint(" <<
this <<
")::QUStates()");
867 StateSet::Iterator sit;
868 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) {
869 if(IsQU(*sit)) res.
Insert(*sit);
876 FD_DG(
"HioPlant(" <<
this <<
")::SetErr(" << index <<
")");
877 StateAttr attr=BASE::StateAttribute(index);
879 BASE::pStates->Attribute(index,attr);
883 TEMP void THIS::SetErr(
const std::string& rName) {
884 FD_DG(
"HioPlant(" <<
this <<
")::SetErr(" << rName <<
")");
885 Idx index = BASE::StateIndex(rName);
891 FD_DG(
"HioPlant(" <<
this <<
")::SetErr(rStates)");
892 StateSet::Iterator sit;
893 for(sit=rStates.
Begin(); sit!=rStates.
End(); sit++) {
900 FD_DG(
"HioPlant(" <<
this <<
")::ClrErr(" << index <<
")");
901 StateAttr attr=BASE::StateAttribute(index);
903 BASE::pStates->Attribute(index,attr);
907 TEMP void THIS::ClrErr(
const std::string& rName) {
908 FD_DG(
"HioPlant(" <<
this <<
")::ClrErr(" << rName <<
")");
909 Idx index = BASE::StateIndex(rName);
915 FD_DG(
"HioPlant(" <<
this <<
")::ClrErr(rStates)");
916 StateSet::Iterator sit;
917 for(sit=rStates.
Begin(); sit!=rStates.
End(); sit++) {
924 StateAttr attr=BASE::StateAttribute(index);
929 TEMP bool THIS::IsErr(
const std::string& rName)
const {
930 Idx index = BASE::StateIndex(rName);
936 FD_DG(
"HioPlant(" <<
this <<
")::ErrStates()");
938 StateSet::Iterator sit;
939 for(sit=BASE::StatesBegin(); sit!=BASE::StatesEnd(); sit++) {
940 if(IsErr(*sit)) res.
Insert(*sit);
989 std::string& rReportStr);
#define FD_DG(message)
Debug: optional report on generator operations.
Idx Insert(void)
Insert new index to set.
Set of indices with symbolic names.
bool Insert(const Idx &rIndex)
Add an element by index.
Generator with I/O-constraint attributes.
bool IsU(Idx index) const
Is event U-event(by index)
bool IsQY(const std::string &rName) const
Is state QY-state (by name)
void ClrQU(Idx index)
Mark state as NOT QU-state (by index)
void SetY(const EventSet &rEvents)
Mark set of events as Y-events.
bool IsErr(const std::string &rName) const
Is state Err-state (by name)
virtual bool UpdateAttributes(void)
Updates internal attributes.
void ClrQY(const StateSet &rStates)
Mark set of states as NOT QY-states (by index)
StateSet ErrStates(void) const
Get StateSet with Err-states.
bool IsY(Idx index) const
Is event Y-event(by index)
bool IsQY(Idx index) const
Is state QY-state (by index)
void SetQU(const std::string &rName)
Mark state as QU-state (by name)
bool IsY(const std::string &rName) const
Is event Y-event(by name)
EventSet UEvents(void) const
Get EventSet with U-events.
StateSet QUStates(void) const
Get StateSet with QU-states.
THioConstraint(const Generator &rOtherGen, const EventSet &rY, const EventSet &rU)
HioConstraint from a std Generator and event sets.
bool IsU(const std::string &rName) const
Is event U-event(by name)
THioConstraint(const std::string &rFileName)
construct a HioConstraint from file
bool IsQU(Idx index) const
Is state QU-state (by index)
void ClrQY(const std::string &rName)
Mark state as NOT QY-state (by name)
void ClrErr(Idx index)
Mark state as NOT Err-state (by index)
void SetQY(const StateSet &rStates)
Mark set of states as QY-states.
void SetU(const EventSet &rEvents)
Mark set of events as U-events.
void SetQY(const std::string &rName)
Mark state as QY-state (by name)
void SetErr(Idx index)
Mark state as Err-state (by index)
void InsUEvent(Idx index)
Add an existing U-event to generator.
virtual THioConstraint * Copy(void) const
Construct copy on heap.
void ClrErr(const std::string &rName)
Mark state as NOT Err-state (by name)
THioConstraint NewHioConstraint(void) const
Create empty HioConstraint with same symboltable as this.
void SetU(Idx index)
Mark event U-event(by index)
bool IsErr(Idx index) const
Is state Err-state (by index)
THioConstraint(const Generator &rOtherGen)
HioConstraint from a std Generator.
void SetQU(Idx index)
Mark event as QU-state (by index)
void InsYEvent(Idx index)
Add an existing Y-event to generator.
Idx InsYEvent(const std::string &rName)
Add new named Y-event to generator.
THioConstraint(void)
Creates an empty HioConstraint object.
void SetY(Idx index)
Mark event as Y-event (by index)
THioConstraint * New(void) const
Construct on heap.
StateSet QYStates(void) const
Get StateSet with QY-states.
void SetU(const std::string &rName)
Mark event U-event(by name)
void SetQY(Idx index)
Mark event as QY-state (by index)
void SetQU(const StateSet &rStates)
Mark set of states as QU-states.
virtual THioConstraint & operator=(const THioConstraint &rOtherGen)
Assignment operator (uses copy)
void ClrQU(const std::string &rName)
Mark state as NOT QU-state (by name)
bool IsQU(const std::string &rName) const
Is state QU-state (by name)
void SetErr(const std::string &rName)
Mark state as Err-state (by name)
void ClrErr(const StateSet &rStates)
Mark set of states as NOT Err-states (by index)
void ClrQU(const StateSet &rStates)
Mark set of states as NOT QU-states (by index)
void SetErr(const StateSet &rStates)
Mark set of states as Err-states.
EventSet YEvents(void) const
Get EventSet with Y-events.
THioConstraint(const THioConstraint &rOtherGen)
HioConstraint from a HioConstraint.
void ClrQY(Idx index)
Mark state as NOT QY-state (by index)
void SetY(const std::string &rName)
Mark event as Y-event(by name)
Idx InsUEvent(const std::string &rName)
Add new named U-event to generator.
Generator with specified attribute types.
virtual TaGenerator & Assign(const Type &rSrc)
Copy from other faudes Type (try to cast to agenerator or pass to base)
Base class of all FAUDES generators.
Includes all libFAUDES headers, no plugins.
Iterator End(void) const
Iterator to the end of set.
Iterator Begin(void) const
Iterator to the begin of set.
Event and state attributes for hierarchical I/O systems.
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
bool IsHioConstraintForm(HioConstraint &rHioConstraint, StateSet &rQY, StateSet &rQU, EventSet &rErrEvSet, TransSet &rErrTrSet, StateSet &rErrStSet, std::string &rReportStr)
IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state attributes.
THioConstraint< AttributeVoid, HioStateFlags, HioEventFlags, AttributeVoid > HioConstraint
void HioStatePartition(HioConstraint &rHioConstraint)
Function definition for run-time interface.