Vaucanson  1.4.1
slots.hxx
1 // slots.hxx: 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_SLOTS_HXX
18 # define VCSN_DESIGN_PATTERN_SLOTS_HXX
19 
21 # include <cstdlib>
22 # include <vaucanson/misc/unique.hh>
24 
25 namespace vcsn {
26 
27  /*------------------------------------------.
28  | SetSlotAttribute constructors and methods |
29  `------------------------------------------*/
30 
31  template<typename S, bool dynamic /* default: false */>
33  {}
34 
35  template<typename S, bool dynamic /* default: false */>
37  {}
38 
39  template<typename S, bool dynamic /* default: false */>
41  {}
42 
43  template<typename S, bool dynamic /* default: false */>
45  {
46  return *static_cast<const S*>(NULL);
47  }
48 
49  template<typename S, bool dynamic /* default: false */>
51  {}
52 
53  template<typename S, bool dynamic /* default: false */>
55  {}
56 
57  template<typename S, bool dynamic /* default: false */>
59  {
60  return true;
61  }
62 
63  /*--------------------------------------------------.
64  | Specialization when structural element is dynamic |
65  `--------------------------------------------------*/
66 
67  template <class S>
69  : s_(NULL)
70  {}
71 
72  template <class S>
74  : s_(other.s_)
75  {}
76 
77  template <class S>
79  : s_(& other ? & misc::unique::get(other) : NULL)
80  {}
81 
82  template <class S>
84  {
85  return *s_;
86  }
87 
88  template <class S>
90  {
91  s_ = other.s_;
92  }
93 
94  template <class S>
96  {
97  precondition(&s != NULL);
98  s_ = & misc::unique::get(s);
99  }
100 
101  template <class S>
103  {
104  return s_;
105  }
106 
107  /*---------------------.
108  | SetSlot constructors |
109  `---------------------*/
110 
111 
112  template <class S, class Tag>
114  : SetSlotAttribute<S, dynamic_traits<S>::ret>()
115  {}
116 
117  template <class S, class Tag>
119  : SetSlotAttribute<S, dynamic_traits<S>::ret>(other)
120  {}
121 
122  template <class S, class Tag>
123  SetSlot<S,Tag>::SetSlot(const S& other)
124  : SetSlotAttribute<S, dynamic_traits<S>::ret>(other)
125  {}
126 
127 
128 } // vcsn
129 
130 #endif // ! VCSN_DESIGN_PATTERN_SLOTS_HXX