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

land_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_LAND_BASIC_HH
00027 # define MLN_ACCU_LOGIC_LAND_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 land_basic;
00049     }
00050 
00051     namespace meta
00052     {
00053 
00054       namespace logic
00055       {
00056 
00058         struct land_basic : public Meta_Accumulator< land_basic >
00059         {
00060           template <typename T>
00061           struct with
00062           {
00063             typedef accu::logic::land_basic ret;
00064           };
00065         };
00066 
00067       } // end of namespace mln::accu::meta::logic
00068     } // end of namespace mln::accu::meta
00069 
00070 
00071     namespace logic
00072     {
00073 
00079     //
00080     struct land_basic : public mln::accu::internal::base< bool, land_basic >
00081     {
00082       typedef bool argument;
00083 
00084       land_basic();
00085 
00088       void init();
00089       void take_as_init_(const argument& t);
00090 
00091       void take(const argument& t);
00092       void take(const land_basic& other);
00094 
00096       bool to_result() const;
00097 
00100       bool is_valid() const;
00101 
00105       bool can_stop() const;
00106 
00107     protected:
00108       bool res_;
00109     };
00110 
00111 # ifndef MLN_INCLUDE_ONLY
00112 
00113     inline
00114     land_basic::land_basic()
00115     {
00116       init();
00117     }
00118 
00119     inline
00120     void
00121     land_basic::init()
00122     {
00123       res_ = true;
00124     }
00125 
00126     inline
00127     void land_basic::take_as_init_(const argument& t)
00128     {
00129       res_ = t;
00130     }
00131 
00132     inline
00133     void land_basic::take(const argument& t)
00134     {
00135       if (res_ == true && t == false)
00136         res_ = false;
00137     }
00138 
00139     inline
00140     void
00141     land_basic::take(const land_basic& other)
00142     {
00143       res_ = res_ && other.res_;
00144     }
00145 
00146     inline
00147     bool
00148     land_basic::to_result() const
00149     {
00150       return res_;
00151     }
00152 
00153     inline
00154     bool
00155     land_basic::is_valid() const
00156     {
00157       return true;
00158     }
00159 
00160     inline
00161     bool
00162     land_basic::can_stop() const
00163     {
00164       return res_ == false;
00165     }
00166 
00167 # endif // ! MLN_INCLUDE_ONLY
00168 
00169     } // end of namespace mln::accu::logic
00170   } // end of namespace mln::accu
00171 } // end of namespace mln
00172 
00173 
00174 #endif // ! MLN_ACCU_LOGIC_LAND_BASIC_HH

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