00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX
00018 # define VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX
00019
00020 # include <vaucanson/misc/contract.hh>
00021 # include <vaucanson/automata/implementation/automaton_view.hh>
00022
00023 #define AutoType(Type) \
00024 typename Element<S, IdentityView<T> >::Type
00025
00026 namespace vcsn {
00027
00028 template <class T>
00029 IdentityView<T>::IdentityView():
00030 object_(0),
00031 const_object_(0)
00032 {}
00033
00034 template <class T>
00035 IdentityView<T>::IdentityView(T& d):
00036 object_(&d),
00037 const_object_(0)
00038 {}
00039
00040 template <class T>
00041 IdentityView<T>::IdentityView(const T& d):
00042 object_(0),
00043 const_object_(&d)
00044 {}
00045
00046 template <class T>
00047 IdentityView<T>::IdentityView(const IdentityView& d):
00048 object_(0)
00049 {
00050 assertion(d.object_ != 0 || d.const_object_ != 0);
00051 const_object_ = d.const_object_ == 0 ? d.object_ : d.const_object_;
00052 }
00053
00054 template <class T>
00055 const T&
00056 IdentityView<T>::object() const
00057 {
00058 assertion(object_ != 0 || const_object_ != 0);
00059 return const_object_ == 0 ? *object_ : *const_object_;
00060 }
00061
00062 template <class T>
00063 T&
00064 IdentityView<T>::object()
00065 {
00066 assertion(object_ != 0);
00067 assertion(const_object_ == 0);
00068 return *object_;
00069 }
00070
00071 template <class T>
00072 IdentityView<T>::operator T&()
00073 {
00074 assertion(object_ != 0);
00075 assertion(const_object_ == 0);
00076 return *object_;
00077 }
00078
00079 template <class T>
00080 IdentityView<T>::operator const T&() const
00081 {
00082 assertion(object_ != 0 || const_object_ != 0);
00083 return const_object_ == 0 ? *object_ : *const_object_;
00084 }
00085
00086 template <class S, class T>
00087 const typename automaton_traits<T>::tag_t&
00088 op_get_tag(const AutomataBase<S>& s, const IdentityView<T>& v)
00089 {
00090 return op_get_tag(s, v.object());
00091 }
00092
00093 template <class S, class T>
00094 typename automaton_traits<T>::tag_t&
00095 op_get_tag(const AutomataBase<S>& s, IdentityView<T>& v)
00096 {
00097 return op_get_tag(s, v.object());
00098 }
00099
00100 template <class S, class T>
00101 const typename automaton_traits<T>::geometry_t&
00102 op_get_geometry(const AutomataBase<S>& s, const IdentityView<T>& v)
00103 {
00104 return op_get_geometry(s, v.object());
00105 }
00106
00107 template <class S, class T>
00108 typename automaton_traits<T>::geometry_t&
00109 op_get_geometry(const AutomataBase<S>& s, IdentityView<T>& v)
00110 {
00111 return op_get_geometry(s, v.object());
00112 }
00113
00114 template <class S, class T>
00115 bool
00116 op_exists(const AutomataBase<S>& s, const IdentityView<T>& v)
00117 {
00118 return op_exists(s, v.object());
00119 }
00120
00121 template <class S, class T>
00122 typename automaton_traits<T>::states_t
00123 op_states(const AutomataBase<S>& s, const IdentityView<T>& v)
00124 {
00125 return op_states(s, v.object());
00126 }
00127
00128 template <class S, class T>
00129 typename automaton_traits<T>::transitions_t
00130 op_transitions(const AutomataBase<S>& s, const IdentityView<T>& v)
00131 {
00132 return op_transitions(s, v.object());
00133 }
00134
00135 template <class S, class T>
00136 typename automaton_traits<T>::initial_support_t
00137 op_initial(const AutomataBase<S>& s, const IdentityView<T>& v)
00138 {
00139 return op_initial(s, v.object());
00140 }
00141
00142 template <class S, class T>
00143 typename automaton_traits<T>::final_support_t
00144 op_final(const AutomataBase<S>& s, const IdentityView<T>& v)
00145 {
00146 return op_final(s, v.object());
00147 }
00148
00149 template <class S, class T>
00150 void
00151 op_set_initial(const AutomataBase<S>& ss, IdentityView<T>& v,
00152 const typename automaton_traits<T>::hstate_t& state,
00153 const AutoType(series_set_elt_t)& s)
00154 {
00155 return op_set_initial(ss, v.object(), state, s);
00156 }
00157
00158 template <class S, class T>
00159 AutoType(series_set_elt_t)
00160 op_get_initial(const AutomataBase<S>& s,
00161 const IdentityView<T>& v,
00162 const typename automaton_traits<T>::hstate_t& state)
00163 {
00164 return op_get_initial(s, v.object(), state);
00165 }
00166
00167 template <class S, class T>
00168 void
00169 op_set_final(const AutomataBase<S>& ss, IdentityView<T>& v,
00170 const typename automaton_traits<T>::hstate_t& state,
00171 const typename Element<S, T>::series_set_elt_t& s)
00172 {
00173 op_set_final(ss, v.object, state, s);
00174 }
00175
00176 template <class S, class T>
00177 typename Element<S, T>::series_set_elt_t
00178 op_get_final(const AutomataBase<S>& s,
00179 const IdentityView<T>& v,
00180 const typename automaton_traits<T>::hstate_t& state)
00181 {
00182 return op_get_final(s, v.object, state);
00183 }
00184
00185 template <class S, class T>
00186 void
00187 op_clear_initial(const AutomataBase<S>& s, IdentityView<T>& v)
00188 {
00189 op_clear_initial(s, v.object);
00190 }
00191
00192 template <class S, class T>
00193 void
00194 op_clear_final(const AutomataBase<S>& s, IdentityView<T>& v)
00195 {
00196 op_clear_final(s, v.object());
00197 }
00198
00199 template <class S, class T>
00200 typename automaton_traits<T>::hstate_t
00201 op_add_state(const AutomataBase<S>& s, IdentityView<T>& v)
00202 {
00203 return op_add_state(s, v.object());
00204 }
00205
00206 template <class S, class T>
00207 typename automaton_traits<T>::hstate_t
00208 op_choose_state(const AutomataBase<S>& s, IdentityView<T>& v)
00209 {
00210 return op_choose_state(s, v.object());
00211 }
00212
00213 template <class S, class T>
00214 typename automaton_traits<T>::htransition_t
00215 op_add_transition(const AutomataBase<S>& s, IdentityView<T>& v,
00216 const typename automaton_traits<T>::hstate_t& from,
00217 const typename automaton_traits<T>::hstate_t& to,
00218 const typename Element<S, T>::label_t& label)
00219 {
00220 return op_add_transition(s, v.object(), from, to, label);
00221 }
00222
00223 template <class S, class T>
00224 typename automaton_traits<T>::htransition_t
00225 op_add_series_transition(const AutomataBase<S>& s,
00226 IdentityView<T>& v,
00227 const typename automaton_traits<T>::hstate_t& from,
00228 const typename automaton_traits<T>::hstate_t& to,
00229 const typename Element<S, T>::series_set_elt_t& se)
00230 {
00231 return op_add_series_transition(s, v.object(), from, to, se);
00232 }
00233
00234 template <class S, class T>
00235 typename automaton_traits<T>::htransition_t
00236 op_add_spontaneous(const AutomataBase<S>& s, IdentityView<T>& v,
00237 const typename automaton_traits<T>::hstate_t& from,
00238 const typename automaton_traits<T>::hstate_t& to)
00239 {
00240 return op_add_spontaneous(s, v.object(), from, to);
00241 }
00242
00243 template <class S, class T>
00244 typename automaton_traits<T>::htransition_t
00245 op_add_letter_transition(const AutomataBase<S>& s, IdentityView<T>& v,
00246 const typename automaton_traits<T>::hstate_t& from,
00247 const typename automaton_traits<T>::hstate_t& to,
00248 const typename Element<S, T>::letter_t& e)
00249 {
00250 return op_add_letter_transition(s, v.object(), from, to, e);
00251 }
00252
00253 template <class S, class T>
00254 void
00255 op_update(const AutomataBase<S>& s, IdentityView<T>& v,
00256 const typename automaton_traits<T>::htransition_t& e,
00257 const AutoType(label_t)& l)
00258 {
00259 op_update(s, v.object(), e, l);
00260 }
00261
00262 template <class S, class T>
00263 void
00264 op_del_state(const AutomataBase<S>& s, IdentityView<T>& v,
00265 const typename automaton_traits<T>::hstate_t& st)
00266 {
00267 op_del_state(s, v.object(), st);
00268 }
00269
00270 template <class S, class T>
00271 void
00272 op_del_transition(const AutomataBase<S>& s, IdentityView<T>& v,
00273 const typename automaton_traits<T>::htransition_t& e)
00274 {
00275 op_del_transition(s, v.object(), e);
00276 }
00277
00278 template <class S, class T>
00279 bool
00280 op_has_state(const AutomataBase<S>& s,
00281 const IdentityView<T>& v,
00282 const typename automaton_traits<T>::hstate_t& st)
00283 {
00284 return op_has_state(s, v.object(), st);
00285 }
00286
00287 template <class S, class T>
00288 bool
00289 op_has_transition(const AutomataBase<S>& s,
00290 const IdentityView<T>& v,
00291 const typename automaton_traits<T>::htransition_t& e)
00292 {
00293 return op_has_transition(s, v.object(), e);
00294 }
00295
00296 template <class S, class T>
00297 typename automaton_traits<T>::hstate_t
00298 op_src_of(const AutomataBase<S>& s,
00299 const IdentityView<T>& v,
00300 const typename automaton_traits<T>::htransition_t& e)
00301 {
00302 return op_src_of(s, v.object(), e);
00303 }
00304
00305 template <class S, class T>
00306 typename automaton_traits<T>::hstate_t
00307 op_dst_of(const AutomataBase<S>& s,
00308 const IdentityView<T>& v,
00309 const typename automaton_traits<T>::htransition_t& e)
00310 {
00311 return op_dst_of(s, v.object(), e);
00312 }
00313
00314 template <class S, class T>
00315 typename Element<S, T>::label_t
00316 op_label_of(const AutomataBase<S>& s,
00317 const IdentityView<T>& v,
00318 const typename automaton_traits<T>::htransition_t& e)
00319 {
00320 return op_label_of(s, v.object(), e);
00321 }
00322
00323 template <class S, class T>
00324 const typename Element<S, T>::series_set_elt_t
00325 op_series_of(const AutomataBase<S>& s,
00326 const IdentityView<T>& v,
00327 const typename automaton_traits<T>::htransition_t& e)
00328 {
00329 return op_series_of(s, v.object(), e);
00330 }
00331
00332 template <class S, class T>
00333 typename Element<S, T>::series_set_elt_value_t
00334 op_series_value_of(const AutomataBase<S>& s,
00335 const IdentityView<T>& v,
00336 const typename automaton_traits<T>::htransition_t& e)
00337 {
00338 return op_series_value_of(s, v.object(), e);
00339 }
00340
00341 template <class S, class T>
00342 typename Element<S, T>::monoid_elt_t
00343 op_word_of(const AutomataBase<S>& s,
00344 const IdentityView<T>& v,
00345 const typename automaton_traits<T>::htransition_t& e)
00346 {
00347 return op_word_of(s, v.object(), e);
00348 }
00349
00350 template <class S, class T>
00351 typename Element<S, T>::monoid_elt_value_t
00352 op_word_value_of(const AutomataBase<S>& s,
00353 const IdentityView<T>& v,
00354 const typename automaton_traits<T>::htransition_t& e)
00355 {
00356 return op_word_value_of(s, v.object(), e);
00357 }
00358
00359 template <class S, class T>
00360 typename Element<S, T>::letter_t
00361 op_letter_of(const AutomataBase<S>& s,
00362 const IdentityView<T>& v,
00363 const typename automaton_traits<T>::htransition_t& e)
00364 {
00365 return op_letter_of(s, v.object(), e);
00366 }
00367
00368 template <class S, class T>
00369 bool
00370 op_is_spontaneous(const AutomataBase<S>& s,
00371 const IdentityView<T>& v,
00372 const typename automaton_traits<T>::htransition_t& e)
00373 {
00374 return op_is_spontaneous(s, v.object(), e);
00375 }
00376
00377 }
00378
00379 # undef AutoType
00380
00381 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX