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::label_t Prefix##label_t; \
00069 typedef Typename AutoType::tag_t Prefix##tag_t; \
00070 typedef Typename AutoType::hstate_t Prefix##hstate_t; \
00071 typedef Typename AutoType::htransition_t Prefix##htransition_t; \
00072 typedef Typename AutoType::delta_state_iterator Prefix##delta_state_iterator; \
00073 typedef Typename AutoType::delta_transition_iterator Prefix##delta_transition_iterator; \
00074 typedef Typename AutoType::rdelta_state_iterator Prefix##rdelta_state_iterator; \
00075 typedef Typename AutoType::rdelta_transition_iterator Prefix##rdelta_transition_iterator;
00076
00077 # define AUTOMATON_TYPES_(AutoType,Prefix) \
00078 AUTOMATON_TYPES_MAYBE_TYPENAME(AutoType, Prefix, typename)
00079
00080 # define AUTOMATON_TYPES_EXACT_(AutoType,Prefix) \
00081 AUTOMATON_TYPES_MAYBE_TYPENAME(AutoType, Prefix, )
00082
00083 # define AUTOMATON_TYPES(AutoType) AUTOMATON_TYPES_(AutoType,)
00084 # define AUTOMATON_TYPES_EXACT(AutoType) AUTOMATON_TYPES_EXACT_(AutoType,)
00085
00086
00087
00088
00089
00090 # define AUTOMATON_FREEMONOID_TYPES_(Autotype, Prefix) \
00091 typedef typename Prefix##monoid_t::alphabets_elt_t Prefix##alphabets_elt_t; \
00092 typedef typename Prefix##monoid_t::alphabet_t Prefix##alphabet_t; \
00093 typedef typename Prefix##alphabet_t::const_iterator Prefix##alphabet_iterator; \
00094 typedef typename Prefix##alphabet_t::letter_t Prefix##letter_t;
00095
00096 # define AUTOMATON_FREEMONOID_TYPES_EXACT_(Autotype, Prefix) \
00097 typedef Prefix##monoid_t::alphabets_elt_t Prefix##alphabets_elt_t; \
00098 typedef Prefix##monoid_t::alphabet_t Prefix##alphabet_t; \
00099 typedef Prefix##alphabet_t::const_iterator Prefix##alphabet_iterator; \
00100 typedef Prefix##alphabet_t::letter_t Prefix##letter_t;
00101
00102
00103 # define AUTOMATON_FREEMONOID_TYPES(Autotype) \
00104 AUTOMATON_FREEMONOID_TYPES_(Autotype,)
00105 # define AUTOMATON_FREEMONOID_TYPES_EXACT(Autotype) \
00106 AUTOMATON_FREEMONOID_TYPES_EXACT_(Autotype,)
00107
00108
00109
00110 # define AUTOMATA_SET_TYPES(AutoSet) \
00111 typedef AutoSet automata_set_t; \
00112 typedef typename automata_set_t::series_set_t series_set_t; \
00113 typedef typename series_set_t::monoid_t monoid_t; \
00114 typedef typename series_set_t::semiring_t semiring_t; \
00115 typedef typename monoid_t::alphabet_t alphabet_t; \
00116 typedef typename alphabet_t::letter_t letter_t;
00117
00118
00119
00120
00121
00122
00123
00125 # define for_all_const_iterator(IteratorType, I, C) \
00126 for (IteratorType I = (C).begin(), I##_end = (C).end(); I##_end != I; ++I)
00127
00128 # define for_all_iterator(ConstIteratorType, I, C) \
00129 for (ConstIteratorType I = (C).begin(); I != (C).end(); ++I)
00130
00131
00133 # define for_all_const(T, I, C) \
00134 for_all_iterator(T::const_iterator, I, C)
00135
00136 # define for_all(T, I, C) \
00137 for_all_iterator(T::iterator, I, C)
00138
00139
00141 # define for_all_const_(T, I, C) \
00142 for_all_const_iterator(typename T::const_iterator, I, C)
00143
00144 # define for_all_(T, I, C) \
00145 for_all_iterator(typename T::iterator, I, C)
00146
00147
00148
00149
00150
00151 # define for_all_letters(I, A) \
00152 for_all_iterator (alphabet_iterator, I, A)
00153
00154 # define for_all_states(I, A) \
00155 for_all_iterator (state_iterator, I, (A).states())
00156
00157 # define for_all_transitions(I, A) \
00158 for_all_iterator (transition_iterator, I, (A).transitions())
00159
00160 # define for_all_initial_states(I, A) \
00161 for_all_iterator (initial_iterator, I, (A).initial())
00162
00163 # define for_all_final_states(I, A) \
00164 for_all_iterator (final_iterator, I, (A).final())
00165
00166 # define for_all_letters_(Prefix, I, A) \
00167 for_all_iterator (Prefix##alphabet_iterator, I, A)
00168
00169 # define for_all_states_(Prefix, I, A) \
00170 for_all_iterator (Prefix##state_iterator, I, (A).states())
00171
00172 # define for_all_transitions_(Prefix, I, A) \
00173 for_all_iterator (Prefix##transition_iterator, I, (A).transitions())
00174
00175 # define for_all_initial_states_(Prefix, I, A) \
00176 for_all_iterator (Prefix##initial_iterator, I, (A).initial())
00177
00178 # define for_all_final_states_(Prefix, I, A) \
00179 for_all_iterator (Prefix##final_iterator, I, (A).final())
00180
00181
00182
00183
00184 # define for_all_const_letters(I, A) \
00185 for_all_const_iterator (alphabet_iterator, I, A)
00186
00187 # define for_all_const_states(I, A) \
00188 for_all_const_iterator (state_iterator, I, (A).states())
00189
00190 # define for_all_const_transitions(I, A) \
00191 for_all_const_iterator (transition_iterator, I, (A).transitions())
00192
00193 # define for_all_const_initial_states(I, A) \
00194 for_all_const_iterator (initial_iterator, I, (A).initial())
00195
00196 # define for_all_const_final_states(I, A) \
00197 for_all_const_iterator (final_iterator, I, (A).final())
00198
00199 # define for_all_const_letters_(Prefix, I, A) \
00200 for_all_const_iterator (Prefix##alphabet_iterator, I, A)
00201
00202 # define for_all_const_states_(Prefix, I, A) \
00203 for_all_const_iterator (Prefix##state_iterator, I, (A).states())
00204
00205 # define for_all_const_transitions_(Prefix, I, A) \
00206 for_all_const_iterator (Prefix##transition_iterator, I, (A).transitions())
00207
00208 # define for_all_const_initial_states_(Prefix, I, A) \
00209 for_all_const_iterator (Prefix##initial_iterator, I, (A).initial())
00210
00211 # define for_all_const_final_states_(Prefix, I, A) \
00212 for_all_const_iterator (Prefix##final_iterator, I, (A).final())
00213
00214
00215
00216 # define remove_in(S, V) \
00217 S.erase(std::remove(S.begin(), S.end(), V), S.end())
00218
00219 # define RAND___(Max) \
00220 ((unsigned) int(((float) rand() / (float) RAND_MAX) * Max));
00221
00222
00223 # ifndef VCSN_NDEBUG
00224 # define XML_FAIL(S) \
00225 do { \
00226 std::cerr << "Implement for " << typeid(S).name() << std::endl; \
00227 exit(1); \
00228 } while (0)
00229 # else
00230 # define XML_FAIL(S)
00231 # endif
00232 # define FAIL(S) { std::cerr << (S) << std::endl; exit(1); }
00233
00234
00235
00236
00237 # define zero_ zero(SELECT(typename series_set_elt_t::value_t))
00238 # define one_ identity(SELECT(typename series_set_elt_t::value_t))
00239 # define VCSN_EMPTY_ identity(SELECT(typename monoid_elt_t::value_t))
00240 # define wzero_ zero(SELECT(typename semiring_elt_t::value_t))
00241 # define wone_ identity(SELECT(typename semiring_elt_t::value_t))
00242
00243
00244 # define VARIANT_INCLUDE_FILE(PATH, FILE, SUFFIX) \
00245 <PATH/BOOST_PP_CAT(FILE, SUFFIX)>
00246
00247 # define GRAPH_IMPL_HEADER \
00248 VARIANT_INCLUDE_FILE(VCSN_GRAPH_IMPL_INCLUDE_PATH,VCSN_GRAPH_IMPL,_graph_impl.hh)
00249
00250 # define GRAPH_DEFAULT_IMPL_HEADER \
00251 VARIANT_INCLUDE_FILE(VCSN_GRAPH_IMPL_INCLUDE_PATH,VCSN_DEFAULT_GRAPH_IMPL,_graph_impl.hh)
00252
00253 # define GRAPH_CONTEXT_HEADER(Impl, Context) \
00254 VARIANT_INCLUDE_FILE(VCSN_CONTEXT_INCLUDE_PATH,Impl,/Context)
00255
00256 # define GRAPH_CONTEXT_HEADER_(Context) \
00257 <VCSN_CONTEXT_INCLUDE_PATH/VCSN_GRAPH_IMPL/Context>
00258
00259 # include <vaucanson/misc/global_timer.hh>
00260
00261 #endif // ! VCSN_MISC_USUAL_MACROS_HH