Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

petri_net Class Reference

A simple Petri net class. More...

Collaboration diagram for petri_net:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 petri_net ()
 Construct an empty petri net.
int p_size () const
 Return the number of places in the net.
int t_size () const
 Return the number of transitions in the net.
bool place_exists (const std::string &name) const
 Return true if a place of name name is present in the net.
bool transition_exists (const std::string &name) const
 Return true if a transition of name name is present in the net.
int get_place_num (const std::string &name) const
 Return the unique identifier of the place name.
int get_transition_num (const std::string &name) const
 Return the unique identifier of the transition name.
const std::string & get_place_name (int p) const
 Return the name of the place identified by p.
const std::string & get_transition_name (int t) const
 Return the name of the transition identified by t.
void add_place (const std::string &name, int initial_marking=0)
 Create a new place of name name and of initial marking initial_marking.
void add_transition (const std::string &name)
 Create a new transition of name name.
void set_input_place (const std::string &place_name, const std::string &trans_name, int valuation=1)
 Define the place place_name as an input of the transition transition_name with the valuation valuation.
void set_output_place (const std::string &place_name, const std::string &trans_name, int valuation=1)
 Define the place place_name as an output of the transition transition_name with the valuation valuation.
markingget_initial_marking () const
 Get the initial marking of the Petri net.
const markingget_pre_condition (int t) const
 Get the precondition of t.
const markingget_post_condition (int t) const
 Get the postcondition of t.
std::list< int > * firable (const marking &m) const
 Return the list of identifiers of the transitions which are firable from the marking m.
markingsuccessor (const marking &m, int t) const
 Return the marking reached when firing the transition identified by t from the marking m.
std::string format_marking (const marking &m) const
 Format the marking m as a string for printing.

Static Public Member Functions

static petri_netparse (const char *file_name)
 Create a petri net from the file file_name.

Private Attributes

std::map< std::string, int > name_num_p
 map between the names of the places and their integer numbers.
std::map< std::string, int > name_num_t
 map between the names of the transitions and their integer numbers.
std::vector< std::string > p_names
 names of the places.
std::vector< std::string > t_names
 names of the transitions.
std::vector< markingpre
 pre, post and incidence matrix.
std::vector< markingpost
 pre, post and incidence matrix.
std::vector< markingincidence
 pre, post and incidence matrix.
marking m0
 initial marking.

Friends

std::ostream & operator<< (std::ostream &, const petri_net &)
 Print the Petri net in 'prod' format.

Detailed Description

A simple Petri net class.

Definition at line 35 of file petrinet.hh.


Constructor & Destructor Documentation

petri_net::petri_net  ) 
 

Construct an empty petri net.


Member Function Documentation

void petri_net::add_place const std::string &  name,
int  initial_marking = 0
 

Create a new place of name name and of initial marking initial_marking.

The place name must be distinct of the existing ones and the initial marking be positive.

void petri_net::add_transition const std::string &  name  ) 
 

Create a new transition of name name.

The place name must be distinct of the existing ones.

std::list<int>* petri_net::firable const marking m  )  const
 

Return the list of identifiers of the transitions which are firable from the marking m.

The list has been allocated with new. It is the responsability of the caller to delete it when no longer needed.

std::string petri_net::format_marking const marking m  )  const
 

Format the marking m as a string for printing.

marking* petri_net::get_initial_marking  )  const
 

Get the initial marking of the Petri net.

The marking has been allocated with new. It is the responsability of the caller to delete it when no longer needed.

const std::string& petri_net::get_place_name int  p  )  const
 

Return the name of the place identified by p.

p must be a valid identifier.

int petri_net::get_place_num const std::string &  name  )  const
 

Return the unique identifier of the place name.

The place must exist.

const marking& petri_net::get_post_condition int  t  )  const
 

Get the postcondition of t.

t must be a valid identifier.

const marking& petri_net::get_pre_condition int  t  )  const
 

Get the precondition of t.

t must be a valid identifier.

const std::string& petri_net::get_transition_name int  t  )  const
 

Return the name of the transition identified by t.

t must be a valid identifier.

int petri_net::get_transition_num const std::string &  name  )  const
 

Return the unique identifier of the transition name.

The place must exist.

int petri_net::p_size  )  const
 

Return the number of places in the net.

static petri_net* petri_net::parse const char *  file_name  )  [static]
 

Create a petri net from the file file_name.

Return a null pointer in case of error.

bool petri_net::place_exists const std::string &  name  )  const
 

Return true if a place of name name is present in the net.

void petri_net::set_input_place const std::string &  place_name,
const std::string &  trans_name,
int  valuation = 1
 

Define the place place_name as an input of the transition transition_name with the valuation valuation.

The place and the transition must exist and the valuation be positive.

void petri_net::set_output_place const std::string &  place_name,
const std::string &  trans_name,
int  valuation = 1
 

Define the place place_name as an output of the transition transition_name with the valuation valuation.

The place and the transition must exist and the valuation be positive.

marking* petri_net::successor const marking m,
int  t
const
 

Return the marking reached when firing the transition identified by t from the marking m.

t must be firable from m. The marking has been allocated with new. It is the responsability of the caller to delete it when no longer needed.

int petri_net::t_size  )  const
 

Return the number of transitions in the net.

bool petri_net::transition_exists const std::string &  name  )  const
 

Return true if a transition of name name is present in the net.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  ,
const petri_net
[friend]
 

Print the Petri net in 'prod' format.


Member Data Documentation

std::vector<marking> petri_net::incidence [private]
 

pre, post and incidence matrix.

Definition at line 156 of file petrinet.hh.

marking petri_net::m0 [private]
 

initial marking.

Definition at line 158 of file petrinet.hh.

std::map<std::string, int> petri_net::name_num_p [private]
 

map between the names of the places and their integer numbers.

Definition at line 148 of file petrinet.hh.

std::map<std::string, int> petri_net::name_num_t [private]
 

map between the names of the transitions and their integer numbers.

Definition at line 150 of file petrinet.hh.

std::vector<std::string> petri_net::p_names [private]
 

names of the places.

Definition at line 152 of file petrinet.hh.

std::vector<marking> petri_net::post [private]
 

pre, post and incidence matrix.

Definition at line 156 of file petrinet.hh.

std::vector<marking> petri_net::pre [private]
 

pre, post and incidence matrix.

Definition at line 156 of file petrinet.hh.

std::vector<std::string> petri_net::t_names [private]
 

names of the transitions.

Definition at line 154 of file petrinet.hh.


The documentation for this class was generated from the following file:
Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Jan 31 15:17:15 2005 for checkpn by doxygen 1.4.0