|
|
Go to the documentation of this file.
12#ifndef FAUDES_TP_TGENERATOR_H
13#define FAUDES_TP_TGENERATOR_H
99template < class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
170 return dynamic_cast< const TtGenerator* > (pOther); };
194 Idx ClocksSize( void) const;
217 void InjectClocks( const ClockSet& newclocks);
227 std::string ClockName( Idx index) const;
237 Idx ClockIndex( const std::string& rName) const;
247 bool InsClock( Idx index);
259 Idx InsClock( const std::string& rName);
267 void InsClocks( const ClockSet& rClockSet);
279 bool DelClock( Idx index);
290 bool DelClock( const std::string& rName);
298 void DelClocks( const ClockSet& rClocks);
309 bool ExistsClock( Idx index) const;
320 bool ExistsClock( const std::string& rName) const;
331 ClockSet::Iterator FindClock( Idx index) const;
342 ClockSet::Iterator FindClock( const std::string& rName) const;
359 ClockSet InactiveClocks( void) const;
365 void InsActiveClocks( void);
371 void DelInactiveClocks( void);
378 ClockSet::Iterator ClocksBegin( void) const;
385 ClockSet::Iterator ClocksEnd( void) const;
394 void ConsistentTimeConstraint( const TimeConstraint& rTimeConstr) const;
403 void ConsistentClocks( const ClockSet& rClocks) const;
466 void Invariant( const std::string& name, const TimeConstraint& rConstraints);
477 void InsInvariant( const std::string& name, const TimeConstraint& rConstraints);
497 void ClrInvariant( Idx idx);
505 void ClrInvariant( const std::string& name);
511 void ClearInvariants( void);
532 bool SetTransition( Idx x1, Idx ev, Idx x2);
553 bool SetTransition( const std::string& rX1, const std::string& rEv,
554 const std::string& rX2);
571 bool SetTransition( const Transition& rTransition, const TransAttr& rAttr);
604 bool SetTransition( Idx x1, Idx ev, Idx x2,
625 bool SetTransition( const std::string& rX1, const std::string& rEv, const std::string& rX2,
740 std::string CStr( Idx index) const;
748 virtual bool Valid( void) const;
758 virtual bool UpdateAttributes( void);
766typedef TtGenerator<AttributeTimedGlobal, AttributeTimedState, AttributeCFlags,AttributeTimedTrans>
770#ifdef FAUDES_COMPATIBILITY
778#define THIS TtGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
779#define BASE TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
780#define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
786 BASE::pGlobalAttribute->mClocks.Name( "Clocks");
788 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator() with csymtab "
789 << (BASE::pGlobalAttribute->mpClockSymbolTable ));
794 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator(rOtherGen) with csymtab"
795 << (BASE::pGlobalAttribute->mpClockSymbolTable) );
801 BASE::pGlobalAttribute->mClocks.Name( "Clocks");
803 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator(rOtherGen) with csymtab"
804 << (BASE::pGlobalAttribute->mpClockSymbolTable) );
808TEMP THIS::TtGenerator( const std::string& rFileName) : BASE(rFileName) {
809 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator(" << rFileName << ") with csymtab"
810 << (BASE::pGlobalAttribute->mpClockSymbolTable) );
816 return BASE::pGlobalAttribute->mpClockSymbolTable;
822 BASE::pGlobalAttribute->mpClockSymbolTable=pSymTab;
831 res->EventSymbolTablep(BASE::mpEventSymbolTable);
832 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
833 res->mReindexOnWrite=BASE::mReindexOnWrite;
835 res->ClockSymbolTablep(ClockSymbolTablep());
850 return BASE::pGlobalAttribute->mClocks.Size();
855 return BASE::pGlobalAttribute->mClocks;
860 return &BASE::pGlobalAttribute->mClocks;
865 BASE::pGlobalAttribute->mClocks=clockset;
866 BASE::pGlobalAttribute->mClocks. Name( "Clocks");
871 return BASE::pGlobalAttribute->mClocks.Insert(clockindex);
875TEMP Idx THIS::InsClock( const std::string& clockname) {
876 return BASE::pGlobalAttribute->mClocks.Insert(clockname);
881 BASE::pGlobalAttribute->mClocks.InsertSet(clockset);
887 FD_DG( "TimedGenerator(" << this << ")::DelClock(" << clockindex << ")");
889 for(tit=BASE::TransRelBegin(); tit!=BASE::TransRelEnd(); tit++) {
890 if(!BASE::pTransRel->Attribute(*tit).IsDefault()) {
891 BASE::pTransRel->Attributep(*tit)->mGuard.EraseByClock(clockindex);
892 BASE::pTransRel->Attributep(*tit)->mResets.Erase(clockindex);
895 StateSet::Iterator it;
896 for(it=BASE::StatesBegin(); it!=BASE::StatesEnd(); it++) {
897 if(!BASE::pStates->Attribute(*it).IsDefault()) {
898 BASE::pStates->Attributep(*it)->mInvariant.EraseByClock(clockindex);
901 return BASE::pGlobalAttribute->mClocks.Erase(clockindex);
905TEMP bool THIS::DelClock( const std::string& clockname) {
906 Idx index=BASE::pGlobalAttribute->mClocks.Index(clockname);
907 return DelClock(index);
912 ClockSet::Iterator it, tmpit;
913 for(it=clockset. Begin(); it!=clockset. End(); ) {
921TEMP bool THIS::ExistsClock( Idx clockindex) const {
922 return BASE::pGlobalAttribute->mClocks.Exists(clockindex);
927 const std::string& clockname) const {
928 return BASE::pGlobalAttribute->mClocks.Exists(clockname);
932TEMP ClockSet::Iterator THIS::FindClock( Idx clockindex) const {
933 return BASE::pGlobalAttribute->mClocks.Find(clockindex);
937TEMP ClockSet::Iterator THIS::FindClock( const std::string& clockname) const {
938 return BASE::pGlobalAttribute->mClocks.Find(clockname);
942TEMP std::string THIS::ClockName( Idx clockindex) const {
943 return BASE::pGlobalAttribute->mClocks.SymbolicName(clockindex);
947TEMP Idx THIS::ClockIndex( const std::string& clockname) const {
948 return BASE::pGlobalAttribute->mClocks.Index(clockname);
953 FD_DG( "TimedGenerator(" << this << ")::ActiveClocks() const");
956 for(tit=BASE::TransRelBegin(); tit!=BASE::TransRelEnd(); tit++) {
957 res. InsertSet(Guard(*tit).ActiveClocks());
960 StateSet::Iterator it;
961 for(it=BASE::StatesBegin(); it!=BASE::StatesEnd(); it++) {
962 res. InsertSet(Invariant(*it).ActiveClocks());
964 res. Name( "AcitiveClocks");
970 FD_DG( "TtaGenerator(" << this << ")::InactiveClocks() const");
971 ClockSet res = BASE::pGlobalAttribute->mClocks;
973 res. Name( "InactiveClocks");
978TEMP void THIS::InsActiveClocks( void) {
979 FD_DG( "TimedGenerator(" << this << ")::InsActiveClocks()");
985TEMP void THIS::DelInactiveClocks( void) {
986 FD_DG( "TimedGenerator(" << this << ")::InsActiveClocks()");
988 BASE::pGlobalAttribute->mClocks.EraseSet(iaclocks);
992TEMP ClockSet::Iterator THIS::ClocksBegin( void) const {
993 return BASE::pGlobalAttribute->mClocks.Begin();
997TEMP ClockSet::Iterator THIS::ClocksEnd( void) const {
998 return BASE::pGlobalAttribute->mClocks.End();
1003 FD_DG( "TimedGenerator(" << this << ")::ConsistentTimeConstraint(constr)");
1005 std::stringstream errstr;
1006 errstr << "clocksymboltable mismatch" << std::endl;
1007 throw Exception( "TimedGenerator::ConsistentTimeConstraint)", errstr.str(), 200);
1010 std::stringstream errstr;
1011 errstr << "time constraint refers to clocks not in clockset: " <<
1013 throw Exception( "TimedGenerator::ConsistentTimeConstraint)", errstr.str(), 200);
1015 FD_DG( "TimedGenerator(" << this << ")::ConsistentTimeConstraint(constr): ok");
1020 if(!( rClocks <= Clocks() )) {
1021 std::stringstream errstr;
1022 errstr << "clocksset contains clocks not in clockset" << std::endl;
1023 throw Exception( "TimedGenerator::ConsistentClocks)", errstr.str(), 200);
1026 std::stringstream errstr;
1027 errstr << "clocksymboltable mismatch" << std::endl;
1028 throw Exception( "TimedGenerator::ConsistentClocks)", errstr.str(), 200);
1035 if(!BASE::ExistsState(stateindex)) {
1036 std::stringstream errstr;
1037 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1038 throw Exception( "TimedGenerator::Invariant", errstr.str(), 200);
1040 return BASE::pStates->Attribute(stateindex).mInvariant;
1045 if(!BASE::ExistsState(stateindex)) {
1046 std::stringstream errstr;
1047 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1048 throw Exception( "TimedGenerator::Invariant", errstr.str(), 200);
1050 return &BASE::pStates->Attributep(stateindex)->mInvariant;
1055 Idx idx=BASE::StateIndex(statename);
1056 return Invariant(idx);
1061 Idx idx=BASE::StateIndex(statename);
1062 return Invariantp(idx);
1067 FD_DG( "TimedGenerator(" << this << ")::Invariant("<<stateindex<< ",inv)");
1068#ifdef FAUDES_CHECKED
1069 ConsistentTimeConstraint(rInv);
1070 if(!BASE::ExistsState(stateindex)) {
1071 std::stringstream errstr;
1072 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1073 throw Exception( "TimedGenerator::Invariant", errstr.str(), 200);
1076 BASE::pStates->Attributep(stateindex)->mInvariant=rInv;
1077 BASE::pStates->Attributep(stateindex)->mInvariant. Name( "Invariant");
1082 FD_DG( "TimedGenerator(" << this << ")::Invariant("<<statename<< ",inv)");
1083 Idx idx=BASE::StateIndex(statename);
1084 Invariant(idx,rInv);
1089 FD_DG( "TimedGenerator(" << this << ")::InsInvariant("<<stateindex<< ",inv)");
1090#ifdef FAUDES_CHECKED
1091 ConsistentTimeConstraint(rInv);
1092 if(!BASE::ExistsState(stateindex)) {
1093 std::stringstream errstr;
1094 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1095 throw Exception( "TimedGenerator::InsInvariant", errstr.str(), 200);
1099 BASE::pStates->Attributep(stateindex)->mInvariant.Insert(rInv);
1105 FD_DG( "TimedGenerator(" << this << ")::InsInvariant("<<statename<< ",inv)");
1106 Idx idx=BASE::StateIndex(statename);
1107 InsInvariant(idx,rInv);
1112 if(!BASE::pStates->Attribute(stateindex).IsDefault())
1113 BASE::pStates->Attributep(stateindex)->mInvariant.Clear();
1117TEMP void THIS::ClrInvariant( const std::string& statename) {
1118 Idx idx=BASE::StateIndex(statename);
1123TEMP void THIS::ClearInvariants( void) {
1125 BASE::pStates->ClearAttributes();
1130TEMP bool THIS::SetTransition( const std::string& rX1, const std::string& rEv, const std::string& rX2) {
1131 return BASE::SetTransition(rX1,rEv,rX2);
1137 return BASE::SetTransition( Transition(x1,ev,x2));
1141TEMP bool THIS::SetTransition( const Transition& rTransition, const TransAttr& rAttr) {
1142 return BASE::SetTransition(rTransition,rAttr);
1148 FD_DG( "TimedGenerator(" << this << ")::SetTransition(" << (BASE::TStr(rTrans)) << ", " <<
1151 return BASE::SetTransition(rTrans);
1155 attr.mResets=rResets;
1156 attr.mGuard. Name( "Guard");
1157 attr.mResets.Name( "Resets");
1158#ifdef FAUDES_CHECKED
1159 ConsistentTimeConstraint(rGuard);
1160 ConsistentClocks(rResets);
1162 return BASE::SetTransition(rTrans,attr);
1168 return SetTransition( Transition(x1,ev,x2),rGuard,rResets);
1173 const std::string& rX1, const std::string& rEv, const std::string& rX2,
1175 FD_DG( "TimedGenerator(" << this << ")::SetTransition(" << rX1 << " " << rEv << " " << rX2 <<
1177 Idx x1=this->StateIndex(rX1);
1178 Idx ev=this->EventIndex(rEv);
1179 Idx x2=this->StateIndex(rX2);
1180 bool res=BASE::SetTransition(x1,ev,x2);
1185 attr.mResets=rResets;
1187 attr.mGuard. Name( "Guard");
1188 attr.mResets.Name( "Resets");
1189#ifdef FAUDES_CHECKED
1190 ConsistentTimeConstraint(rGuard);
1191 ConsistentClocks(rResets);
1193 BASE::TransAttribute( Transition(x1,ev,x2),attr);
1199#ifdef FAUDES_CHECKED
1200 if(!BASE::ExistsTransition(rTrans)) {
1201 std::stringstream errstr;
1202 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1203 throw Exception( "TimedGenerator::Guard(trans)", errstr.str(), 200);
1206 return BASE::pTransRel->Attribute(rTrans).mGuard;
1212#ifdef FAUDES_CHECKED
1213 if(!BASE::ExistsTransition(rTrans)) {
1214 std::stringstream errstr;
1215 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1216 throw Exception( "TimedGenerator::Guardp(trans)", errstr.str(), 200);
1219 return &BASE::pTransRel->Attributep(rTrans)->mGuard;
1225#ifdef FAUDES_CHECKED
1226 ConsistentTimeConstraint(rGuard);
1227 if(!BASE::ExistsTransition(rTrans)) {
1228 std::stringstream errstr;
1229 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1230 throw Exception( "TimedGenerator::Guard(trans,guard)", errstr.str(), 200);
1233 BASE::pTransRel->Attributep(rTrans)->mGuard=rGuard;
1234 BASE::pTransRel->Attributep(rTrans)->mGuard. Name( "Guard");
1239#ifdef FAUDES_CHECKED
1240 ConsistentTimeConstraint(rGuard);
1241 if(!BASE::ExistsTransition(rTrans)) {
1242 std::stringstream errstr;
1243 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1244 throw Exception( "TimedGenerator::InsGuard(trans,guard)", errstr.str(), 200);
1247 if(!rGuard. Empty()) {
1248 BASE::pTransRel->Attributep(rTrans)->mGuard.Insert(rGuard);
1254#ifdef FAUDES_CHECKED
1255 if(!BASE::ExistsTransition(rTrans)) {
1256 std::stringstream errstr;
1257 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1258 throw Exception( "TimedGenerator::ClrGuard(trans)", errstr.str(), 200);
1261 if(!BASE::pTransRel->Attribute(rTrans).IsDefault())
1262 BASE::pTransRel->Attributep(rTrans)->mGuard.Clear();
1268#ifdef FAUDES_CHECKED
1269 if(!BASE::ExistsTransition(rTrans)) {
1270 std::stringstream errstr;
1271 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1272 throw Exception( "TimedGenerator::Resets(trans)", errstr.str(), 200);
1275 return BASE::pTransRel->Attribute(rTrans).mResets;
1281#ifdef FAUDES_CHECKED
1282 if(!BASE::ExistsTransition(rTrans)) {
1283 std::stringstream errstr;
1284 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1285 throw Exception( "TimedGenerator::Resetsp(trans)", errstr.str(), 200);
1288 return &BASE::pTransRel->Attributep(rTrans)->mResets;
1294#ifdef FAUDES_CHECKED
1295 ConsistentClocks(rResets);
1296 if(!BASE::ExistsTransition(rTrans)) {
1297 std::stringstream errstr;
1298 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1299 throw Exception( "TimedGenerator::Resets(trans,guard)", errstr.str(), 200);
1302 BASE::pTransRel->Attributep(rTrans)->mResets=rResets;
1308#ifdef FAUDES_CHECKED
1309 ConsistentClocks(rResets);
1310 if(!BASE::ExistsTransition(rTrans)) {
1311 std::stringstream errstr;
1312 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1313 throw Exception( "TimedGenerator::InsResets(trans,guard)", errstr.str(), 200);
1316 if(!rResets. Empty()) {
1317 BASE::pTransRel->Attributep(rTrans)->mResets.InsertSet(rResets);
1324#ifdef FAUDES_CHECKED
1325 if(!BASE::ExistsTransition(rTrans)) {
1326 std::stringstream errstr;
1327 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1328 throw Exception( "TimedGenerator::ClrResets(trans)", errstr.str(), 200);
1331 if(!BASE::pTransRel->Attribute(rTrans).IsDefault())
1332 BASE::pTransRel->Attributep(rTrans)->mGuard.Clear();
1338 FD_DV( "TimedGenerator(" << this << ")::Valid()");
1340 if(!BASE::Valid()) return false;
1343 StateSet::Iterator sit;
1344 for(sit = BASE::StatesBegin(); sit!= BASE::StatesEnd(); ++sit) {
1345 if(Invariant(*sit).Name()!= "Invariant") return false;
1347 for(tit = BASE::TransRelBegin(); tit!= BASE::TransRelEnd(); ++tit) {
1348 if(Guard(*tit).Name()!= "Guard") return false;
1349 if(Resets(*tit).Name()!= "Resets") return false;
1351 if(Clocks().Name()!= "Clocks") return false;
1354 if(!(aclocks <= Clocks())) return false;
1356 for(sit = BASE::StatesBegin(); sit!= BASE::StatesEnd(); ++sit) {
1357 if(Invariant(*sit).ClockSymbolTablep()!=ClockSymbolTablep()) return false;
1359 for(tit = BASE::TransRelBegin(); tit!= BASE::TransRelEnd(); ++tit) {
1360 if(Guard(*tit).ClockSymbolTablep()!=ClockSymbolTablep()) return false;
1361 if(Resets(*tit).SymbolTablep()!=ClockSymbolTablep()) return false;
1363 if(Clocks().SymbolTablep()!=ClockSymbolTablep()) return false;
1370TEMP bool THIS::UpdateAttributes( void) {
1371 FD_DG( "TimedGenerator(" << this << ")::UpdateAttributes()");
1375 StateSet blockstates=BASE::BlockingStates();
1376 StateSet::Iterator sit;
1377 for(sit=BASE::StatesBegin(); sit!= BASE::StatesEnd(); sit++) {
1378 StateAttr attr=BASE::StateAttribute(*sit);
1379 if(blockstates. Exists(*sit)) {
1380 attr.Set(0x20000000);
1382 attr.Clr(0x20000000);
1384 BASE::StateAttribute(*sit,attr);
1394 return BASE::pGlobalAttribute->mClocks.Str(index);
static SymbolTable * GlobalClockSymbolTablep(void)
const std::string & Name(void) const
virtual void InsertSet(const NameSet &rOtherSet)
SymbolTable * SymbolTablep(void) const
void EraseSet(const NameSet &rOtherSet)
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
std::string ToString(void) const
std::string Name(void) const
ClockSet ActiveClocks(void) const
SymbolTable * ClockSymbolTablep(void) const
virtual const Type * Cast(const Type *pOther) const
virtual void Name(const std::string &rName)
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
bool Exists(const T &rElem) const
virtual AttributeVoid * Attributep(const T &rElem)
Iterator Begin(void) const
TtGenerator< AttributeTimedGlobal, AttributeTimedState, AttributeCFlags, AttributeTimedTrans > TimedGenerator
TtGenerator< AttributeTimedGlobal, AttributeTimedState, AttributeCFlags, AttributeTimedTrans > tGenerator
libFAUDES 2.34e
--- 2026.03.16
--- c++ api documentaion by doxygen
|