Vaucanson  1.4.1
element.hh
Go to the documentation of this file.
1 // element.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_DESIGN_PATTERN_ELEMENT_HH
18 # define VCSN_DESIGN_PATTERN_ELEMENT_HH
19 
32 
33 namespace vcsn {
34 
37  /*--------.
38  | Element |
39  `--------*/
40 
60  template<typename S, typename T>
61  class Element : public MetaElement<S, T>, private SetSlot<S>
62  {
63  public:
65  typedef S set_t;
66 
68  typedef T value_t;
69 
71  static const bool dynamic = dynamic_traits<S>::ret
73 
74  /*--------------------.
75  | Default constructor |
76  `--------------------*/
77 
88  Element();
89 
90  /*--------------------------.
91  | Constructors from Element |
92  `--------------------------*/
93 
95  Element(const Element& other);
96 
98  template<typename U>
99  Element(const Element<S, U>& other);
100 
107  template<typename OtherS, typename U>
108  Element(const Element<OtherS, U>& other);
109 
110  /*-------------------------.
111  | Constructors from values |
112  `-------------------------*/
113 
115 
121  Element(const T& other);
122 
123  template<typename U>
124  Element(const U& other);
126 
127  /*-------------------------------------------------.
128  | Constructors from structural elements and values |
129  `-------------------------------------------------*/
130 
137  explicit Element(const S& structure);
138 
140  Element(const S& structure, const T& other);
141 
143  template<typename U> Element(const S& structure, const U& other);
144 
146  template<typename OtherS, typename U>
147  Element(const S& structure, const Element<OtherS, U>& other);
148 
149  /*-----------.
150  | Assignment |
151  `-----------*/
152 
154  Element& operator=(const Element& other);
155 
157  template<typename U>
158  Element& operator=(const Element<S, U>& other);
159 
161  template<typename OtherS, typename U>
162  Element& operator=(const Element<OtherS, U>& other);
163 
165  template<typename U>
166  Element& operator=(const U& other);
167 
168  /*--------------------------.
169  | Design pattern facilities |
170  `--------------------------*/
171 
173  const S& structure() const;
174 
176  void attach(const S& structure);
177 
179 
180  T& value();
181  const T& value() const;
183 
184  private :
185  T value_;
186  };
187 
190 } // vcsn
191 
192 
193 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
194 # include <vaucanson/design_pattern/element.hxx>
195 # endif // VCSN_USE_INTERFACE_ONLY
196 
197 #endif // ! VCSN_DESIGN_PATTERN_ELEMENT_HH