Vaucanson 1.4
|
00001 // monoid_base.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, 2007, 2010 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_ALGEBRA_CONCEPT_MONOID_BASE_HXX 00018 # define VCSN_ALGEBRA_CONCEPT_MONOID_BASE_HXX 00019 00020 # include <vaucanson/algebra/concept/monoid_base.hh> 00021 # include <vaucanson/algebra/concept/semigroup_base.hh> 00022 00023 namespace vcsn { 00024 00025 namespace algebra { 00026 00027 /*-----------------. 00028 | MonoidBase<Self> | 00029 `-----------------*/ 00030 template<class Self> 00031 template<typename T> 00032 Element<Self, T> 00033 MonoidBase<Self>::identity(SELECTOR(T)) const 00034 { 00035 return Element<Self, T>(this->self(), 00036 identity_value(SELECT(Self), SELECT(T))); 00037 } 00038 00039 template<class Self> 00040 template<typename T> 00041 Element<Self, T> MonoidBase<Self>::zero(SELECTOR(T)) const 00042 { 00043 return Element<Self, T>(this->self(), 00044 zero_value(SELECT(Self), SELECT(T))); 00045 } 00046 00047 template <class Self> 00048 MonoidBase<Self>::MonoidBase() 00049 {} 00050 00051 template <class Self> 00052 MonoidBase<Self>::MonoidBase(const MonoidBase& other) : 00053 SemigroupBase<Self>(other) 00054 {} 00055 00056 template <class T> 00057 template <class S> 00058 Element<S, T> 00059 identity_as<T>::of(const S& s) 00060 { 00061 return s.identity(SELECT(T)); 00062 } 00063 00064 template <class T> 00065 template <class S> 00066 Element<S, T> 00067 zero_as<T>::of(const S& s) 00068 { 00069 return s.zero(SELECT(T)); 00070 } 00071 00072 } // algebra 00073 00074 /*---------------------------------. 00075 | MetaElement<MonoidBase<Self>, T> | 00076 `---------------------------------*/ 00077 00078 template<class Self, typename T> 00079 MetaElement<algebra::MonoidBase<Self>, T>::MetaElement() 00080 {} 00081 00082 template<class Self, typename T> 00083 MetaElement<algebra::MonoidBase<Self>, T>::MetaElement(const MetaElement& other) : 00084 MetaElement<algebra::SemigroupBase<Self>, T>(other) 00085 {} 00086 00087 namespace algebra { 00088 00089 template<typename T, typename Self> 00090 T 00091 op_default(SELECTOR(algebra::MonoidBase<Self>), SELECTOR(T)) 00092 { 00093 // By default, an element of a monoid is the identity. 00094 return identity_value(SELECT(Self), SELECT(T)); 00095 } 00096 00097 } // algebra 00098 00099 } // vcsn 00100 00101 #endif // ! VCSN_ALGEBRA_CONCEPT_MONOID_BASE_HXX