00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_MISC_USUAL_MACROS_HH
00019 # define VCSN_MISC_USUAL_MACROS_HH
00020
00021 # include <fstream>
00022 # include <vaucanson/config/system.hh>
00023 # include <boost/preprocessor/cat.hpp>
00024
00026 # define IMPORT_TYPEDEF_TYPENAME(From, Qual, Type, Typename) \
00027 typedef Typename From::Type Qual ## Type
00028
00029
00031 # define IMPORT_QUALIFIED_TYPEDEF(From, Qual, Type) \
00032 IMPORT_TYPEDEF_TYPENAME(From, Qual, Type,)
00033
00035 # define IMPORT_QUALIFIED_TYPEDEF_(From, Qual, Type) \
00036 IMPORT_TYPEDEF_TYPENAME(From, Qual, Type, typename)
00037
00038
00040 # define IMPORT_TYPEDEF_(From, Type) \
00041 IMPORT_QUALIFIED_TYPEDEF_(From, ,Type)
00042
00044 # define IMPORT_TYPEDEF(From, Type) \
00045 IMPORT_QUALIFIED_TYPEDEF(From, ,Type)
00046
00047
00048
00049
00050 # define AUTOMATON_TYPES_MAYBE_TYPENAME(AutoType, Prefix, Typename) \
00051 typedef AutoType Prefix##automaton_t; \
00052 typedef Typename AutoType::set_t Prefix##automata_set_t; \
00053 typedef Typename AutoType::states_t Prefix##states_t; \
00054 typedef Typename AutoType::state_iterator Prefix##state_iterator; \
00055 typedef Typename AutoType::transitions_t Prefix##transitions_t; \
00056 typedef Typename AutoType::transition_iterator Prefix##transition_iterator; \
00057 typedef Typename AutoType::initial_iterator Prefix##initial_iterator; \
00058 typedef Typename AutoType::final_iterator Prefix##final_iterator; \
00059 typedef Typename AutoType::monoid_t Prefix##monoid_t; \
00060 typedef Typename AutoType::monoid_elt_t Prefix##monoid_elt_t; \
00061 typedef Typename Prefix##monoid_elt_t::value_t Prefix##monoid_elt_value_t; \
00062 typedef Typename AutoType::semiring_t Prefix##semiring_t; \
00063 typedef Typename AutoType::series_set_t Prefix##series_set_t; \
00064 typedef Typename AutoType::series_set_elt_value_t Prefix##series_set_elt_value_t; \
00065 typedef Typename AutoType::series_set_elt_t Prefix##series_set_elt_t; \
00066 typedef Typename Prefix##series_set_elt_t::semiring_elt_t Prefix##semiring_elt_t; \
00067 typedef Typename Prefix##semiring_elt_t::value_t Prefix##semiring_elt_value_t; \
00068 typedef Typename AutoType::kind_t Prefix##kind_t; \
00069 typedef Typename AutoType::label_t Prefix##label_t; \
00070 typedef Typename AutoType::tag_t Prefix##tag_t; \
00071 typedef Typename AutoType::hstate_t Prefix##hstate_t; \
00072 typedef Typename AutoType::htransition_t Prefix##htransition_t; \
00073 typedef Typename AutoType::delta_state_iterator Prefix##delta_state_iterator; \
00074 typedef Typename AutoType::delta_transition_iterator Prefix##delta_transition_iterator; \
00075 typedef Typename AutoType::rdelta_state_iterator Prefix##rdelta_state_iterator; \
00076 typedef Typename AutoType::rdelta_transition_iterator Prefix##rdelta_transition_iterator; \
00077 typedef Typename AutoType::series_set_t::series_rep_t Prefix##series_rep_t; \
00078 typedef Typename AutoType::monoid_t::monoid_rep_t Prefix##monoid_rep_t;
00079
00080 # define AUTOMATON_TYPES_(AutoType,Prefix) \
00081 AUTOMATON_TYPES_MAYBE_TYPENAME(AutoType, Prefix, typename)
00082
00083 # define AUTOMATON_TYPES_EXACT_(AutoType,Prefix) \
00084 AUTOMATON_TYPES_MAYBE_TYPENAME(AutoType, Prefix, )
00085
00086 # define AUTOMATON_TYPES(AutoType) AUTOMATON_TYPES_(AutoType,)
00087 # define AUTOMATON_TYPES_EXACT(AutoType) AUTOMATON_TYPES_EXACT_(AutoType,)
00088
00089
00090
00091
00092
00093 # define AUTOMATON_FREEMONOID_TYPES_(Autotype, Prefix) \
00094 typedef typename Prefix##monoid_t::alphabets_elt_t Prefix##alphabets_elt_t; \
00095 typedef typename Prefix##monoid_t::alphabet_t Prefix##alphabet_t; \
00096 typedef typename Prefix##alphabet_t::const_iterator Prefix##alphabet_iterator; \
00097 typedef typename Prefix##alphabet_t::letter_t Prefix##letter_t;
00098
00099 # define AUTOMATON_FREEMONOID_TYPES_EXACT_(Autotype, Prefix) \
00100 typedef Prefix##monoid_t::alphabets_elt_t Prefix##alphabets_elt_t; \
00101 typedef Prefix##monoid_t::alphabet_t Prefix##alphabet_t; \
00102 typedef Prefix##alphabet_t::const_iterator Prefix##alphabet_iterator; \
00103 typedef Prefix##alphabet_t::letter_t Prefix##letter_t;
00104
00105
00106 # define AUTOMATON_FREEMONOID_TYPES(Autotype) \
00107 AUTOMATON_FREEMONOID_TYPES_(Autotype,)
00108 # define AUTOMATON_FREEMONOID_TYPES_EXACT(Autotype) \
00109 AUTOMATON_FREEMONOID_TYPES_EXACT_(Autotype,)
00110
00111
00112
00113 # define AUTOMATA_SET_TYPES(AutoSet) \
00114 typedef AutoSet automata_set_t; \
00115 typedef typename automata_set_t::series_set_t series_set_t; \
00116 typedef typename series_set_t::monoid_t monoid_t; \
00117 typedef typename series_set_t::semiring_t semiring_t; \
00118 typedef typename monoid_t::alphabet_t alphabet_t; \
00119 typedef typename alphabet_t::letter_t letter_t;
00120
00121
00122
00123
00124
00125
00126
00128 # define for_all_const_iterator(IteratorType, I, C) \
00129 for (IteratorType I = (C).begin(), I##_end = (C).end(); I##_end != I; ++I)
00130
00131 # define for_all_iterator(ConstIteratorType, I, C) \
00132 for (ConstIteratorType I = (C).begin(); I != (C).end(); ++I)
00133
00134
00136 # define for_all_const(T, I, C) \
00137 for_all_iterator(T::const_iterator, I, C)
00138
00139 # define for_all(T, I, C) \
00140 for_all_iterator(T::iterator, I, C)
00141
00142
00144 # define for_all_const_(T, I, C) \
00145 for_all_const_iterator(typename T::const_iterator, I, C)
00146
00147 # define for_all_(T, I, C) \
00148 for_all_iterator(typename T::iterator, I, C)
00149
00150
00151
00152
00153
00154 # define for_all_letters(I, A) \
00155 for_all_iterator (alphabet_iterator, I, A)
00156
00157 # define for_all_states(I, A) \
00158 for_all_iterator (state_iterator, I, (A).states())
00159
00160 # define for_all_transitions(I, A) \
00161 for_all_iterator (transition_iterator, I, (A).transitions())
00162
00163 # define for_all_initial_states(I, A) \
00164 for_all_iterator (initial_iterator, I, (A).initial())
00165
00166 # define for_all_final_states(I, A) \
00167 for_all_iterator (final_iterator, I, (A).final())
00168
00169 # define for_all_letters_(Prefix, I, A) \
00170 for_all_iterator (Prefix##alphabet_iterator, I, A)
00171
00172 # define for_all_states_(Prefix, I, A) \
00173 for_all_iterator (Prefix##state_iterator, I, (A).states())
00174
00175 # define for_all_transitions_(Prefix, I, A) \
00176 for_all_iterator (Prefix##transition_iterator, I, (A).transitions())
00177
00178 # define for_all_initial_states_(Prefix, I, A) \
00179 for_all_iterator (Prefix##initial_iterator, I, (A).initial())
00180
00181 # define for_all_final_states_(Prefix, I, A) \
00182 for_all_iterator (Prefix##final_iterator, I, (A).final())
00183
00184
00185
00186
00187
00188 # define for_all_const_letters(I, A) \
00189 for_all_const_iterator (alphabet_iterator, I, A)
00190
00191 # define for_all_const_states(I, A) \
00192 for_all_const_iterator (state_iterator, I, (A).states())
00193
00194 # define for_all_const_transitions(I, A) \
00195 for_all_const_iterator (transition_iterator, I, (A).transitions())
00196
00197 # define for_all_const_initial_states(I, A) \
00198 for_all_const_iterator (initial_iterator, I, (A).initial())
00199
00200 # define for_all_const_final_states(I, A) \
00201 for_all_const_iterator (final_iterator, I, (A).final())
00202
00203 # define for_all_const_letters_(Prefix, I, A) \
00204 for_all_const_iterator (Prefix##alphabet_iterator, I, A)
00205
00206 # define for_all_const_states_(Prefix, I, A) \
00207 for_all_const_iterator (Prefix##state_iterator, I, (A).states())
00208
00209 # define for_all_const_transitions_(Prefix, I, A) \
00210 for_all_const_iterator (Prefix##transition_iterator, I, (A).transitions())
00211
00212 # define for_all_const_initial_states_(Prefix, I, A) \
00213 for_all_const_iterator (Prefix##initial_iterator, I, (A).initial())
00214
00215 # define for_all_const_final_states_(Prefix, I, A) \
00216 for_all_const_iterator (Prefix##final_iterator, I, (A).final())
00217
00218
00219
00220 # define remove_in(S, V) \
00221 S.erase(std::remove(S.begin(), S.end(), V), S.end())
00222
00223 # define RAND___(Max) \
00224 ((unsigned) int(((float) rand() / (float) RAND_MAX) * Max));
00225
00226
00227 # ifndef VCSN_NDEBUG
00228 # define XML_FAIL(S) \
00229 do { \
00230 std::cerr << "Implement for " << typeid(S).name() << std::endl; \
00231 exit(1); \
00232 } while (0)
00233 # else
00234 # define XML_FAIL(S)
00235 # endif
00236 # define FAIL(S) { std::cerr << (S) << std::endl; exit(1); }
00237
00238
00239
00240
00241 # define zero_ zero(SELECT(typename series_set_elt_t::value_t))
00242 # define one_ identity(SELECT(typename series_set_elt_t::value_t))
00243 # define VCSN_EMPTY_ identity(SELECT(typename monoid_elt_t::value_t))
00244 # define wzero_ zero(SELECT(typename semiring_elt_t::value_t))
00245 # define wone_ identity(SELECT(typename semiring_elt_t::value_t))
00246
00247
00248 # define VARIANT_INCLUDE_FILE(PATH, FILE, SUFFIX) \
00249 <PATH/BOOST_PP_CAT(FILE, SUFFIX)>
00250
00251 # define GRAPH_IMPL_HEADER \
00252 VARIANT_INCLUDE_FILE(VCSN_GRAPH_IMPL_INCLUDE_PATH,VCSN_GRAPH_IMPL,_graph_impl.hh)
00253
00254 # define GRAPH_DEFAULT_IMPL_HEADER \
00255 VARIANT_INCLUDE_FILE(VCSN_GRAPH_IMPL_INCLUDE_PATH,VCSN_DEFAULT_GRAPH_IMPL,_graph_impl.hh)
00256
00257 # define GRAPH_CONTEXT_HEADER(Impl, Context) \
00258 VARIANT_INCLUDE_FILE(VCSN_CONTEXT_INCLUDE_PATH,Impl,/Context)
00259
00260 # define GRAPH_CONTEXT_HEADER_(Context) \
00261 <VCSN_CONTEXT_INCLUDE_PATH/VCSN_GRAPH_IMPL/Context>
00262
00263 # include <vaucanson/misc/global_timer.hh>
00264
00265 #endif // ! VCSN_MISC_USUAL_MACROS_HH