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

- File List
- File Members

# handlers.hxx

    00001 // handlers.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_AUTOMATA_CONCEPT_HANDLERS_HXX
    00018 # define VCSN_AUTOMATA_CONCEPT_HANDLERS_HXX
    00019
    00020 # include <vaucanson/automata/concept/handlers.hh>
    00021
    00022 namespace vcsn
    00023 {
    00024
    00025   template<typename Tag, typename Type>
    00026   handler<Tag, Type>::handler() : v_(Type())
    00027   {}
    00028
    00029   template<typename Tag, typename Type>
    00030   handler<Tag, Type>::handler(const Type& h) : v_(h)
    00031   {}
    00032
    00033   template<typename Tag, typename Type>
    00034   handler<Tag, Type>::handler(const handler<Tag, Type>& h) : v_(h.v_)
    00035   {}
    00036
    00037   template<typename Tag, typename Type>
    00038   handler<Tag, Type>&
    00039   handler<Tag, Type>::operator=(const handler<Tag, Type>& h)
    00040   {
    00041     v_ = h.v_;
    00042     return *this;
    00043   }
    00044
    00045   template<typename Tag, typename Type>
    00046   Type handler<Tag, Type>::value() const
    00047   {
    00048     return v_;
    00049   }
    00050
    00051   template<typename Tag, typename Type>
    00052   bool
    00053   handler<Tag, Type>::is_valid() const
    00054   {
    00055     return v_ != Type();
    00056   }
    00057
    00058 } // vcsn
    00059
    00060 #define HOPERATOR(Op)                                   \
    00061 template<typename Tag, typename Type>                   \
    00062 bool operator Op (const handler<Tag, Type>& h1,         \
    00063                   const handler<Tag, Type>& h2)         \
    00064 { return h1.value() Op h2.value(); }
    00065
    00066 namespace vcsn {
    00067 HOPERATOR(==);
    00068 HOPERATOR(!=);
    00069 HOPERATOR(<);
    00070 HOPERATOR(>);
    00071 HOPERATOR(<=);
    00072 HOPERATOR(>=);
    00073 }
    00074
    00075 namespace std {
    00076
    00077   template <typename Tag, typename Type>
    00078   std::ostream&
    00079   operator<<(std::ostream& out, const vcsn::handler<Tag, Type>& h)
    00080   {
    00081     out << int(h);
    00082     return out;
    00083   }
    00084
    00085 } // std
    00086
    00087 #undef HOPERATOR
    00088 #endif // ! VCSN_AUTOMATA_CONCEPT_HANDLERS_HXX