|
Go to the documentation of this file.
24 #ifndef FAUDES_AGENERATOR_H
25 #define FAUDES_AGENERATOR_H
69 template < class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
263 virtual void Clear( void);
285 const TaEventSet<EventAttr>& Alphabet( void) const;
293 const TaStateSet<StateAttr>& States( void) const;
379 Idx InsEvent( const std::string& rName, const EventAttr& rAttr);
452 Idx InsState( const std::string& rName, const StateAttr& attr);
484 void InjectStates( const TaStateSet<StateAttr>& rNewStates);
527 bool SetTransition( const std::string& rX1, const std::string& rEv,
528 const std::string& rX2);
825 #define THIS TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
826 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
827 #define BASE vGenerator
842 TEMP const GlobalAttr& THIS::GlobalTaGen( void) {
843 static GlobalAttr* pstatic = new GlobalAttr();
853 FD_DG( "TaGenerator(" << this << ")::TaGenerator()");
857 FD_DG( "TaGenerator(" << this << ")::TaGenerator(): done");
865 FD_DG( "TaGenerator(" << this << ")::TaGenerator(" << &rOtherGen << ")");
879 FD_DG( "TaGenerator(" << this << ")::TaGenerator([v]" << &rOtherGen << ")");
888 TEMP THIS::TaGenerator( const std::string& rFileName) :
892 FD_DG( "TaGenerator(" << this << ")::TaGenerator(" << rFileName << ")");
905 TEMP void THIS::NewCore( void) {
906 FD_DG( "TaGenerator(" << this << ")::NewCore()");
912 TEMP void THIS::UpdateCore( void) {
916 pGlobalAttribute = dynamic_cast< GlobalAttr* >(mpGlobalAttribute);
919 pTransRel = dynamic_cast< ATransSet* >(mpTransRel);
922 if(pGlobalAttribute==0 && mpGlobalAttribute!=0) tmm= true;
923 if(pAlphabet==0 && mpAlphabet!=0) tmm= true;
924 if(pStates==0 && mpStates!=0) tmm= true;
925 if(pTransRel==0 && mpTransRel!=0) tmm= true;
927 std::stringstream errstr;
928 errstr << "cannot cast attributes for generator " << Name();
929 throw Exception( "Generator::UpdateCore", errstr.str(), 63);
936 FD_DG( "TaGenerator(" << this << ")::Assign(" << &rGen << ")");
955 #ifdef FAUDES_DEBUG_CODE
957 FD_DG( "TaGenerator()::Assign(): invalid generator");
967 FD_DG( "TaGenerator(" << this << ")::Assign([v]" << &rGen << ")");
968 FD_DG( "TaGenerator(" << this << ")::Assign(): src type " << typeid(rGen).name());
969 FD_DG( "TaGenerator(" << this << ")::Assign(): dst type " << typeid(*this).name());
973 #ifdef FAUDES_DEBUG_GENERATOR
984 FD_DG( "TaGenerator(" << this << ")::Assign([type] " << &rSrc << ")");
986 if(&rSrc== this) return * this;
989 if(vgen) Assign(*vgen);
996 FD_DG( "TaGenerator(" << this << ")::Move(" << &rGen << ")");
1004 FD_DG( "TaGenerator(" << this << ")::Move([v]" << &rGen << ")");
1011 FD_DG( "TaGenerator(" << this << ")::~TaGenerator()");
1019 res->EventSymbolTablep(BASE::mpEventSymbolTable);
1020 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
1021 res->mReindexOnWrite=BASE::mReindexOnWrite;
1037 res.EventSymbolTablep(BASE::mpEventSymbolTable);
1038 res.mStateNamesEnabled=BASE::mStateNamesEnabled;
1039 res.mReindexOnWrite=BASE::mReindexOnWrite;
1046 return dynamic_cast< const THIS* > (pOther);
1051 FD_DG( "TaGenerator(" << this << ")::operator = " << &rOtherGen);
1052 return Assign(rOtherGen);
1057 FD_DG( "TaGenerator(" << this << ")::operator = [v]" << &rOtherGen);
1058 return Assign(rOtherGen);
1063 FD_DG( "TaGenerator(" << this << ")::Valid()");
1064 if(!BASE::Valid()) return false;
1067 if( typeid( Alphabet().Attribute())!= typeid( const EventAttr&)) tmm= true;
1068 if( typeid(States().Attribute())!= typeid( const StateAttr&)) tmm= true;
1069 if( typeid(TransRel().Attribute())!= typeid( const TransAttr&)) tmm= true;
1070 if( typeid(GlobalAttribute())!= typeid( const GlobalAttr&)) tmm= true;
1082 FD_DG( "TaGenerator(" << this << ")::Clear()");
1089 FD_DG( "TaGenerator::InjectAlphabet() " << rNewAlphabet. ToString());
1090 BASE::InjectAlphabet(rNewAlphabet);
1094 TEMP void THIS::InjectAlphabet( const TaEventSet<EventAttr>& rNewAlphabet) {
1095 FD_DG( "TaGenerator::InjectAlphabet(TaEventSet<EventAttr>) " << rNewAlphabet.ToString());
1096 #ifdef FAUDES_CHECKED
1097 if(rNewAlphabet.SymbolTablep()!=mpEventSymbolTable) {
1098 std::stringstream errstr;
1099 errstr << "symboltable mismatch aka not implemented" << std::endl;
1100 throw Exception( "TaGenerator::InjectAlphabet", errstr.str(), 88);
1103 *pAlphabet=rNewAlphabet;
1104 mpAlphabet->Name( "Alphabet");
1109 FD_DG( "TaGenerator(" << this << ")::InsEvent(" << index << ")");
1110 return pAlphabet->Insert(index);
1114 TEMP Idx THIS::InsEvent( const std::string& rName) {
1115 FD_DG( "TaGenerator(" << this << ")::InsEvent(\"" << rName << "\")");
1116 return pAlphabet->Insert(rName);
1120 TEMP bool THIS::InsEvent( Idx index, const EventAttr& attr) {
1121 FD_DG( "TaGenerator(" << this << ")::InsEvent(" << index << " " << attr.ToString() << ")");
1122 return pAlphabet->Insert(index, attr);
1126 TEMP Idx THIS::InsEvent( const std::string& rName, const EventAttr& attr) {
1127 FD_DG( "TaGenerator(" << this << ")::InsEvent(\"" << rName << attr.ToString() << "\")");
1128 return pAlphabet->Insert(rName, attr);
1133 FD_DG( "TaGenerator(" << this << ")::InsState()");
1134 return mpStates->Insert();
1139 FD_DG( "TaGenerator(" << this << ")::InsState(attr)");
1140 return pStates->Insert(attr);
1145 FD_DG( "TaGenerator(" << this << ")::InsState(" << index << ")");
1146 return mpStates->Insert(index);
1150 TEMP bool THIS::InsState( Idx index, const StateAttr& rAttr) {
1151 FD_DG( "TaGenerator(" << this << ")::InsState(" << index << ",rAttr)");
1152 return pStates->Insert(index,rAttr);
1156 TEMP Idx THIS::InsState( const std::string& rName) {
1157 FD_DG( "TaGenerator(" << this << ")::InsState(\"" << rName << "\")");
1158 Idx index=mpStates->Insert();
1159 StateName(index,rName);
1164 TEMP Idx THIS::InsState( const std::string& rName, const StateAttr& attr) {
1165 FD_DG( "TaGenerator(" << this << ")::InsState(\"" << rName << "\", attr)");
1166 Idx index=mpStates->Insert();
1167 StateName(index,rName);
1168 StateAttribute(index,attr);
1175 FD_DG( "TaGenerator(" << this << ")::InjectStates("
1177 BASE::InjectStates(rNewStates);
1181 TEMP void THIS::InjectStates( const TaStateSet<StateAttr>& rNewStates) {
1182 FD_DG( "TaGenerator(" << this << ")::InjectStates("
1183 << rNewStates.ToString() << ")");
1184 *pStates=rNewStates;
1185 mpStates->Name( "States");
1186 mpStateSymbolTable->RestrictDomain(*mpStates);
1193 FD_DG( "TaGenerator::InjectTransRel(...)");
1194 *mpTransRel=rNewTransRel;
1199 FD_DG( "TaGenerator::InjectTransRel(...)");
1200 *pTransRel=rNewTransRel;
1205 TEMP bool THIS::SetTransition( const std::string& rX1, const std::string& rEv, const std::string& rX2) {
1206 return BASE::SetTransition(rX1,rEv,rX2);
1217 FD_DG( "TaGenerator(" << this << ")::SetTransition(" << rTransition. X1 << ","
1218 << rTransition. Ev << "," << rTransition. X2 << ")");
1219 #ifdef FAUDES_CHECKED
1220 if (! mpStates->Exists(rTransition. X1)) {
1221 std::stringstream errstr;
1222 errstr << "TaGenerator::SetTransition: state " << rTransition. X1
1223 << " not in stateset";
1224 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1226 if (! mpAlphabet->Exists(rTransition. Ev)) {
1227 std::stringstream errstr;
1228 errstr << "TaGenerator::SetTransition: event " << rTransition. Ev
1229 << " not in alphabet ";
1230 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1232 if (! mpStates->Exists(rTransition. X2)) {
1233 std::stringstream errstr;
1234 errstr << "TaGenerator::SetTransition: state " << rTransition. X2
1235 << " not in stateset";
1236 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1239 return mpTransRel->Insert(rTransition);
1243 TEMP bool THIS::SetTransition( const Transition& rTransition, const TransAttr& rAttr) {
1244 FD_DG( "TaGenerator(" << this << ")::SetTransition(" << rTransition. X1 << ","
1245 << rTransition. Ev << "," << rTransition. X2 << ", [attr:]" << rAttr.ToString() << ")");
1246 #ifdef FAUDES_CHECKED
1247 if (! mpStates->Exists(rTransition. X1)) {
1248 std::stringstream errstr;
1249 errstr << "TaGenerator::SetTransition: state " << rTransition. X1
1250 << " not in stateset";
1251 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1253 if (! mpAlphabet->Exists(rTransition. Ev)) {
1254 std::stringstream errstr;
1255 errstr << "TaGenerator::SetTransition: event " << rTransition. Ev
1256 << " not in alphabet ";
1257 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1259 if (! mpStates->Exists(rTransition. X2)) {
1260 std::stringstream errstr;
1261 errstr << "TaGenerator::SetTransition: state " << rTransition. X2
1262 << " not in stateset";
1263 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1266 return pTransRel->Insert(rTransition,rAttr);
1271 FD_DG( "TaGenerator(" << this << ")::TransAttribute("
1272 << TStr(rTrans) << ",\"" << rAttr.ToString() << "\")");
1273 pTransRel->Attribute(rTrans, rAttr);
1278 FD_DG( "TaGenerator(" << this << ")::TransAttribute("
1279 << TStr(rTrans) << ",\"" << rAttr. ToString() << "\")");
1280 const TransAttr* attrp = dynamic_cast<const TransAttr* >(&rAttr);
1282 std::stringstream errstr;
1283 errstr << "cannot cast event attribute " << rAttr. ToString() << " for generator " << Name();
1284 throw Exception( "TaGenerator::TransAttribute", errstr.str(), 63);
1286 mpTransRel->Attribute(rTrans, *attrp);
1291 return pTransRel->Attributep(rTrans);
1297 return pTransRel->Attribute(rTrans);
1301 TEMP void THIS::EventAttribute( Idx index, const EventAttr& rAttr) {
1302 FD_DG( "TaGenerator(" << this << ")::EventAttribute("
1303 << EStr(index) << ",\"" << rAttr.ToString() << "\")");
1304 pAlphabet->Attribute(index, rAttr);
1309 FD_DG( "TaGenerator(" << this << ")::EventAttribute("
1310 << EStr(index) << ",\"" << rAttr. ToString() << "\")");
1311 const EventAttr* attrp = dynamic_cast<const EventAttr* >(&rAttr);
1313 std::stringstream errstr;
1314 errstr << "cannot cast event attribute " << rAttr. ToString() << " for generator " << Name();
1315 throw Exception( "TaGenerator::EventAttribute", errstr.str(), 63);
1317 pAlphabet->Attribute(index, *attrp);
1321 TEMP const EventAttr& THIS::EventAttribute( Idx index) const {
1322 return pAlphabet->Attribute(index);
1326 TEMP EventAttr* THIS::EventAttributep( Idx index) {
1327 return pAlphabet->Attributep(index);
1331 TEMP const EventAttr& THIS::EventAttribute( const std::string& rName) const {
1332 return EventAttribute(EventIndex(rName));
1336 TEMP EventAttr* THIS::EventAttributep( const std::string& rName) {
1337 return EventAttributep(EventIndex(rName));
1341 TEMP void THIS::StateAttribute( Idx index, const StateAttr& rAttr) {
1342 FD_DG( "TaGenerator(" << this << ")::StateAttribute("
1343 << index << ",\"" << rAttr.ToString() << "\")");
1344 mpStates->Attribute(index, rAttr);
1349 FD_DG( "TaGenerator(" << this << ")::StateAttribute("
1350 << SStr(index) << ",\"" << rAttr. ToString() << "\")");
1351 const StateAttr* attrp = dynamic_cast<const StateAttr* >(&rAttr);
1353 std::stringstream errstr;
1354 errstr << "cannot cast event attribute " << rAttr. ToString() << " for generator " << Name();
1355 throw Exception( "TaGenerator::StateAttribute", errstr.str(), 63);
1357 mpStates->Attribute(index, *attrp);
1362 TEMP const StateAttr& THIS::StateAttribute( Idx index) const {
1363 return pStates->Attribute(index);
1367 TEMP StateAttr* THIS::StateAttributep( Idx index) {
1368 return pStates->Attributep(index);
1377 TEMP const TaStateSet<StateAttr>& THIS::States( void) const {
1382 TEMP const typename THIS::ATransSet& THIS::TransRel( void) const {
libFAUDES 2.24g
--- 2014.09.15
--- c++ api documentaion by doxygen
|