Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_FUN_P2B_HAS_HH 00027 # define MLN_FUN_P2B_HAS_HH 00028 00032 00033 00034 # include <mln/core/concept/image.hh> 00035 # include <mln/core/concept/function.hh> 00036 # include <mln/metal/const.hh> 00037 # include <mln/metal/unconst.hh> 00038 00039 00040 namespace mln 00041 { 00042 00043 namespace fun 00044 { 00045 00046 namespace p2b 00047 { 00048 00049 // FIXME: Doc! 00050 00051 template <typename I> 00052 struct has 00053 00054 : public Function_v2b< has<I> >, 00055 private mlc_is_a(I, Image)::check_t 00056 { 00058 typedef bool result; 00059 00061 bool operator()(const mln_psite(I)& p) const; 00062 00063 00065 has(); 00066 00068 has(mlc_const(I)& ima); 00069 00070 00072 has(const has<I>& rhs); 00073 00075 has<I>& operator=(const has<I>& rhs); 00076 00077 private: 00078 mlc_const(I) ima_; 00079 typedef Function_v2b< has<I> > super_; 00080 }; 00081 00082 00083 # ifndef MLN_INCLUDE_ONLY 00084 00085 template <typename I> 00086 inline 00087 bool 00088 has<I>::operator()(const mln_psite(I)& p) const 00089 { 00090 return ima_.has(p); 00091 } 00092 00093 template <typename I> 00094 inline 00095 has<I>::has() 00096 : ima_() 00097 { 00098 } 00099 00100 template <typename I> 00101 inline 00102 has<I>::has(mlc_const(I)& ima) 00103 : ima_(ima) 00104 { 00105 } 00106 00107 template <typename I> 00108 inline 00109 has<I>::has(const has<I>& rhs) 00110 : Function_v2v< has<I> >(), // Please g++. 00111 super_(), 00112 ima_(rhs.ima_) 00113 { 00114 } 00115 00116 template <typename I> 00117 inline 00118 has<I>& 00119 has<I>::operator=(const has<I>& rhs) 00120 { 00121 if (&rhs == this) 00122 return *this; 00123 const_cast<mlc_unconst(I)&>(this->ima_) = rhs.ima_; 00124 return *this; 00125 } 00126 00127 # endif // ! MLN_INCLUDE_ONLY 00128 00129 } // end of namespace mln::fun::p2b 00130 00131 } // end of namespace mln::fun 00132 00133 } // end of namespace mln 00134 00135 00136 #endif // ! MLN_FUN_P2B_HAS_HH