Vaucanson  1.4.1
automaton_view.hxx
1 // automaton_view.hxx: 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_IMPLEMENTATION_AUTOMATON_VIEW_HXX
18 # define VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX
19 
21 # include <vaucanson/automata/implementation/automaton_view.hh>
22 
23 #define AutoType(Type) \
24  typename Element<S, IdentityView<T> >::Type
25 
26 namespace vcsn {
27 
28  template <class T>
29  IdentityView<T>::IdentityView():
30  object_(0),
31  const_object_(0)
32  {}
33 
34  template <class T>
35  IdentityView<T>::IdentityView(T& d):
36  object_(&d),
37  const_object_(0)
38  {}
39 
40  template <class T>
41  IdentityView<T>::IdentityView(const T& d):
42  object_(0),
43  const_object_(&d)
44  {}
45 
46  template <class T>
47  IdentityView<T>::IdentityView(const IdentityView& d):
48  object_(0)
49  {
50  assertion(d.object_ != 0 || d.const_object_ != 0);
51  const_object_ = d.const_object_ == 0 ? d.object_ : d.const_object_;
52  }
53 
54  template <class T>
55  const T&
56  IdentityView<T>::object() const
57  {
58  assertion(object_ != 0 || const_object_ != 0);
59  return const_object_ == 0 ? *object_ : *const_object_;
60  }
61 
62  template <class T>
63  T&
64  IdentityView<T>::object()
65  {
66  assertion(object_ != 0);
67  assertion(const_object_ == 0);
68  return *object_;
69  }
70 
71  template <class T>
72  IdentityView<T>::operator T&()
73  {
74  assertion(object_ != 0);
75  assertion(const_object_ == 0);
76  return *object_;
77  }
78 
79  template <class T>
80  IdentityView<T>::operator const T&() const
81  {
82  assertion(object_ != 0 || const_object_ != 0);
83  return const_object_ == 0 ? *object_ : *const_object_;
84  }
85 
86  template <class S, class T>
87  const typename automaton_traits<T>::tag_t&
88  op_get_tag(const AutomataBase<S>& s, const IdentityView<T>& v)
89  {
90  return op_get_tag(s, v.object());
91  }
92 
93  template <class S, class T>
94  typename automaton_traits<T>::tag_t&
95  op_get_tag(const AutomataBase<S>& s, IdentityView<T>& v)
96  {
97  return op_get_tag(s, v.object());
98  }
99 
100  template <class S, class T>
101  const typename automaton_traits<T>::geometry_t&
102  op_get_geometry(const AutomataBase<S>& s, const IdentityView<T>& v)
103  {
104  return op_get_geometry(s, v.object());
105  }
106 
107  template <class S, class T>
108  typename automaton_traits<T>::geometry_t&
109  op_get_geometry(const AutomataBase<S>& s, IdentityView<T>& v)
110  {
111  return op_get_geometry(s, v.object());
112  }
113 
114  template <class S, class T>
115  bool
116  op_exists(const AutomataBase<S>& s, const IdentityView<T>& v)
117  {
118  return op_exists(s, v.object());
119  }
120 
121  template <class S, class T>
122  typename automaton_traits<T>::states_t
123  op_states(const AutomataBase<S>& s, const IdentityView<T>& v)
124  {
125  return op_states(s, v.object());
126  }
127 
128  template <class S, class T>
129  typename automaton_traits<T>::transitions_t
130  op_transitions(const AutomataBase<S>& s, const IdentityView<T>& v)
131  {
132  return op_transitions(s, v.object());
133  }
134 
135  template <class S, class T>
136  typename automaton_traits<T>::initial_support_t
137  op_initial(const AutomataBase<S>& s, const IdentityView<T>& v)
138  {
139  return op_initial(s, v.object());
140  }
141 
142  template <class S, class T>
143  typename automaton_traits<T>::final_support_t
144  op_final(const AutomataBase<S>& s, const IdentityView<T>& v)
145  {
146  return op_final(s, v.object());
147  }
148 
149  template <class S, class T>
150  void
151  op_set_initial(const AutomataBase<S>& ss, IdentityView<T>& v,
152  const typename automaton_traits<T>::hstate_t& state,
153  const AutoType(series_set_elt_t)& s)
154  {
155  return op_set_initial(ss, v.object(), state, s);
156  }
157 
158  template <class S, class T>
159  AutoType(series_set_elt_t)
160  op_get_initial(const AutomataBase<S>& s,
161  const IdentityView<T>& v,
162  const typename automaton_traits<T>::hstate_t& state)
163  {
164  return op_get_initial(s, v.object(), state);
165  }
166 
167  template <class S, class T>
168  void
169  op_set_final(const AutomataBase<S>& ss, IdentityView<T>& v,
170  const typename automaton_traits<T>::hstate_t& state,
171  const typename Element<S, T>::series_set_elt_t& s)
172  {
173  op_set_final(ss, v.object, state, s);
174  }
175 
176  template <class S, class T>
177  typename Element<S, T>::series_set_elt_t
178  op_get_final(const AutomataBase<S>& s,
179  const IdentityView<T>& v,
180  const typename automaton_traits<T>::hstate_t& state)
181  {
182  return op_get_final(s, v.object, state);
183  }
184 
185  template <class S, class T>
186  void
187  op_clear_initial(const AutomataBase<S>& s, IdentityView<T>& v)
188  {
189  op_clear_initial(s, v.object);
190  }
191 
192  template <class S, class T>
193  void
194  op_clear_final(const AutomataBase<S>& s, IdentityView<T>& v)
195  {
196  op_clear_final(s, v.object());
197  }
198 
199  template <class S, class T>
200  typename automaton_traits<T>::hstate_t
201  op_add_state(const AutomataBase<S>& s, IdentityView<T>& v)
202  {
203  return op_add_state(s, v.object());
204  }
205 
206  template <class S, class T>
207  typename automaton_traits<T>::hstate_t
208  op_choose_state(const AutomataBase<S>& s, IdentityView<T>& v)
209  {
210  return op_choose_state(s, v.object());
211  }
212 
213  template <class S, class T>
214  typename automaton_traits<T>::htransition_t
215  op_add_transition(const AutomataBase<S>& s, IdentityView<T>& v,
216  const typename automaton_traits<T>::hstate_t& from,
217  const typename automaton_traits<T>::hstate_t& to,
218  const typename Element<S, T>::label_t& label)
219  {
220  return op_add_transition(s, v.object(), from, to, label);
221  }
222 
223  template <class S, class T>
224  typename automaton_traits<T>::htransition_t
225  op_add_series_transition(const AutomataBase<S>& s,
226  IdentityView<T>& v,
227  const typename automaton_traits<T>::hstate_t& from,
228  const typename automaton_traits<T>::hstate_t& to,
229  const typename Element<S, T>::series_set_elt_t& se)
230  {
231  return op_add_series_transition(s, v.object(), from, to, se);
232  }
233 
234  template <class S, class T>
235  typename automaton_traits<T>::htransition_t
236  op_add_spontaneous(const AutomataBase<S>& s, IdentityView<T>& v,
237  const typename automaton_traits<T>::hstate_t& from,
238  const typename automaton_traits<T>::hstate_t& to)
239  {
240  return op_add_spontaneous(s, v.object(), from, to);
241  }
242 
243  template <class S, class T>
244  typename automaton_traits<T>::htransition_t
245  op_add_letter_transition(const AutomataBase<S>& s, IdentityView<T>& v,
246  const typename automaton_traits<T>::hstate_t& from,
247  const typename automaton_traits<T>::hstate_t& to,
248  const typename Element<S, T>::letter_t& e)
249  {
250  return op_add_letter_transition(s, v.object(), from, to, e);
251  }
252 
253  template <class S, class T>
254  void
255  op_update(const AutomataBase<S>& s, IdentityView<T>& v,
256  const typename automaton_traits<T>::htransition_t& e,
257  const AutoType(label_t)& l)
258  {
259  op_update(s, v.object(), e, l);
260  }
261 
262  template <class S, class T>
263  void
264  op_del_state(const AutomataBase<S>& s, IdentityView<T>& v,
265  const typename automaton_traits<T>::hstate_t& st)
266  {
267  op_del_state(s, v.object(), st);
268  }
269 
270  template <class S, class T>
271  void
272  op_del_transition(const AutomataBase<S>& s, IdentityView<T>& v,
273  const typename automaton_traits<T>::htransition_t& e)
274  {
275  op_del_transition(s, v.object(), e);
276  }
277 
278  template <class S, class T>
279  bool
280  op_has_state(const AutomataBase<S>& s,
281  const IdentityView<T>& v,
282  const typename automaton_traits<T>::hstate_t& st)
283  {
284  return op_has_state(s, v.object(), st);
285  }
286 
287  template <class S, class T>
288  bool
289  op_has_transition(const AutomataBase<S>& s,
290  const IdentityView<T>& v,
291  const typename automaton_traits<T>::htransition_t& e)
292  {
293  return op_has_transition(s, v.object(), e);
294  }
295 
296  template <class S, class T>
297  typename automaton_traits<T>::hstate_t
298  op_src_of(const AutomataBase<S>& s,
299  const IdentityView<T>& v,
300  const typename automaton_traits<T>::htransition_t& e)
301  {
302  return op_src_of(s, v.object(), e);
303  }
304 
305  template <class S, class T>
306  typename automaton_traits<T>::hstate_t
307  op_dst_of(const AutomataBase<S>& s,
308  const IdentityView<T>& v,
309  const typename automaton_traits<T>::htransition_t& e)
310  {
311  return op_dst_of(s, v.object(), e);
312  }
313 
314  template <class S, class T>
315  typename Element<S, T>::label_t
316  op_label_of(const AutomataBase<S>& s,
317  const IdentityView<T>& v,
318  const typename automaton_traits<T>::htransition_t& e)
319  {
320  return op_label_of(s, v.object(), e);
321  }
322 
323  template <class S, class T>
324  const typename Element<S, T>::series_set_elt_t
325  op_series_of(const AutomataBase<S>& s,
326  const IdentityView<T>& v,
327  const typename automaton_traits<T>::htransition_t& e)
328  {
329  return op_series_of(s, v.object(), e);
330  }
331 
332  template <class S, class T>
333  typename Element<S, T>::series_set_elt_value_t
334  op_series_value_of(const AutomataBase<S>& s,
335  const IdentityView<T>& v,
336  const typename automaton_traits<T>::htransition_t& e)
337  {
338  return op_series_value_of(s, v.object(), e);
339  }
340 
341  template <class S, class T>
342  typename Element<S, T>::monoid_elt_t
343  op_word_of(const AutomataBase<S>& s,
344  const IdentityView<T>& v,
345  const typename automaton_traits<T>::htransition_t& e)
346  {
347  return op_word_of(s, v.object(), e);
348  }
349 
350  template <class S, class T>
351  typename Element<S, T>::monoid_elt_value_t
352  op_word_value_of(const AutomataBase<S>& s,
353  const IdentityView<T>& v,
354  const typename automaton_traits<T>::htransition_t& e)
355  {
356  return op_word_value_of(s, v.object(), e);
357  }
358 
359  template <class S, class T>
360  typename Element<S, T>::letter_t
361  op_letter_of(const AutomataBase<S>& s,
362  const IdentityView<T>& v,
363  const typename automaton_traits<T>::htransition_t& e)
364  {
365  return op_letter_of(s, v.object(), e);
366  }
367 
368  template <class S, class T>
369  bool
370  op_is_spontaneous(const AutomataBase<S>& s,
371  const IdentityView<T>& v,
372  const typename automaton_traits<T>::htransition_t& e)
373  {
374  return op_is_spontaneous(s, v.object(), e);
375  }
376 
377 } // vcsn
378 
379 # undef AutoType
380 
381 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX