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