2291: Create an util::ordpair_-based container usable as a site.

* mln/util/site_pair.hh: New. --- milena/ChangeLog | 6 +++ milena/mln/util/site_pair.hh | 100 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 0 deletions(-) create mode 100644 milena/mln/util/site_pair.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index 2a8833e..7d3f79a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,11 @@ 2008-09-17 Roland Levillain <roland@lrde.epita.fr> + Create an util::ordpair_-based container usable as a site. + + * mln/util/site_pair.hh: New. + +2008-09-17 Roland Levillain <roland@lrde.epita.fr> + Update util::ordpair_. * mln/util/ordpair.hh diff --git a/milena/mln/util/site_pair.hh b/milena/mln/util/site_pair.hh new file mode 100644 index 0000000..76ab3ab --- /dev/null +++ b/milena/mln/util/site_pair.hh @@ -0,0 +1,100 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_UTIL_SITE_PAIR_HH +# define MLN_UTIL_SITE_PAIR_HH + +# include <mln/util/ordpair.hh> + +/// \file mln/util/site_pair.hh +/// \brief Definition of a site pair type. + +namespace mln +{ + /* FIXME: The class mln::internal::image_base requires its site + types to have a `coord' typedef, but util::ordpair_ has none. + Hence this small workaround. Remove as soon as image_base is + refurbished. */ + template <typename P> + struct site_pair : public mln::Object< site_pair<P> > + { + site_pair(); + site_pair(const P& first, const P& second); + typedef mln_coord(P) coord; + util::ordpair_<P> pair_; + }; + + /* FIXME: The proxy mechanism requires these operators; why? It + seems its static assertions do not check the right guy. IMHO + (Roland's), it should look for line_graph_psite's operators, + not site_pair's. */ + template <typename P> + bool operator==(const site_pair<P>& lhs, const site_pair<P>& rhs); + + template <typename P> + bool operator< (const site_pair<P>& lhs, const site_pair<P>& rhs); + + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + site_pair<P>::site_pair() + : pair_(P(), P()) + { + } + + template <typename P> + site_pair<P>::site_pair(const P& first, const P& second) + : pair_(first, second) + { + } + + template <typename P> + inline + bool + operator==(const site_pair<P>& lhs, const site_pair<P>& rhs) + { + abort(); + return lhs.pair_ == rhs.pair_; + } + + template <typename P> + inline + bool + operator< (const site_pair<P>& lhs, const site_pair<P>& rhs) + { + abort(); + return lhs.pair_ < rhs.pair_; + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of mln + + +#endif // ! MLN_UTIL_SITE_PAIR_HH -- 1.6.0.1
participants (1)
-
Roland Levillain