Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 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_WIN_INTER_HH 00027 # define MLN_WIN_INTER_HH 00028 00032 00033 # include <mln/core/window.hh> 00034 00035 00036 00037 namespace mln 00038 { 00039 00041 template <typename W1, typename W2> 00042 mln_regular(W1) 00043 operator && (const Window<W1>& win1, const Window<W2>& win2); 00044 00045 00046 # ifndef MLN_INCLUDE_ONLY 00047 00048 namespace win 00049 { 00050 00051 namespace impl 00052 { 00053 00054 template <typename W1, typename W2> 00055 inline 00056 mln_regular(W1) 00057 inter(trait::window::definition::unique, 00058 const W1& win1, const W2& win2) 00059 { 00060 mlc_is(mln_trait_window_size(W1), 00061 trait::window::size::fixed)::check(); 00062 mlc_is(mln_trait_window_size(W2), 00063 trait::window::size::fixed)::check(); 00064 00065 mln_regular(W1) tmp; 00066 unsigned n = win1.size(); 00067 for (unsigned i = 0; i < n; ++i) 00068 if (win2.has(win1.dp(i))) 00069 tmp.insert(win1.dp(i)); 00070 return tmp; 00071 } 00072 00073 template <typename W1, typename W2> 00074 inline 00075 mln_regular(W1) 00076 inter(trait::window::definition::multiple, 00077 const W1& win1, const W2& win2) 00078 { 00079 mln_precondition(win1.nwindows() == win2.nwindows()); 00080 // FIXME: What about "win1.function() not equal win2.function()"! 00081 00082 mln_regular(W1) tmp(win1.function()); 00083 const unsigned nw = win1.nwindows(); 00084 for (unsigned w = 0; w < nw; ++w) 00085 tmp.set_window(w, win1.window(w) && win2.window(w)); 00086 return tmp; 00087 } 00088 00089 } // end of namespace mln::win::impl 00090 00091 } // end of namespace mln::win 00092 00093 00094 // Facade. 00095 template <typename W1, typename W2> 00096 inline 00097 mln_regular(W1) 00098 operator && (const Window<W1>& win1, const Window<W2>& win2) 00099 { 00100 trace::entering("win::inter"); 00101 00102 // Compatibility checks. 00103 mlc_equal(mln_regular(W1), mln_regular(W2))::check(); 00104 mlc_converts_to(mln_dpsite(W1), mln_dpsite(W2))::check(); 00105 00106 // Support checks. 00107 mlc_is(mln_trait_window_support(W1), 00108 trait::window::support::regular)::check(); 00109 mlc_is(mln_trait_window_support(W2), 00110 trait::window::support::regular)::check(); 00111 00112 // Definition checks. 00113 mlc_equal(mln_trait_window_definition(W1), 00114 mln_trait_window_definition(W2))::check(); 00115 00116 mlc_is_not(mln_trait_window_definition(W1), 00117 trait::window::definition::varying)::check(); 00118 00119 mln_regular(W1) tmp = win::impl::inter(mln_trait_window_definition(W1)(), 00120 exact(win1), exact(win2)); 00121 00122 trace::exiting("win::inter"); 00123 return tmp; 00124 } 00125 00126 # endif // ! MLN_INCLUDE_ONLY 00127 00128 } // end of namespace mln 00129 00130 00131 #endif // ! MLN_WIN_INTER_HH