Vaucanson 1.4
|
00001 // element.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 The Vaucanson Group. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // The complete GNU General Public Licence Notice can be found as the 00013 // `COPYING' file in the root directory. 00014 // 00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 00016 // 00017 #ifndef VCSN_DESIGN_PATTERN_ELEMENT_HH 00018 # define VCSN_DESIGN_PATTERN_ELEMENT_HH 00019 00027 # include <vaucanson/design_pattern/predecls.hh> 00028 # include <vaucanson/design_pattern/meta_element_root.hh> 00029 # include <vaucanson/design_pattern/element_ops.hh> 00030 # include <vaucanson/design_pattern/default_ops.hh> 00031 # include <vaucanson/design_pattern/slots.hh> 00032 00033 namespace vcsn { 00034 00037 /*--------. 00038 | Element | 00039 `--------*/ 00040 00060 template<typename S, typename T> 00061 class Element : public MetaElement<S, T>, private SetSlot<S> 00062 { 00063 public: 00065 typedef S set_t; 00066 00068 typedef T value_t; 00069 00071 static const bool dynamic = dynamic_traits<S>::ret 00072 || MetaElement<S, T>::dynamic_value; 00073 00074 /*--------------------. 00075 | Default constructor | 00076 `--------------------*/ 00077 00088 Element(); 00089 00090 /*--------------------------. 00091 | Constructors from Element | 00092 `--------------------------*/ 00093 00095 Element(const Element& other); 00096 00098 template<typename U> 00099 Element(const Element<S, U>& other); 00100 00107 template<typename OtherS, typename U> 00108 Element(const Element<OtherS, U>& other); 00109 00110 /*-------------------------. 00111 | Constructors from values | 00112 `-------------------------*/ 00113 00115 00121 Element(const T& other); 00122 00123 template<typename U> 00124 Element(const U& other); 00126 00127 /*-------------------------------------------------. 00128 | Constructors from structural elements and values | 00129 `-------------------------------------------------*/ 00130 00137 explicit Element(const S& structure); 00138 00140 Element(const S& structure, const T& other); 00141 00143 template<typename U> Element(const S& structure, const U& other); 00144 00146 template<typename OtherS, typename U> 00147 Element(const S& structure, const Element<OtherS, U>& other); 00148 00149 /*-----------. 00150 | Assignment | 00151 `-----------*/ 00152 00154 Element& operator=(const Element& other); 00155 00157 template<typename U> 00158 Element& operator=(const Element<S, U>& other); 00159 00161 template<typename OtherS, typename U> 00162 Element& operator=(const Element<OtherS, U>& other); 00163 00165 template<typename U> 00166 Element& operator=(const U& other); 00167 00168 /*--------------------------. 00169 | Design pattern facilities | 00170 `--------------------------*/ 00171 00173 const S& structure() const; 00174 00176 void attach(const S& structure); 00177 00179 00180 T& value(); 00181 const T& value() const; 00183 00184 private : 00185 T value_; 00186 }; 00187 00190 } // vcsn 00191 00192 00193 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00194 # include <vaucanson/design_pattern/element.hxx> 00195 # endif // VCSN_USE_INTERFACE_ONLY 00196 00197 #endif // ! VCSN_DESIGN_PATTERN_ELEMENT_HH