1 #ifndef __DIADES__PETRI__NET_HH_ 2 #define __DIADES__PETRI__NET_HH_ 71 static string typeName() {
return "Diades::Petri::Net"; }
110 list<Arc>::const_iterator
_it;
133 const Place & operator *()
const 137 return _it->sourceRef();
139 return _it->targetRef();
158 list<Arc>::const_iterator _it2= _it;
169 const Place * operator ->(
void)
const 173 return &_it->sourceRef();
175 return &_it->targetRef();
185 return (_pre == it.
_pre) && (_it == it.
_it);
196 return !(*
this == it);
252 return (_it == it.
_it) && (_net == it.
_net) && (_type == it.
_type);
262 return !(*
this == it);
388 const set<Event> & synchronization,
bool strict =
true);
413 require(Exception, !_readOnly,
"setName: read only");
414 if(!_readOnly) { _name = name; }
415 else { printWarning(
"setName"); }
422 const string &
name()
const {
return _name; }
429 unsigned int id()
const 471 return _eventList.begin();
481 return _eventList.end();
492 require(Exception,t.valid(),
"getEvent: invalid transition");
493 require(Exception,&t.owner() == &_graph,
"getEvent: the transition does not belong to the Petri Net");
494 require(Exception, _nodeType[t] == T,
"getEvent; this is not a transition but a place" );
506 require(Exception,t.valid(),
"setEvent: invalid transition");
507 require(Exception,&t.owner() == &_graph,
508 "setEvent: the transition does not belong to the Petri Net");
509 require(Exception, _nodeType[t] == T,
510 "setEvent; this is not a transition but a place" );
511 require(Exception, !_readOnly,
"setEvent: read only");
514 _eventList.insert(event);
516 if(_transitionsOfEventId.size() <= event)
518 _transitionsOfEventId.resize(event+1);
520 _transitionsOfEventId[event].insert(t);
524 printWarning(
"setEvent");
536 if(_transitionsOfEventId.size() <= event)
540 return !_transitionsOfEventId[event].empty();
558 require(Exception, !_readOnly,
"newPlace: read only");
563 p = _graph.newNode();
566 s <<
"__p" << p.id();
572 printWarning(
"newPlace");
574 ensure(Exception, p.valid(),
"newPlace: invalid returned place");
575 ensure(Exception, &p.owner() == &graph(),
"newPlace: invalid returned place");
586 Place newPlace(
const string & label);
592 require(Exception, !_readOnly,
"setLabelOfPlace: read only");
593 require(Exception,_placeOfLabel.find(label) == _placeOfLabel.end(),
594 "setLabelOfPlace: this label already exists in the net");
595 _labelNode[place] = label;
596 _placeOfLabel[label] = place;
640 return _labelNode[p];
651 require(Exception,p.valid(),
"getInfoLabel: invalid place");
652 require(Exception,&p.owner() == &_graph,
"getInfoLabel: the place does not belong to the Petri Net");
653 require(Exception, _nodeType[p] == P,
"getInfoLabel: this is not a place but a transition" );
667 require(Exception,p.valid(),
"setInfoLabel: invalid place");
668 require(Exception,&p.owner() == &_graph,
"setInfoLabel: the place does not belong to the Petri Net");
669 require(Exception, _nodeType[p] == P,
"setInfoLabel: this is not a place but a transition" );
670 require(Exception, !_readOnly,
"setInfoLabel: read only");
695 virtual bool enables(
const Transition & t,
const set<Place> & marking);
707 virtual Transition newTransition(
const set<Place> & pre,
const set<Place> & post);
719 virtual Transition
newTransition(
const set<Place> & pre,
const set<Place> & post,
const string & label)
721 require(Exception, !_readOnly,
"newTransition: read only");
725 trans = newTransition(pre,post);
726 setLabelOfTransition(trans,label);
730 printWarning(
"newTransition");
744 return _nbTransitions;
755 return _graph.numberOfEdges();
765 void addPre(Transition transition, Place place)
767 _graph.newEdge(place,transition);
777 void addPost(Transition transition, Place place)
779 _graph.newEdge(transition,place);
788 bool pre(
const Vdd * marking,
const Transition & t)
const;
917 require(Exception, !_readOnly,
"setLabelOfTransition: read only");
918 _labelNode[t] = label;
928 return _labelNode[t];
937 bool inPre(
const Transition & t,
const Place & p)
const;
946 require(Exception,containsEvent(event),
947 "beginOfTransitionWithEvent: the event is not associated to a transition of this Petri Net");
948 return _transitionsOfEventId[event].begin();
960 require(Exception,containsEvent(event),
961 "endOfTransitionWithEvent: the event is not associated to a transition of this Petri Net");
962 return _transitionsOfEventId[event].end();
979 virtual Transition duplicateTransition(Transition t);
1004 void setPostponable(Transition t);
1013 require(Exception, t.valid(),
"isPostponable: invalid transition");
1014 require(Exception, &t.owner() == &graph(),
"isPostponable: the transition does not belong to the Petri Net");
1015 return _postponable[t] == Postponable;
1025 void setNotPostponable(Transition t);
1046 const set<Event> & synchronization,
bool strict);
1063 void setMarking(
const set<Place> & marking);
1071 return _initialMarking != 0;
1079 bool isMarked(Place p)
const;
1095 void unmark(Place p);
1105 return _explicitInitialMarking;
1125 virtual void net2Dot(
const string & fileName)
const;
1135 virtual void net2Tina(ostream & os)
const;
1144 cerr <<
"WARNING: attempt to modify a read-only net (" << s <<
")" << endl;
1151 void printFactory(
const string & fileName)
const;
1178 void unlock()
const;
1184 const Vdd * marking()
const;
1194 const Zsl * getPreZsl(Transition t)
const;
1203 const Zsl * getIncidenceZsl(Transition t)
const;
1209 const Vdd * reachableNodes()
const;
1217 void printVdd(
const Vdd * result,
string fileName);
TransitionIterator endOfTransitions() const
set< Place > _explicitInitialMarking
void setLabelOfTransition(const Transition &t, const string &label)
size_t numberOfTransitions() const
ConstIterator preEnd(const Transition &transition) const
const set< Place > & initialMarking() const
bool synchronize(const std::vector< typename Ptr< Fsm >::ConstP > &components, const SynchronisationRules< Fsm > &rules, Fsm &synchronisation, StateCreator &creator)
ConstIterator preBegin(const Transition &transition) const
PerTypeIterator PlaceIterator
EventIterator beginOfEvents() const
ConstIterator postBegin(const Transition &transition) const
const Vdd * _initialMarking
vector< set< Transition > > _transitionsOfEventId
ConstIterator postTransBegin(const Place &place) const
EventIterator endOfEvents() const
Diades::Utils::Exception< Net > Exception
Diades::Graph::Node Place
Graph::ConstNodeMap< const Zsl * > _incidenceZslOfTransition
TransitionEventIterator endOfTransitionWithEvent(Event event) const
virtual void setEvent(Transition t, Event event)
#define ensure(Exception, expr, message)
PlaceIterator beginOfPlaces() const
bool isPostponable(Transition t) const
const string & labelOfTransition(const Transition &t) const
const Event & getEvent(Transition t) const
Graph::NodeMap< int > _postponable
set< Event >::const_iterator EventIterator
Graph::NodeMap< string > _infoNode
Graph::NodeMap< string > _labelNode
virtual Transition newTransition(const set< Place > &pre, const set< Place > &post, const string &label)
void setLabelOfPlace(const Place &place, const string &label)
list< Arc >::const_iterator _it
AutFsm::Transition Transition
DdAutFsm::EventPropertyId Event
void addPre(Transition transition, Place place)
GraphIterator< Node > NodeIterator
ZslFactory * zslFactory() const
void deleteTransition(Component &comp, InputIterator first, InputIterator last)
Graph::NodeMap< NodeType > _nodeType
PlaceIterator endOfPlaces() const
void printWarning(const string &s) const
#define require(Exception, expr, message)
const string & getInfoLabel(Place p) const
Namespace of the Diades project.
ConstIterator postEnd(const Transition &transition) const
unordered_map< string, Graph::Node > _placeOfLabel
bool containsEvent(Event event) const
PerTypeIterator TransitionIterator
void setName(const string &name)
VddFactory * vddFactory() const
const string & labelOfPlace(const Place &p) const
const string & name() const
ConstIterator on the Net.
Iterators over the places or the transitions of the Net.
boost::adjacency_list Graph
const Vdd * _reachableNodes
const Diades::Graph::Graph & graph() const
ConstIterator preTransEnd(const Place &place) const
ConstIterator preTransBegin(const Place &place) const
set< Transition >::const_iterator TransitionEventIterator
void setInfoLabel(Place p, const string &info)
size_t numberOfArcs() const
Graph::NodeMap< Event > _event
size_t numberOfPlaces() const
ConstIterator postTransEnd(const Place &place) const
ConstIterator(list< Arc >::const_iterator it, bool pre)
TransitionEventIterator beginOfTransitionWithEvent(Event event) const
void addPost(Transition transition, Place place)
TransitionIterator beginOfTransitions() const
Graph::ConstNodeMap< const Zsl * > _preZslOfTransition