Vaucanson  1.4.1
history.hh
1 // history.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_AUTOMATA_CONCEPT_HISTORY_HH
18 # define VCSN_AUTOMATA_CONCEPT_HISTORY_HH
19 
20 # include <list>
21 # include <map>
22 # include <string>
23 
24 # include <vaucanson/automata/concept/handlers.hh>
25 // # include <vaucanson/misc/ref.hh>
26 
27 namespace vcsn {
28 
29  namespace history {
30 
31  typedef std::string event_kind_t;
32 
33  template <class T>
34  class Event
35  {
36  public:
37  Event(event_kind_t e);
38 
39  virtual
40  event_kind_t
41  get_event_kind() const;
42 
43  virtual ~Event();
44  protected :
45  event_kind_t kind_;
46  };
47 
48  template <class T>
49  class BinaryEvent : public Event<T>
50  {
51  public:
52  BinaryEvent(event_kind_t e, const T& first, const T& second);
53 
54  const T&
55  get_first() const;
56 
57  const T&
58  get_second() const;
59 
60  protected :
61  T first_, second_;
62  };
63 
64  template <class T>
65  class UnaryEvent : public Event<T>
66  {
67  public:
68  UnaryEvent(event_kind_t e, const T& first);
69 
70  const T&
71  get_first() const;
72 
73  protected :
74  T first_;
75  };
76 
77  template <class T>
78  std::ostream&
79  operator<<(std::ostream& out, const Event<T>& e);
80 
81  template <class AutoType_>
82  class AutomatonHistory
83  {
84  public :
85  typedef typename AutoType_::hstate_t hstate_t;
86  typedef typename AutoType_::htransition_t htransition_t;
87  typedef std::list<Event<AutoType_> > auto_events_t;
88  typedef std::list<Event<hstate_t> > state_events_t;
89  typedef std::list<Event<htransition_t> > transition_events_t;
90  typedef std::map<hstate_t, state_events_t> states_events_t;
91  typedef std::map<htransition_t, transition_events_t> transitions_events_t;
92 
93  bool
94  set_state_event_about(event_kind_t, hstate_t);
95  bool
96  set_state_event_about(event_kind_t, hstate_t, hstate_t);
97  bool
98  set_state_event_about(event_kind_t, hstate_t, hstate_t, hstate_t);
99  const Event<hstate_t>
100  get_state_event_about(event_kind_t, hstate_t) const;
101 
102  bool
103  set_transition_event_about(event_kind_t, htransition_t);
104  bool
105  set_transition_event_about(event_kind_t, htransition_t, htransition_t);
106  bool
107  set_transition_event_about(event_kind_t, htransition_t, htransition_t,
108  htransition_t);
109  const Event<htransition_t>
110  get_transition_event_about(event_kind_t, htransition_t) const;
111 
112  bool
113  set_auto_event_about(event_kind_t);
114  bool
115  set_auto_event_about(event_kind_t, AutoType_);
116  bool
117  set_auto_event_about(event_kind_t, AutoType_, AutoType_);
118  const Event<AutoType_>
119  get_auto_event_about(event_kind_t) const;
120 
121  protected :
122  states_events_t states_events_;
123  transitions_events_t transitions_events_;
124  auto_events_t auto_events_;
125  };
126 
127  } // history
128 
129 } // vcsn
130 
131 
132 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
133 # include <vaucanson/automata/concept/history.hxx>
134 #endif // VCSN_USE_INTERFACE_ONLY
135 
136 
137 #endif // ! VCSN_AUTOMATA_CONCEPT_HISTORY_HH