|
|
Go to the documentation of this file.
12#ifndef FAUDES_TP_TGENERATOR_H
13#define FAUDES_TP_TGENERATOR_H
15#include "corefaudes.h"
99template < class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
170 return dynamic_cast< const TtGenerator* > (pOther); };
204 Idx ClocksSize( void) const;
227 void InjectClocks( const ClockSet& newclocks);
237 std::string ClockName( Idx index) const;
247 Idx ClockIndex( const std::string& rName) const;
257 bool InsClock( Idx index);
269 Idx InsClock( const std::string& rName);
277 void InsClocks( const ClockSet& rClockSet);
289 bool DelClock( Idx index);
300 bool DelClock( const std::string& rName);
308 void DelClocks( const ClockSet& rClocks);
319 bool ExistsClock( Idx index) const;
330 bool ExistsClock( const std::string& rName) const;
341 ClockSet::Iterator FindClock( Idx index) const;
352 ClockSet::Iterator FindClock( const std::string& rName) const;
369 ClockSet InactiveClocks( void) const;
375 void InsActiveClocks( void);
381 void DelInactiveClocks( void);
388 ClockSet::Iterator ClocksBegin( void) const;
395 ClockSet::Iterator ClocksEnd( void) const;
404 void ConsistentTimeConstraint( const TimeConstraint& rTimeConstr) const;
413 void ConsistentClocks( const ClockSet& rClocks) const;
476 void Invariant( const std::string& name, const TimeConstraint& rConstraints);
487 void InsInvariant( const std::string& name, const TimeConstraint& rConstraints);
507 void ClrInvariant( Idx idx);
515 void ClrInvariant( const std::string& name);
521 void ClearInvariants( void);
542 bool SetTransition( Idx x1, Idx ev, Idx x2);
563 bool SetTransition( const std::string& rX1, const std::string& rEv,
564 const std::string& rX2);
581 bool SetTransition( const Transition& rTransition, const TransAttr& rAttr);
614 bool SetTransition( Idx x1, Idx ev, Idx x2,
635 bool SetTransition( const std::string& rX1, const std::string& rEv, const std::string& rX2,
750 std::string CStr( Idx index) const;
758 virtual bool Valid( void) const;
768 virtual bool UpdateAttributes( void);
776typedef TtGenerator<AttributeTimedGlobal, AttributeTimedState, AttributeCFlags,AttributeTimedTrans>
780#ifdef FAUDES_COMPATIBILITY
788#define THIS TtGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
789#define BASE TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
790#define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
796 BASE::pGlobalAttribute->mClocks.Name( "Clocks");
798 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator() with csymtab "
799 << (BASE::pGlobalAttribute->mpClockSymbolTable ));
804 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator(rOtherGen) with csymtab"
805 << (BASE::pGlobalAttribute->mpClockSymbolTable) );
811 BASE::pGlobalAttribute->mClocks.Name( "Clocks");
813 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator(rOtherGen) with csymtab"
814 << (BASE::pGlobalAttribute->mpClockSymbolTable) );
818TEMP THIS::TtGenerator( const std::string& rFileName) : BASE(rFileName) {
819 FD_DG( "TimedGenerator(" << this << ")::TimedGenerator(" << rFileName << ") with csymtab"
820 << (BASE::pGlobalAttribute->mpClockSymbolTable) );
826 return BASE::pGlobalAttribute->mpClockSymbolTable;
832 BASE::pGlobalAttribute->mpClockSymbolTable=pSymTab;
841 res->EventSymbolTablep(BASE::mpEventSymbolTable);
842 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
843 res->mReindexOnWrite=BASE::mReindexOnWrite;
845 res->ClockSymbolTablep(ClockSymbolTablep());
860 THIS res= BASE::NewCGen();
862 res.ClockSymbolTablep(ClockSymbolTablep());
868 return BASE::pGlobalAttribute->mClocks.Size();
873 return BASE::pGlobalAttribute->mClocks;
878 return &BASE::pGlobalAttribute->mClocks;
883 BASE::pGlobalAttribute->mClocks=clockset;
884 BASE::pGlobalAttribute->mClocks. Name( "Clocks");
889 return BASE::pGlobalAttribute->mClocks.Insert(clockindex);
893TEMP Idx THIS::InsClock( const std::string& clockname) {
894 return BASE::pGlobalAttribute->mClocks.Insert(clockname);
899 BASE::pGlobalAttribute->mClocks.InsertSet(clockset);
905 FD_DG( "TimedGenerator(" << this << ")::DelClock(" << clockindex << ")");
907 for(tit=BASE::TransRelBegin(); tit!=BASE::TransRelEnd(); tit++) {
908 if(!BASE::pTransRel->Attribute(*tit).IsDefault()) {
909 BASE::pTransRel->Attributep(*tit)->mGuard.EraseByClock(clockindex);
910 BASE::pTransRel->Attributep(*tit)->mResets.Erase(clockindex);
913 StateSet::Iterator it;
914 for(it=BASE::StatesBegin(); it!=BASE::StatesEnd(); it++) {
915 if(!BASE::pStates->Attribute(*it).IsDefault()) {
916 BASE::pStates->Attributep(*it)->mInvariant.EraseByClock(clockindex);
919 return BASE::pGlobalAttribute->mClocks.Erase(clockindex);
923TEMP bool THIS::DelClock( const std::string& clockname) {
924 Idx index=BASE::pGlobalAttribute->mClocks.Index(clockname);
925 return DelClock(index);
930 ClockSet::Iterator it, tmpit;
931 for(it=clockset. Begin(); it!=clockset. End(); ) {
939TEMP bool THIS::ExistsClock( Idx clockindex) const {
940 return BASE::pGlobalAttribute->mClocks.Exists(clockindex);
945 const std::string& clockname) const {
946 return BASE::pGlobalAttribute->mClocks.Exists(clockname);
950TEMP ClockSet::Iterator THIS::FindClock( Idx clockindex) const {
951 return BASE::pGlobalAttribute->mClocks.Find(clockindex);
955TEMP ClockSet::Iterator THIS::FindClock( const std::string& clockname) const {
956 return BASE::pGlobalAttribute->mClocks.Find(clockname);
960TEMP std::string THIS::ClockName( Idx clockindex) const {
961 return BASE::pGlobalAttribute->mClocks.SymbolicName(clockindex);
965TEMP Idx THIS::ClockIndex( const std::string& clockname) const {
966 return BASE::pGlobalAttribute->mClocks.Index(clockname);
971 FD_DG( "TimedGenerator(" << this << ")::ActiveClocks() const");
974 for(tit=BASE::TransRelBegin(); tit!=BASE::TransRelEnd(); tit++) {
975 res. InsertSet(Guard(*tit).ActiveClocks());
978 StateSet::Iterator it;
979 for(it=BASE::StatesBegin(); it!=BASE::StatesEnd(); it++) {
980 res. InsertSet(Invariant(*it).ActiveClocks());
982 res. Name( "AcitiveClocks");
988 FD_DG( "TtaGenerator(" << this << ")::InactiveClocks() const");
989 ClockSet res = BASE::pGlobalAttribute->mClocks;
991 res. Name( "InactiveClocks");
996TEMP void THIS::InsActiveClocks( void) {
997 FD_DG( "TimedGenerator(" << this << ")::InsActiveClocks()");
1003TEMP void THIS::DelInactiveClocks( void) {
1004 FD_DG( "TimedGenerator(" << this << ")::InsActiveClocks()");
1005 ClockSet iaclocks=InactiveClocks();
1006 BASE::pGlobalAttribute->mClocks.EraseSet(iaclocks);
1010TEMP ClockSet::Iterator THIS::ClocksBegin( void) const {
1011 return BASE::pGlobalAttribute->mClocks.Begin();
1015TEMP ClockSet::Iterator THIS::ClocksEnd( void) const {
1016 return BASE::pGlobalAttribute->mClocks.End();
1021 FD_DG( "TimedGenerator(" << this << ")::ConsistentTimeConstraint(constr)");
1023 std::stringstream errstr;
1024 errstr << "clocksymboltable mismatch" << std::endl;
1025 throw Exception( "TimedGenerator::ConsistentTimeConstraint)", errstr.str(), 200);
1028 std::stringstream errstr;
1029 errstr << "time constraint refers to clocks not in clockset: " <<
1031 throw Exception( "TimedGenerator::ConsistentTimeConstraint)", errstr.str(), 200);
1033 FD_DG( "TimedGenerator(" << this << ")::ConsistentTimeConstraint(constr): ok");
1038 if(!( rClocks <= Clocks() )) {
1039 std::stringstream errstr;
1040 errstr << "clocksset contains clocks not in clockset" << std::endl;
1041 throw Exception( "TimedGenerator::ConsistentClocks)", errstr.str(), 200);
1044 std::stringstream errstr;
1045 errstr << "clocksymboltable mismatch" << std::endl;
1046 throw Exception( "TimedGenerator::ConsistentClocks)", errstr.str(), 200);
1053 if(!BASE::ExistsState(stateindex)) {
1054 std::stringstream errstr;
1055 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1056 throw Exception( "TimedGenerator::Invariant", errstr.str(), 200);
1058 return BASE::pStates->Attribute(stateindex).mInvariant;
1063 if(!BASE::ExistsState(stateindex)) {
1064 std::stringstream errstr;
1065 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1066 throw Exception( "TimedGenerator::Invariant", errstr.str(), 200);
1068 return &BASE::pStates->Attributep(stateindex)->mInvariant;
1073 Idx idx=BASE::StateIndex(statename);
1074 return Invariant(idx);
1079 Idx idx=BASE::StateIndex(statename);
1080 return Invariantp(idx);
1085 FD_DG( "TimedGenerator(" << this << ")::Invariant("<<stateindex<< ",inv)");
1086#ifdef FAUDES_CHECKED
1087 ConsistentTimeConstraint(rInv);
1088 if(!BASE::ExistsState(stateindex)) {
1089 std::stringstream errstr;
1090 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1091 throw Exception( "TimedGenerator::Invariant", errstr.str(), 200);
1094 BASE::pStates->Attributep(stateindex)->mInvariant=rInv;
1095 BASE::pStates->Attributep(stateindex)->mInvariant. Name( "Invariant");
1100 FD_DG( "TimedGenerator(" << this << ")::Invariant("<<statename<< ",inv)");
1101 Idx idx=BASE::StateIndex(statename);
1102 Invariant(idx,rInv);
1107 FD_DG( "TimedGenerator(" << this << ")::InsInvariant("<<stateindex<< ",inv)");
1108#ifdef FAUDES_CHECKED
1109 ConsistentTimeConstraint(rInv);
1110 if(!BASE::ExistsState(stateindex)) {
1111 std::stringstream errstr;
1112 errstr << "state index " << stateindex << " not found in StateSet" << std::endl;
1113 throw Exception( "TimedGenerator::InsInvariant", errstr.str(), 200);
1117 BASE::pStates->Attributep(stateindex)->mInvariant.Insert(rInv);
1123 FD_DG( "TimedGenerator(" << this << ")::InsInvariant("<<statename<< ",inv)");
1124 Idx idx=BASE::StateIndex(statename);
1125 InsInvariant(idx,rInv);
1130 if(!BASE::pStates->Attribute(stateindex).IsDefault())
1131 BASE::pStates->Attributep(stateindex)->mInvariant.Clear();
1135TEMP void THIS::ClrInvariant( const std::string& statename) {
1136 Idx idx=BASE::StateIndex(statename);
1141TEMP void THIS::ClearInvariants( void) {
1143 BASE::pStates->ClearAttributes();
1148TEMP bool THIS::SetTransition( const std::string& rX1, const std::string& rEv, const std::string& rX2) {
1149 return BASE::SetTransition(rX1,rEv,rX2);
1155 return BASE::SetTransition( Transition(x1,ev,x2));
1159TEMP bool THIS::SetTransition( const Transition& rTransition, const TransAttr& rAttr) {
1160 return BASE::SetTransition(rTransition,rAttr);
1166 FD_DG( "TimedGenerator(" << this << ")::SetTransition(" << (BASE::TStr(rTrans)) << ", " <<
1169 return BASE::SetTransition(rTrans);
1173 attr.mResets=rResets;
1174 attr.mGuard. Name( "Guard");
1175 attr.mResets.Name( "Resets");
1176#ifdef FAUDES_CHECKED
1177 ConsistentTimeConstraint(rGuard);
1178 ConsistentClocks(rResets);
1180 return BASE::SetTransition(rTrans,attr);
1186 return SetTransition( Transition(x1,ev,x2),rGuard,rResets);
1191 const std::string& rX1, const std::string& rEv, const std::string& rX2,
1193 FD_DG( "TimedGenerator(" << this << ")::SetTransition(" << rX1 << " " << rEv << " " << rX2 <<
1195 Idx x1=this->StateIndex(rX1);
1196 Idx ev=this->EventIndex(rEv);
1197 Idx x2=this->StateIndex(rX2);
1198 bool res=BASE::SetTransition(x1,ev,x2);
1203 attr.mResets=rResets;
1205 attr.mGuard. Name( "Guard");
1206 attr.mResets.Name( "Resets");
1207#ifdef FAUDES_CHECKED
1208 ConsistentTimeConstraint(rGuard);
1209 ConsistentClocks(rResets);
1211 BASE::TransAttribute( Transition(x1,ev,x2),attr);
1217#ifdef FAUDES_CHECKED
1218 if(!BASE::ExistsTransition(rTrans)) {
1219 std::stringstream errstr;
1220 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1221 throw Exception( "TimedGenerator::Guard(trans)", errstr.str(), 200);
1224 return BASE::pTransRel->Attribute(rTrans).mGuard;
1230#ifdef FAUDES_CHECKED
1231 if(!BASE::ExistsTransition(rTrans)) {
1232 std::stringstream errstr;
1233 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1234 throw Exception( "TimedGenerator::Guardp(trans)", errstr.str(), 200);
1237 return &BASE::pTransRel->Attributep(rTrans)->mGuard;
1243#ifdef FAUDES_CHECKED
1244 ConsistentTimeConstraint(rGuard);
1245 if(!BASE::ExistsTransition(rTrans)) {
1246 std::stringstream errstr;
1247 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1248 throw Exception( "TimedGenerator::Guard(trans,guard)", errstr.str(), 200);
1251 BASE::pTransRel->Attributep(rTrans)->mGuard=rGuard;
1252 BASE::pTransRel->Attributep(rTrans)->mGuard. Name( "Guard");
1257#ifdef FAUDES_CHECKED
1258 ConsistentTimeConstraint(rGuard);
1259 if(!BASE::ExistsTransition(rTrans)) {
1260 std::stringstream errstr;
1261 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1262 throw Exception( "TimedGenerator::InsGuard(trans,guard)", errstr.str(), 200);
1265 if(!rGuard. Empty()) {
1266 BASE::pTransRel->Attributep(rTrans)->mGuard.Insert(rGuard);
1272#ifdef FAUDES_CHECKED
1273 if(!BASE::ExistsTransition(rTrans)) {
1274 std::stringstream errstr;
1275 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1276 throw Exception( "TimedGenerator::ClrGuard(trans)", errstr.str(), 200);
1279 if(!BASE::pTransRel->Attribute(rTrans).IsDefault())
1280 BASE::pTransRel->Attributep(rTrans)->mGuard.Clear();
1286#ifdef FAUDES_CHECKED
1287 if(!BASE::ExistsTransition(rTrans)) {
1288 std::stringstream errstr;
1289 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1290 throw Exception( "TimedGenerator::Resets(trans)", errstr.str(), 200);
1293 return BASE::pTransRel->Attribute(rTrans).mResets;
1299#ifdef FAUDES_CHECKED
1300 if(!BASE::ExistsTransition(rTrans)) {
1301 std::stringstream errstr;
1302 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1303 throw Exception( "TimedGenerator::Resetsp(trans)", errstr.str(), 200);
1306 return &BASE::pTransRel->Attributep(rTrans)->mResets;
1312#ifdef FAUDES_CHECKED
1313 ConsistentClocks(rResets);
1314 if(!BASE::ExistsTransition(rTrans)) {
1315 std::stringstream errstr;
1316 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1317 throw Exception( "TimedGenerator::Resets(trans,guard)", errstr.str(), 200);
1320 BASE::pTransRel->Attributep(rTrans)->mResets=rResets;
1326#ifdef FAUDES_CHECKED
1327 ConsistentClocks(rResets);
1328 if(!BASE::ExistsTransition(rTrans)) {
1329 std::stringstream errstr;
1330 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1331 throw Exception( "TimedGenerator::InsResets(trans,guard)", errstr.str(), 200);
1334 if(!rResets. Empty()) {
1335 BASE::pTransRel->Attributep(rTrans)->mResets.InsertSet(rResets);
1342#ifdef FAUDES_CHECKED
1343 if(!BASE::ExistsTransition(rTrans)) {
1344 std::stringstream errstr;
1345 errstr << "transition " << BASE::TStr(rTrans) << " not found " << std::endl;
1346 throw Exception( "TimedGenerator::ClrResets(trans)", errstr.str(), 200);
1349 if(!BASE::pTransRel->Attribute(rTrans).IsDefault())
1350 BASE::pTransRel->Attributep(rTrans)->mGuard.Clear();
1356 FD_DV( "TimedGenerator(" << this << ")::Valid()");
1358 if(!BASE::Valid()) return false;
1361 StateSet::Iterator sit;
1362 for(sit = BASE::StatesBegin(); sit!= BASE::StatesEnd(); ++sit) {
1363 if(Invariant(*sit).Name()!= "Invariant") return false;
1365 for(tit = BASE::TransRelBegin(); tit!= BASE::TransRelEnd(); ++tit) {
1366 if(Guard(*tit).Name()!= "Guard") return false;
1367 if(Resets(*tit).Name()!= "Resets") return false;
1369 if(Clocks().Name()!= "Clocks") return false;
1372 if(!(aclocks <= Clocks())) return false;
1374 for(sit = BASE::StatesBegin(); sit!= BASE::StatesEnd(); ++sit) {
1375 if(Invariant(*sit).ClockSymbolTablep()!=ClockSymbolTablep()) return false;
1377 for(tit = BASE::TransRelBegin(); tit!= BASE::TransRelEnd(); ++tit) {
1378 if(Guard(*tit).ClockSymbolTablep()!=ClockSymbolTablep()) return false;
1379 if(Resets(*tit).SymbolTablep()!=ClockSymbolTablep()) return false;
1381 if(Clocks().SymbolTablep()!=ClockSymbolTablep()) return false;
1388TEMP bool THIS::UpdateAttributes( void) {
1389 FD_DG( "TimedGenerator(" << this << ")::UpdateAttributes()");
1393 StateSet blockstates=BASE::BlockingStates();
1394 StateSet::Iterator sit;
1395 for(sit=BASE::StatesBegin(); sit!= BASE::StatesEnd(); sit++) {
1396 StateAttr attr=BASE::StateAttribute(*sit);
1397 if(blockstates. Exists(*sit)) {
1398 attr.Set(0x20000000);
1400 attr.Clr(0x20000000);
1402 BASE::StateAttribute(*sit,attr);
1412 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)
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.33k
--- 2025.09.16
--- c++ api documentaion by doxygen
|