• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

lor_basic.hh

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_ACCU_LOGIC_LOR_BASIC_HH
00027 # define MLN_ACCU_LOGIC_LOR_BASIC_HH
00028 
00034 
00035 # include <mln/core/concept/meta_accumulator.hh>
00036 # include <mln/accu/internal/base.hh>
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace accu
00043   {
00044 
00045     namespace logic
00046     {
00047       // Forward declaration.
00048       struct lor_basic;
00049     }
00050 
00051     namespace meta
00052     {
00053 
00054       namespace logic
00055       {
00057         struct lor_basic : public Meta_Accumulator< lor_basic >
00058         {
00059           template <typename T>
00060           struct with
00061           {
00062             typedef accu::logic::lor_basic ret;
00063           };
00064         };
00065 
00066       } // end of namespace mln::accu::meta::logic
00067     } // end of namespace mln::accu::meta
00068 
00069 
00070     namespace logic
00071     {
00072 
00078       //
00079       struct lor_basic : public mln::accu::internal::base< bool, lor_basic >
00080       {
00081         typedef bool argument;
00082 
00083         lor_basic();
00084 
00087         void init();
00088         void take_as_init_(const argument& t);
00089 
00090         void take(const argument& t);
00091         void take(const lor_basic& other);
00093 
00095         bool to_result() const;
00096 
00099         bool is_valid() const;
00100 
00104         bool can_stop() const;
00105 
00106       protected:
00107         bool res_;
00108       };
00109 
00110 # ifndef MLN_INCLUDE_ONLY
00111 
00112       inline
00113       lor_basic::lor_basic()
00114       {
00115         init();
00116       }
00117 
00118       inline
00119       void
00120       lor_basic::init()
00121       {
00122         res_ = false;
00123       }
00124 
00125       inline
00126       void lor_basic::take_as_init_(const argument& t)
00127       {
00128         res_ = t;
00129       }
00130 
00131       inline
00132       void lor_basic::take(const argument& t)
00133       {
00134         if (res_ == false && t == true)
00135           res_ = true;
00136       }
00137 
00138       inline
00139       void
00140       lor_basic::take(const lor_basic& other)
00141       {
00142         res_ = res_ || other.res_;
00143       }
00144 
00145       inline
00146       bool
00147       lor_basic::to_result() const
00148       {
00149         return res_;
00150       }
00151 
00152       inline
00153       bool
00154       lor_basic::is_valid() const
00155       {
00156         return true;
00157       }
00158 
00159       inline
00160       bool
00161       lor_basic::can_stop() const
00162       {
00163         return res_ == true;
00164       }
00165 
00166 # endif // ! MLN_INCLUDE_ONLY
00167 
00168     } // end of namespace mln::accu::logic
00169   } // end of namespace mln::accu
00170 } // end of namespace mln
00171 
00172 
00173 #endif // ! MLN_ACCU_LOGIC_LOR_BASIC_HH

Generated on Thu Sep 8 2011 18:32:04 for Milena (Olena) by  doxygen 1.7.1