00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
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 } 
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 } 
00086 
00087 #undef HOPERATOR
00088 #endif // ! VCSN_AUTOMATA_CONCEPT_HANDLERS_HXX