00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PETRI_NET_HH
00024 #define PETRI_NET_HH
00025
00026 #include <string>
00027 #include <list>
00028 #include <iostream>
00029 #include <map>
00030 #include <vector>
00031
00032 #include "marking.hh"
00033
00035 class petri_net {
00036 public:
00037
00041 static petri_net* parse(const char *file_name);
00042
00044 petri_net();
00045
00047 int p_size() const;
00048
00050 int t_size() const;
00051
00053 bool place_exists(const std::string& name) const;
00054
00056 bool transition_exists(const std::string& name) const;
00057
00061 int get_place_num(const std::string& name) const;
00062
00066 int get_transition_num(const std::string& name) const;
00067
00071 const std::string& get_place_name(int p) const;
00072
00076 const std::string& get_transition_name(int t) const;
00077
00083 void add_place(const std::string& name, int initial_marking = 0);
00084
00088 void add_transition(const std::string& name);
00089
00095 void set_input_place(const std::string& place_name, const std::string &trans_name,
00096 int valuation = 1);
00097
00103 void set_output_place(const std::string &place_name, const std::string &trans_name,
00104 int valuation = 1);
00105
00111 marking* get_initial_marking() const;
00112
00116 const marking& get_pre_condition(int t) const;
00117
00121 const marking& get_post_condition(int t) const;
00122
00129 std::list<int>* firable(const marking& m) const;
00130
00138 marking* successor(const marking& m, int t) const;
00139
00141 std::string format_marking(const marking& m) const;
00142
00144 friend std::ostream& operator<<(std::ostream &, const petri_net &);
00145
00146 private:
00148 std::map<std::string, int> name_num_p;
00150 std::map<std::string, int> name_num_t;
00152 std::vector<std::string> p_names;
00154 std::vector<std::string> t_names;
00156 std::vector<marking> pre, post, incidence;
00158 marking m0;
00159 };
00160
00161 #endif