6 #ifndef DIAG_GENERATOR_H 
    7 #define DIAG_GENERATOR_H 
   25 template <
class GlobalAttr, 
class StateAttr, 
class EventAttr, 
class TransAttr>
 
   85       FD_DG(
"TdiagGenerator(" << 
this << 
")::~TdiagGenerator()");
 
  112     Idx InsFailureTypeMapping(
const std::string& failureType, 
const EventSet& rfailureEvents);
 
  119     void InsFailureTypeMap(
const std::map<std::string,EventSet>& rFailureMap);
 
  128     Idx GetFailureType(
Idx failureEvent) 
const;
 
  135     EventSet GetAllFailureEvents(
void) 
const;
 
  146     void InsStateLabelMapping(
Idx dStateIndex, 
Idx gStateIndex, 
Idx labelIndex);
 
  175     std::string SAStr(
Idx dStateIndex) 
const;
 
  188     void DotWrite(
const std::string& rFileName) 
const;
 
  201 #ifdef FAUDES_COMPATIBILITY 
  221 #define THIS TdiagGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 
  222 #define BASE TcGenerator<GlobalAttr, StateAttr, EventAttr, TransAttr> 
  223 #define TEMP template<class GlobalAttr, class StateAttr, class EventAttr, class TransAttr> 
  228   FD_DG(
"TdiagGenerator(" << 
this << 
")::TdiagGenerator()");
 
  230   BASE::mReindexOnWrite=
false;
 
  235   FD_DG(
"TdiagGenerator(" << 
this << 
")::TdiagGenerator(rOtherGen)");
 
  237   BASE::mReindexOnWrite=
false;
 
  242   FD_DG(
"TdiagGenerator(" << 
this << 
")::TdiagGenerator(rOtherGen)");
 
  244   BASE::mReindexOnWrite=
false;
 
  248 TEMP THIS::TdiagGenerator(
const std::string& rFileName) : 
BASE() {
 
  249   FD_DG(
"TDiagGenerator(" << 
this << 
")::TdiagGenerator(rFilename) : done");
 
  251   BASE::mReindexOnWrite=
false;
 
  252   BASE::Read(rFileName);
 
  260   res->EventSymbolTablep(BASE::mpEventSymbolTable);
 
  261   res->mStateNamesEnabled=BASE::mStateNamesEnabled;
 
  262   res->mReindexOnWrite=BASE::mReindexOnWrite;  
 
  264   res->mpLabelSymbolTable=mpLabelSymbolTable;
 
  278 TEMP Idx THIS::InsFailureTypeMapping(
const std::string& failureType, 
const EventSet& rfailureEvents) {
 
  279   return BASE::pGlobalAttribute->AddFailureTypeMapping(failureType, rfailureEvents);
 
  283 TEMP void THIS::InsFailureTypeMap(
const std::map<std::string,EventSet>& rFailureMap) {
 
  284   BASE::pGlobalAttribute->AddFailureTypeMap(rFailureMap);
 
  290   return BASE::pGlobalAttribute->FailureType(failureEvent);
 
  295   return BASE::pGlobalAttribute->AllFailureEvents();
 
  299 TEMP void THIS::InsStateLabelMapping(
Idx dStateIndex, 
Idx gStateIndex, 
Idx labelIndex) {
 
  300   BASE::StateAttributep(dStateIndex)->AddStateLabelMapping(gStateIndex, labelIndex);
 
  306   BASE::StateAttributep(dStateIndex)->AddStateLabelMap(gState, labels);
 
  312   BASE::StateAttribute(dStateIndex,newAttr);
 
  316 TEMP std::string THIS::SAStr(
Idx dStateIndex)
 const {
 
  317   return BASE::StateAttribute(dStateIndex).Str();
 
  321 TEMP void THIS::DotWrite(
const std::string& rFileName)
 const {
 
  322   FD_DG(
"TdiagGenerator(" << 
this << 
")::DotWrite(" << rFileName << 
")");
 
  323   BASE::SetMinStateIndexMap();
 
  324   StateSet::Iterator lit;
 
  325   typename BASE::ATransSet::Iterator tit;
 
  327     std::ofstream stream;
 
  328     stream.exceptions(std::ios::badbit|std::ios::failbit);
 
  329     stream.open(rFileName.c_str());
 
  330     stream << 
"digraph \"" << BASE::Name() << 
"\" {" << std::endl;
 
  331     stream << 
"  rankdir=LR" << std::endl;
 
  332     stream << 
"  node [shape=box];" << std::endl;
 
  334     stream << 
"  // initial states" << std::endl;
 
  336     for (lit = BASE::InitStatesBegin(); lit != BASE::InitStatesEnd(); ++lit) {
 
  338       std::string xname = SAStr(*lit);
 
  340       stream << 
"  dot_dummyinit_" << i << 
" [shape=none, label=\"\" ];" << std::endl;
 
  341       stream << 
"  dot_dummyinit_" << i << 
" -> \"" << xname << 
"\";" << std::endl; 
 
  345     stream << 
"  // marked states" << std::endl;
 
  346     for (lit = BASE::MarkedStatesBegin(); lit != BASE::MarkedStatesEnd(); ++lit) {
 
  348       std::string xname = SAStr(*lit);
 
  350       stream << 
"  \"" << xname << 
"\" [shape=doubleoctagon];" << std::endl;
 
  353     stream << 
"  // rest of stateset" << std::endl;
 
  354     for (lit = BASE::StatesBegin(); lit != BASE::StatesEnd(); ++lit) {
 
  355       if (! (BASE::ExistsInitState(*lit) || BASE::ExistsMarkedState(*lit)) ) {
 
  357   std::string xname = SAStr(*lit);
 
  359   stream << 
"  \"" << xname << 
"\";" << std::endl;
 
  364     stream << 
"  // transition relation" << std::endl;
 
  365     for (tit = BASE::TransRelBegin(); tit != BASE::TransRelEnd(); ++tit) {
 
  367       std::string x1name = SAStr(tit->X1);
 
  370       std::string x2name = SAStr(tit->X2);
 
  372       stream << 
"  \"" << x1name  << 
"\" -> \"" << x2name
 
  373        << 
"\" [label=\"" << BASE::EventName(tit->Ev) << 
"\"];" << std::endl;
 
  375     stream << 
"}" << std::endl;
 
  378   catch (std::ios::failure&) {
 
  379     throw Exception(
"TdiagGenerator::DotWrite", 
 
  380         "Exception opening/writing dotfile \""+rFileName+
"\"", 2);
 
  382   BASE::ClearMinStateIndexMap();
 
static SymbolTable * StaticLabelSymbolTablep(void)
 
SymbolTable * mpLabelSymbolTable
 
TdiagGenerator< AttributeFailureTypeMap, AttributeDiagnoserState, AttributeCFlags, AttributeVoid > Diagnoser
 
TdiagGenerator< AttributeFailureTypeMap, AttributeDiagnoserState, AttributeCFlags, AttributeVoid > diagGenerator
 
std::string ToStringInteger(Int number)