00001 // letter.hh: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The 00006 // Vaucanson Group. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation; either version 2 00011 // of the License, or (at your option) any later version. 00012 // 00013 // The complete GNU General Public Licence Notice can be found as the 00014 // `COPYING' file in the root directory. 00015 // 00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 00017 // 00018 #ifndef VCSN_ALGEBRA_CONCEPT_LETTER_HH 00019 # define VCSN_ALGEBRA_CONCEPT_LETTER_HH 00020 00021 # include <string> 00022 # include <vector> 00023 00024 # include <vaucanson/design_pattern/predecls.hh> 00025 # include <vaucanson/misc/static.hh> 00026 00027 namespace vcsn { 00028 00029 namespace algebra { 00030 00031 template <class L> 00032 struct letter_traits 00033 { 00034 // When we do not know the type we assume false. 00035 typedef misc::false_t is_char_letter; 00036 00037 // Default value 00038 enum 00039 { 00040 cardinal = misc::static_pow<2, sizeof(L) * 8>::value 00041 }; 00042 00045 00047 // FIXME: we must add traits to monoids to handle this better 00048 static std::string kind(); 00049 static int dim(); 00050 00052 typedef undefined_type first_projection_t; 00053 00055 typedef undefined_type second_projection_t; 00056 00059 static L literal_to_letter(const std::string&); 00060 00062 static std::string letter_to_literal(const L&); 00063 00064 # define DECLARE_DEFAULT(name) \ 00065 static const std::string default_##name (); 00066 00068 DECLARE_DEFAULT(open_par) 00069 00070 00071 DECLARE_DEFAULT(close_par) 00072 00074 DECLARE_DEFAULT(plus) 00075 00077 DECLARE_DEFAULT(times) 00078 00080 DECLARE_DEFAULT(star) 00081 00083 DECLARE_DEFAULT(epsilon) 00084 00086 DECLARE_DEFAULT(zero) 00087 00089 DECLARE_DEFAULT(open_weight) 00090 00092 DECLARE_DEFAULT(close_weight) 00093 00095 DECLARE_DEFAULT(space) 00096 00097 # undef DECLARE_DEFAULT 00098 00099 }; 00100 00101 template <typename L> 00102 struct token_representation 00103 { 00104 std::string open_par; 00105 std::string close_par; 00106 std::string plus; 00107 std::string times; 00108 std::string star; 00109 std::string one; 00110 std::string zero; 00111 std::string open_weight; 00112 std::string close_weight; 00113 std::vector<std::string> spaces; 00114 00115 // Default CTOR. 00116 token_representation(); 00117 00118 // Convertion CTOR. 00119 template <typename U> 00120 token_representation(const token_representation<U>& arg); 00121 00122 }; 00123 00124 // generic interface to overwrite static defaults 00125 typedef token_representation<misc::true_t> token_representation_t; 00126 00127 # define LETTER_DEFAULT(name, value) \ 00128 static std::string default_##name () { return value; } 00129 00130 } // ! algebra 00131 00132 } // ! vcsn 00133 00134 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00135 # include <vaucanson/algebra/concept/letter.hxx> 00136 # endif // ! VCSN_USE_INTERFACE_ONLY 00137 00138 #endif // ! VCSN_ALGEBRA_CONCEPT_LETTER_HH