|
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>
230 bool Valid( void) const;
238 virtual void Clear( void);
260 const TaEventSet<EventAttr>& Alphabet( void) const;
268 const TaStateSet<StateAttr>& States( void) const;
354 Idx InsEvent( const std::string& rName, const EventAttr& rAttr);
427 Idx InsState( const std::string& rName, const StateAttr& attr);
459 void InjectStates( const TaStateSet<StateAttr>& rNewStates);
502 bool SetTransition( const std::string& rX1, const std::string& rEv,
503 const std::string& rX2);
804 #define THIS TaGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr>
805 #define TEMP template <class GlobalAttr, class StateAttr, class EventAttr, class TransAttr>
806 #define BASE vGenerator
821 TEMP const GlobalAttr& THIS::GlobalTaGen( void) {
822 static GlobalAttr fls;;
832 FD_DG( "TaGenerator(" << this << ")::TaGenerator()");
836 FD_DG( "TaGenerator(" << this << ")::TaGenerator(): done");
844 FD_DG( "TaGenerator(" << this << ")::TaGenerator(" << &rOtherGen << ")");
858 FD_DG( "TaGenerator(" << this << ")::TaGenerator([v]" << &rOtherGen << ")");
864 FD_DG( "TaGenerator(" << this << ")::TaGenerator([v]" << &rOtherGen << "): ok");
868 TEMP THIS::TaGenerator( const std::string& rFileName) :
872 FD_DG( "TaGenerator(" << this << ")::TaGenerator(" << rFileName << ")");
885 TEMP void THIS::NewCore( void) {
886 FD_DG( "TaGenerator(" << this << ")::NewCore()");
894 mpAlphabet= AlphabetTaGen().New();
895 mpStates=StatesTaGen().New();
896 mpTransRel=TransRelTaGen().New();
897 mpGlobalAttribute=GlobalTaGen().New();
903 TEMP void THIS::UpdateCore( void) {
907 pGlobalAttribute = dynamic_cast< GlobalAttr* >(mpGlobalAttribute);
910 pTransRel = dynamic_cast< ATransSet* >(mpTransRel);
913 if(pGlobalAttribute==0 && mpGlobalAttribute!=0) tmm= true;
914 if(pAlphabet==0 && mpAlphabet!=0) tmm= true;
915 if(pStates==0 && mpStates!=0) tmm= true;
916 if(pTransRel==0 && mpTransRel!=0) tmm= true;
918 std::stringstream errstr;
919 errstr << "cannot cast attributes for generator " << Name();
920 throw Exception( "Generator::UpdateCore", errstr.str(), 63);
927 FD_DG( "TaGenerator(" << this << ")::DoAssign(" << &rGen << ")");
928 FD_DG( "TaGenerator(" << this << ")::DoAssign(..): types " << typeid(*this).name() << " <= " << typeid(rGen).name());
947 #ifdef FAUDES_DEBUG_CODE
949 FD_DG( "TaGenerator()::DoAssign(): invalid generator");
954 FD_DG( "TaGenerator(" << this << ")::DoAssign(" << &rGen << "): done");
959 FD_DG( "TaGenerator(" << this << ")::Assign([type] " << &rSrc << ")");
963 if( this==agen) return * this;
977 FD_DG( "TaGenerator(" << this << ")::Move(" << &rGen << ")");
985 FD_DG( "TaGenerator(" << this << ")::Move([v]" << &rGen << ")");
991 TEMP THIS::~TaGenerator( void) {
992 FD_DG( "TaGenerator(" << this << ")::~TaGenerator()");
1000 res->EventSymbolTablep(BASE::mpEventSymbolTable);
1001 res->mStateNamesEnabled=BASE::mStateNamesEnabled;
1002 res->mReindexOnWrite=BASE::mReindexOnWrite;
1018 res.EventSymbolTablep(BASE::mpEventSymbolTable);
1019 res.mStateNamesEnabled=BASE::mStateNamesEnabled;
1020 res.mReindexOnWrite=BASE::mReindexOnWrite;
1027 return dynamic_cast< const THIS* > (pOther);
1033 FD_DG( "TaGenerator(" << this << ")::operator = [v]" << &rOtherGen);
1034 return Assign(rOtherGen);
1038 TEMP bool THIS::Valid( void) const {
1039 FD_DG( "TaGenerator(" << this << ")::Valid()");
1040 if(!BASE::Valid()) return false;
1043 if( typeid( Alphabet().AttributeType())!= typeid( const EventAttr*)) tmm= true;
1044 if( typeid(States().AttributeType())!= typeid( const StateAttr*)) tmm= true;
1045 if( typeid(TransRel().AttributeType())!= typeid( const TransAttr*)) tmm= true;
1046 if( typeid(GlobalAttribute())!= typeid( const GlobalAttr&)) tmm= true;
1058 FD_DG( "TaGenerator(" << this << ")::Clear()");
1065 FD_DG( "TaGenerator::InjectAlphabet() " << rNewAlphabet. ToString());
1066 BASE::InjectAlphabet(rNewAlphabet);
1070 TEMP void THIS::InjectAlphabet( const TaEventSet<EventAttr>& rNewAlphabet) {
1071 FD_DG( "TaGenerator::InjectAlphabet(TaEventSet<EventAttr>) " << rNewAlphabet.ToString());
1072 #ifdef FAUDES_CHECKED
1073 if(rNewAlphabet.SymbolTablep()!=mpEventSymbolTable) {
1074 std::stringstream errstr;
1075 errstr << "symboltable mismatch aka not implemented" << std::endl;
1076 throw Exception( "TaGenerator::InjectAlphabet", errstr.str(), 88);
1079 *pAlphabet=rNewAlphabet;
1080 mpAlphabet->Name( "Alphabet");
1085 FD_DG( "TaGenerator(" << this << ")::InsEvent(" << index << ")");
1086 return pAlphabet->Insert(index);
1090 TEMP Idx THIS::InsEvent( const std::string& rName) {
1091 FD_DG( "TaGenerator(" << this << ")::InsEvent(\"" << rName << "\")");
1092 return pAlphabet->Insert(rName);
1096 TEMP bool THIS::InsEvent( Idx index, const EventAttr& attr) {
1097 FD_DG( "TaGenerator(" << this << ")::InsEvent(" << index << " " << attr.ToString() << ")");
1098 return pAlphabet->Insert(index, attr);
1102 TEMP Idx THIS::InsEvent( const std::string& rName, const EventAttr& attr) {
1103 FD_DG( "TaGenerator(" << this << ")::InsEvent(\"" << rName << attr.ToString() << "\")");
1104 return pAlphabet->Insert(rName, attr);
1109 FD_DG( "TaGenerator(" << this << ")::InsState()");
1110 return pStates->Insert();
1115 FD_DG( "TaGenerator(" << this << ")::InsState(attr)");
1116 return pStates->Insert(attr);
1121 FD_DG( "TaGenerator(" << this << ")::InsState(" << index << ")");
1122 return pStates->Insert(index);
1126 TEMP bool THIS::InsState( Idx index, const StateAttr& rAttr) {
1127 FD_DG( "TaGenerator(" << this << ")::InsState(" << index << ",rAttr)");
1128 return pStates->Insert(index,rAttr);
1132 TEMP Idx THIS::InsState( const std::string& rName) {
1133 FD_DG( "TaGenerator(" << this << ")::InsState(\"" << rName << "\")");
1134 Idx index=pStates->Insert();
1135 StateName(index,rName);
1140 TEMP Idx THIS::InsState( const std::string& rName, const StateAttr& attr) {
1141 FD_DG( "TaGenerator(" << this << ")::InsState(\"" << rName << "\", attr)");
1142 Idx index=pStates->Insert();
1143 StateName(index,rName);
1144 StateAttribute(index,attr);
1151 FD_DG( "TaGenerator(" << this << ")::InjectStates("
1153 BASE::InjectStates(rNewStates);
1157 TEMP void THIS::InjectStates( const TaStateSet<StateAttr>& rNewStates) {
1158 FD_DG( "TaGenerator(" << this << ")::InjectStates("
1159 << rNewStates.ToString() << ")");
1160 *pStates=rNewStates;
1161 pStates->Name( "States");
1162 mpStateSymbolTable->RestrictDomain(*mpStates);
1169 FD_DG( "TaGenerator::InjectTransRel(...)");
1170 *pTransRel=rNewTransRel;
1175 FD_DG( "TaGenerator::InjectTransRel(...)");
1176 *pTransRel=rNewTransRel;
1181 TEMP bool THIS::SetTransition( const std::string& rX1, const std::string& rEv, const std::string& rX2) {
1182 return BASE::SetTransition(rX1,rEv,rX2);
1193 FD_DG( "TaGenerator(" << this << ")::SetTransition(" << rTransition. X1 << ","
1194 << rTransition. Ev << "," << rTransition. X2 << ")");
1195 #ifdef FAUDES_CHECKED
1196 if (! mpStates->Exists(rTransition. X1)) {
1197 std::stringstream errstr;
1198 errstr << "TaGenerator::SetTransition: state " << rTransition. X1
1199 << " not in stateset";
1200 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1202 if (! mpAlphabet->Exists(rTransition. Ev)) {
1203 std::stringstream errstr;
1204 errstr << "TaGenerator::SetTransition: event " << rTransition. Ev
1205 << " not in alphabet ";
1206 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1208 if (! mpStates->Exists(rTransition. X2)) {
1209 std::stringstream errstr;
1210 errstr << "TaGenerator::SetTransition: state " << rTransition. X2
1211 << " not in stateset";
1212 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1215 return pTransRel->Insert(rTransition);
1219 TEMP bool THIS::SetTransition( const Transition& rTransition, const TransAttr& rAttr) {
1220 FD_DG( "TaGenerator(" << this << ")::SetTransition(" << rTransition. X1 << ","
1221 << rTransition. Ev << "," << rTransition. X2 << ", [attr:]" << rAttr.ToString() << ")");
1222 #ifdef FAUDES_CHECKED
1223 if (! mpStates->Exists(rTransition. X1)) {
1224 std::stringstream errstr;
1225 errstr << "TaGenerator::SetTransition: state " << rTransition. X1
1226 << " not in stateset";
1227 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1229 if (! mpAlphabet->Exists(rTransition. Ev)) {
1230 std::stringstream errstr;
1231 errstr << "TaGenerator::SetTransition: event " << rTransition. Ev
1232 << " not in alphabet ";
1233 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1235 if (! mpStates->Exists(rTransition. X2)) {
1236 std::stringstream errstr;
1237 errstr << "TaGenerator::SetTransition: state " << rTransition. X2
1238 << " not in stateset";
1239 throw Exception( "TaGenerator::SetTransition(..)", errstr.str(), 95);
1242 return pTransRel->Insert(rTransition,rAttr);
1247 FD_DG( "TaGenerator(" << this << ")::TransAttribute("
1248 << TStr(rTrans) << ",\"" << rAttr.ToString() << "\")");
1249 pTransRel->Attribute(rTrans, rAttr);
1254 FD_DG( "TaGenerator(" << this << ")::TransAttribute("
1255 << TStr(rTrans) << ",\"" << rAttr. ToString() << "\")");
1256 const TransAttr* attrp = dynamic_cast<const TransAttr* >(&rAttr);
1258 std::stringstream errstr;
1259 errstr << "cannot cast event attribute " << rAttr. ToString() << " for generator " << Name();
1260 throw Exception( "TaGenerator::TransAttribute", errstr.str(), 63);
1262 pTransRel->Attribute(rTrans, *attrp);
1267 return pTransRel->Attributep(rTrans);
1273 return pTransRel->Attribute(rTrans);
1277 TEMP void THIS::EventAttribute( Idx index, const EventAttr& rAttr) {
1278 FD_DG( "TaGenerator(" << this << ")::EventAttribute("
1279 << EStr(index) << ",\"" << rAttr.ToString() << "\")");
1280 pAlphabet->Attribute(index, rAttr);
1285 FD_DG( "TaGenerator(" << this << ")::EventAttribute("
1286 << EStr(index) << ",\"" << rAttr. ToString() << "\")");
1287 const EventAttr* attrp = dynamic_cast<const EventAttr* >(&rAttr);
1289 std::stringstream errstr;
1290 errstr << "cannot cast event attribute " << rAttr. ToString() << " for generator " << Name();
1291 throw Exception( "TaGenerator::EventAttribute", errstr.str(), 63);
1293 pAlphabet->Attribute(index, *attrp);
1297 TEMP const EventAttr& THIS::EventAttribute( Idx index) const {
1298 return pAlphabet->Attribute(index);
1302 TEMP EventAttr* THIS::EventAttributep( Idx index) {
1303 return pAlphabet->Attributep(index);
1307 TEMP const EventAttr& THIS::EventAttribute( const std::string& rName) const {
1308 return EventAttribute(EventIndex(rName));
1312 TEMP EventAttr* THIS::EventAttributep( const std::string& rName) {
1313 return EventAttributep(EventIndex(rName));
1317 TEMP void THIS::StateAttribute( Idx index, const StateAttr& rAttr) {
1318 FD_DG( "TaGenerator(" << this << ")::StateAttribute("
1319 << index << ",\"" << rAttr.ToString() << "\")");
1320 pStates->Attribute(index, rAttr);
1325 FD_DG( "TaGenerator(" << this << ")::StateAttribute("
1326 << SStr(index) << ",\"" << rAttr. ToString() << "\")");
1327 const StateAttr* attrp = dynamic_cast<const StateAttr* >(&rAttr);
1329 std::stringstream errstr;
1330 errstr << "cannot cast event attribute " << rAttr. ToString() << " for generator " << Name();
1331 throw Exception( "TaGenerator::StateAttribute", errstr.str(), 63);
1333 pStates->Attribute(index, *attrp);
1338 TEMP const StateAttr& THIS::StateAttribute( Idx index) const {
1339 return pStates->Attribute(index);
1343 TEMP StateAttr* THIS::StateAttributep( Idx index) {
1344 return pStates->Attributep(index);
1353 TEMP const TaStateSet<StateAttr>& THIS::States( void) const {
1358 TEMP const typename THIS::ATransSet& THIS::TransRel( void) const {
libFAUDES 2.28a
--- 2016.09.13
--- c++ api documentaion by doxygen
|