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

petrinet.hh

Go to the documentation of this file.
00001 // Copyright (C) 2004  Laboratoire d'Informatique de Paris 6 (LIP6),
00002 // département Systèmes Répartis Coopératifs (SRC), Université Pierre
00003 // et Marie Curie.
00004 //
00005 // This file is part of the Spot tutorial. Spot is a model checking 
00006 // library.
00007 //
00008 // Spot is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // Spot is distributed in the hope that it will be useful, but WITHOUT
00014 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
00016 // License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with Spot; see the file COPYING.  If not, write to the Free
00020 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00021 // 02111-1307, USA.
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

Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Jan 31 15:17:13 2005 for checkpn by doxygen 1.4.0