- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# slots.hxx

    00001 // slots.hxx: 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_SLOTS_HXX
    00018 # define VCSN_DESIGN_PATTERN_SLOTS_HXX
    00019
    00020 # include <vaucanson/design_pattern/slots.hh>
    00021 # include <cstdlib>
    00022 # include <vaucanson/misc/unique.hh>
    00023 # include <vaucanson/misc/contract.hh>
    00024
    00025 namespace vcsn {
    00026
    00027   /*------------------------------------------.
    00028   | SetSlotAttribute constructors and methods |
    00029   `------------------------------------------*/
    00030
    00031   template<typename S, bool dynamic /* default: false */>
    00032   SetSlotAttribute<S, dynamic>::SetSlotAttribute()
    00033   {}
    00034
    00035   template<typename S, bool dynamic /* default: false */>
    00036   SetSlotAttribute<S, dynamic>::SetSlotAttribute(const SetSlotAttribute&)
    00037   {}
    00038
    00039   template<typename S, bool dynamic /* default: false */>
    00040   SetSlotAttribute<S, dynamic>::SetSlotAttribute(const S&)
    00041   {}
    00042
    00043   template<typename S, bool dynamic /* default: false */>
    00044   const S& SetSlotAttribute<S, dynamic>::_structure_get() const
    00045   {
    00046     return *static_cast<const S*>(NULL);
    00047   }
    00048
    00049   template<typename S, bool dynamic /* default: false */>
    00050   void SetSlotAttribute<S, dynamic>::_structure_assign(const SetSlotAttribute&)
    00051   {}
    00052
    00053   template<typename S, bool dynamic /* default: false */>
    00054   void SetSlotAttribute<S, dynamic>::_structure_attach(const S& )
    00055   {}
    00056
    00057   template<typename S, bool dynamic /* default: false */>
    00058   bool SetSlotAttribute<S, dynamic>::_structure_bound() const
    00059   {
    00060     return true;
    00061   }
    00062
    00063   /*--------------------------------------------------.
    00064   | Specialization when structural element is dynamic |
    00065   `--------------------------------------------------*/
    00066
    00067   template <class S>
    00068   SetSlotAttribute<S, true>::SetSlotAttribute()
    00069     : s_(NULL)
    00070   {}
    00071
    00072   template <class S>
    00073   SetSlotAttribute<S, true>::SetSlotAttribute(const SetSlotAttribute& other)
    00074     : s_(other.s_)
    00075   {}
    00076
    00077   template <class S>
    00078   SetSlotAttribute<S, true>::SetSlotAttribute(const S& other)
    00079     : s_(& other ? & misc::unique::get(other) : NULL)
    00080   {}
    00081
    00082   template <class S>
    00083   const S& SetSlotAttribute<S, true>::_structure_get() const
    00084   {
    00085     return *s_;
    00086   }
    00087
    00088   template <class S>
    00089   void SetSlotAttribute<S, true>::_structure_assign(const SetSlotAttribute& other)
    00090   {
    00091     s_ = other.s_;
    00092   }
    00093
    00094   template <class S>
    00095   void SetSlotAttribute<S, true>::_structure_attach(const S& s)
    00096   {
    00097     precondition(&s != NULL);
    00098     s_ = & misc::unique::get(s);
    00099   }
    00100
    00101   template <class S>
    00102   bool SetSlotAttribute<S, true>::_structure_bound() const
    00103   {
    00104     return s_;
    00105   }
    00106
    00107   /*---------------------.
    00108   | SetSlot constructors |
    00109   `---------------------*/
    00110
    00111
    00112   template <class S, class Tag>
    00113   SetSlot<S,Tag>::SetSlot()
    00114     : SetSlotAttribute<S, dynamic_traits<S>::ret>()
    00115   {}
    00116
    00117   template <class S, class Tag>
    00118   SetSlot<S,Tag>::SetSlot(const SetSlot& other)
    00119     : SetSlotAttribute<S, dynamic_traits<S>::ret>(other)
    00120   {}
    00121
    00122   template <class S, class Tag>
    00123   SetSlot<S,Tag>::SetSlot(const S& other)
    00124     : SetSlotAttribute<S, dynamic_traits<S>::ret>(other)
    00125   {}
    00126
    00127
    00128 } // vcsn
    00129
    00130 #endif // ! VCSN_DESIGN_PATTERN_SLOTS_HXX