Commit a913e1f8 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add value::next routine.

	* mln/value/label.hh: Include next routine.

	* mln/value/next.hh: New.
parent 396cb068
2010-10-21 Guillaume Lazzara <z@lrde.epita.fr>
Add value::next routine.
* mln/value/label.hh: Include next routine.
* mln/value/next.hh: New.
2010-09-15 Guillaume Lazzara <z@lrde.epita.fr>
 
Temporarily disable static tests on Magick::Quantum type size.
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project 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. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#ifndef MLN_VALUE_NEXT_HH
# define MLN_VALUE_NEXT_HH
/// \file
///
/// Return a given value incremented by 1.
# include <mln/value/label.hh>
namespace mln
{
namespace value
{
template <typename V>
V
next(const V&);
# ifndef MLN_INCLUDE_ONLY
// Implementations
namespace implementation
{
namespace generic
{
template <typename V>
inline
V
next(const V& v)
{
return v + 1;
}
} // end of namespace mln::value::implementation::generic
template <unsigned n>
inline
mln::value::label<n>
next_label(const mln::value::label<n>& v)
{
return v.next();
}
} // end of namespace mln::value::implementation
// Dispatch
namespace internal
{
template <unsigned n>
inline
label<n>
next_dispatch(const label<n>& v)
{
return implementation::next_label(v);
}
template <typename V>
inline
V
next_dispatch(const V& v)
{
return implementation::generic::next(v);
}
} // end of namespace mln::value::internal
// Facade
template <typename V>
inline
V
next(const V& v)
{
return internal::next_dispatch(v);
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
} // end of namespace mln
#endif // ! MLN_VALUE_NEXT_HH
......@@ -115,6 +115,9 @@ namespace scribo
typedef mln_result(center_accu_t) center_t;
typedef internal::component_set_data<L> data_t;
typedef data_t* id_t;
public:
/// Constructors
......@@ -190,7 +193,7 @@ namespace scribo
const mln::util::array<scribo::component_info>& infos_() const;
/// Unique set Id.
unsigned id_() const;
id_t id_() const;
/// Read/Write access to the underlying labeled image.
......@@ -212,7 +215,7 @@ namespace scribo
/// Duplicate the underlying image and create a new component_set.
void init_(const component_set<L>& model);
mln::util::tracked_ptr< internal::component_set_data<L> > data_;
mln::util::tracked_ptr<data_t> data_;
};
......@@ -312,7 +315,7 @@ namespace scribo
{
typedef mln_site(L) P;
infos_.reserve(static_cast<unsigned>(ncomps_) + 1);
infos_.reserve(value::next(ncomps_));
infos_.append(component_info()); // Component 0, i.e. the background.
for_all_comp_data(i, attribs)
......@@ -330,7 +333,7 @@ namespace scribo
{
typedef mln_site(L) P;
infos_.reserve(static_cast<unsigned>(ncomps_) + 1);
infos_.reserve(value::next(ncomps_));
infos_.append(component_info()); // Component 0, i.e. the background.
for_all_comp_data(i, attribs)
......@@ -485,10 +488,10 @@ namespace scribo
template <typename L>
inline
unsigned
typename component_set<L>::id_t
component_set<L>::id_() const
{
return (unsigned)data_.ptr_;
return data_.ptr_;
}
......@@ -506,7 +509,7 @@ namespace scribo
mln_concrete(L)
component_set<L>::valid_comps_image_() const
{
mln::util::array<bool> f(unsigned(this->data_->ncomps_) + 1);
mln::util::array<bool> f(value::next(this->data_->ncomps_));
f(0) = true;
for_all_comps(c, (*this))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment