https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Reorganize and fix oln/core/1d/.
* oln/core/1d/aliases.hh (oln::fwd_piter1d, oln::bkd_piter1d): Fix
their definitions.
* oln/core/1d/neighb1d.hh (oln::c2): Rename as...
(oln::mk_c2): ...this.
(c2): New object.
* oln/core/1d/array1d.hh, oln/core/1d/dpoint1d.hh,
* oln/core/1d/image1d.hh, oln/core/1d/neighb1d.hh,
* oln/core/1d/point1d.hh: Separate the interface of the methods
and functions from their implementation.
* oln/core/1d/image1d.hh (oln::vtypes< image1d<T> >): Set
topo_type to topo1d.
(bbox_<point1d>): Move explicit instantiation...
* oln/basics1d.hh: ...here
(oln/core/fwd_piter.hh): Include it.
* oln/core/1d/image1d.hh:
Move the definition of the virtual types fwd_piter and bkd_piter
of oln::image1d...
* oln/core/fwd_piter.hh: ...here.
* oln/core/abstract/image/hybrid/classical.hh
(oln::abstract:classical_1d_image)
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 1>)
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 2>): Rename
as...
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 2>)
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 3>):
...these.
(oln::case_<image_hybrid_hierarchy_wrt_classical, E, 1>): New.
Handle 1D case.
basics1d.hh | 9 +++-
core/1d/aliases.hh | 5 --
core/1d/array1d.hh | 70 ++++++++++++++++++++++---------
core/1d/dpoint1d.hh | 37 ++++++++++++----
core/1d/image1d.hh | 72 +++++++++++++++++++++++---------
core/1d/neighb1d.hh | 26 +++++++++++
core/1d/point1d.hh | 44 +++++++++++++++----
core/abstract/image/hybrid/classical.hh | 33 +++++++++++++-
core/fwd_piter.hh | 17 +++++++
9 files changed, 249 insertions(+), 64 deletions(-)
Index: oln/core/1d/aliases.hh
--- oln/core/1d/aliases.hh (revision 622)
+++ oln/core/1d/aliases.hh (working copy)
@@ -55,14 +55,13 @@
typedef bbox_<point1d> bbox1d;
typedef topo_lbbox_<point1d> topo1d;
- typedef fwd_piter_bbox_<topo1d> fwd_piter1d;
- typedef bkd_piter_bbox_<topo1d> bkd_piter1d;
+ typedef fwd_piter_bbox_<point1d> fwd_piter1d;
+ typedef bkd_piter_bbox_<point1d> bkd_piter1d;
typedef point1d_<float> point1df;
typedef dpoint1d_<float> dpoint1df;
/// \}
-
} // end of namespace oln
Index: oln/core/1d/neighb1d.hh
--- oln/core/1d/neighb1d.hh (revision 622)
+++ oln/core/1d/neighb1d.hh (working copy)
@@ -36,7 +36,15 @@
namespace oln
{
- neighb1d c2()
+ namespace internal
+ {
+
+ neighb1d mk_c2();
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ neighb1d mk_c2()
{
static bool flower = true;
static neighb1d the_;
@@ -48,6 +56,22 @@
return the_;
}
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+ extern const neighb1d c2;
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ const neighb1d c2 = internal::mk_c2();
+
+# endif
+
+
} // end of namespace oln
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 622)
+++ oln/core/1d/array1d.hh (working copy)
@@ -43,7 +43,38 @@
public:
/// Ctor.
- array1d(coord_t min, coord_t max) :
+ array1d(coord_t min, coord_t max);
+ /// Ctor.
+ array1d(coord_t len);
+
+ /// Dtor.
+ ~array1d();
+
+ value_t operator()(coord_t i) const;
+ value_t& operator()(coord_t i);
+
+ bool has(coord_t i) const;
+
+ size_t memsize() const;
+
+ protected:
+
+ coord_t min_, max_;
+ coord_t len_;
+ value_t* buffer_;
+
+ private:
+
+ void allocate_();
+ void deallocate_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename value_t, typename coord_t>
+ array1d<value_t, coord_t>::array1d(coord_t min, coord_t max) :
min_(min), max_(max)
{
precondition(max >= min);
@@ -51,8 +82,8 @@
allocate_();
}
- /// Ctor.
- array1d(coord_t len) :
+ template <typename value_t, typename coord_t>
+ array1d<value_t, coord_t>::array1d(coord_t len) :
min_(0), len_(len)
{
precondition(len > 0);
@@ -60,55 +91,54 @@
allocate_();
}
- /// Dtor.
- ~array1d()
+ template <typename value_t, typename coord_t>
+ array1d<value_t, coord_t>::~array1d()
{
deallocate_();
}
- value_t operator()(coord_t i) const
+ template <typename value_t, typename coord_t>
+ value_t array1d<value_t, coord_t>::operator()(coord_t i) const
{
precondition(has(i));
return buffer_[i - min_];
}
- value_t& operator()(coord_t i)
+ template <typename value_t, typename coord_t>
+ value_t& array1d<value_t, coord_t>::operator()(coord_t i)
{
precondition(has(i));
return buffer_[i - min_];
}
- bool has(coord_t i) const
+ template <typename value_t, typename coord_t>
+ bool array1d<value_t, coord_t>::has(coord_t i) const
{
return
i >= min_ and i <= max_;
}
- size_t memsize() const
+ template <typename value_t, typename coord_t>
+ size_t array1d<value_t, coord_t>::memsize() const
{
return size_t(len_) * sizeof(value_t);
}
- protected:
-
- coord_t min_, max_;
- coord_t len_;
- value_t* buffer_;
-
- private:
-
- void allocate_()
+ template <typename value_t, typename coord_t>
+ void array1d<value_t, coord_t>::allocate_()
{
buffer_ = new value_t[size_t(len_)];
}
- void deallocate_()
+ template <typename value_t, typename coord_t>
+ void array1d<value_t, coord_t>::deallocate_()
{
precondition(buffer_ != 0);
delete[] buffer_;
buffer_ = 0; // safety
}
- };
+
+# endif
} // end of namespace oln
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 622)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -68,36 +68,57 @@
{
typedef dpoint1d_<C> self_t;
typedef stc_get_super(dpoint1d_<C>) super_t;
- typedef oln_type_of(self_t, coord) coord_t;
using super_t::v_;
public:
/// Ctor.
- dpoint1d_()
+ dpoint1d_();
+
+ /// Ctor.
+ dpoint1d_(const xtd::vec<1,C>& v);
+
+ /// Ctor.
+ dpoint1d_(C index);
+
+ C index() const;
+ C& index();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename C>
+ dpoint1d_<C>::dpoint1d_()
{
}
/// Ctor.
- dpoint1d_(const xtd::vec<1,coord_t>& v)
+ template <typename C>
+ dpoint1d_<C>::dpoint1d_(const xtd::vec<1,C>& v)
: super_t(v)
{
}
/// Ctor.
- dpoint1d_(coord_t index)
+ template <typename C>
+ dpoint1d_<C>::dpoint1d_(C index)
: super_t(xtd::mk_vec(index))
{
}
- coord_t index() const { return v_[0]; }
- coord_t& index() { return v_[0]; }
- };
+ template <typename C>
+ C dpoint1d_<C>::index() const { return v_[0]; }
+ template <typename C>
+ C& dpoint1d_<C>::index() { return v_[0]; }
+
+# endif
-} // end of namespace oln
+} // end of namespace oln
#endif // ! OLN_CORE_1D_DPOINT1D_HH
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 622)
+++ oln/core/1d/image1d.hh (working copy)
@@ -36,16 +36,14 @@
# include <oln/core/internal/tracked_ptr.hh>
// For topo1d.
# include <oln/core/1d/aliases.hh>
+// For fwd_piter and bkd_piter virtual types.
+// FIXME: Really necessary?
+# include <oln/core/fwd_piter.hh>
namespace oln
{
- // FIXME: Inexplicably, this explicit instantiation is required to
- // have topo_lbbox_<point1d> work. See if we can get rid of it.
- template class bbox_<point1d>;
-
-
// Forward declaration.
template <typename T> class image1d;
@@ -54,14 +52,11 @@
template <typename T>
struct vtypes< image1d<T> >
{
- typedef topo_lbbox_<point1d> topo_type;
+ typedef topo1d topo_type;
typedef grid1d grid_type;
typedef point1d point_type;
- typedef fwd_piter_bbox_<topo_type> fwd_piter_type;
- typedef bkd_piter_bbox_<topo_type> bkd_piter_type;
-
typedef T value_type;
typedef T lvalue_type;
typedef mlc::true_ is_mutable_type;
@@ -89,45 +84,84 @@
public:
/// Ctor using sizes.
- image1d(unsigned nindices, unsigned border = 2)
+ image1d(unsigned nindices, unsigned border = 2);
+
+ /// Ctor using an existing topology.
+ image1d(const topo1d& topo);
+
+ const topo1d& impl_topo() const;
+
+ T impl_op_read(const point1d& p) const;
+ T& impl_op_readwrite(const point1d& p);
+
+ T* adr_at(int index);
+ const T* adr_at(int index) const;
+
+ private:
+
+ topo1d topo_;
+ internal::tracked_ptr<array_t> data_;
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image1d<T>::image1d(unsigned nindices, unsigned border)
: topo_(bbox1d(point1d(0), point1d(nindices - 1)), border),
data_(new array_t(0 - border,
nindices - 1 + border))
{
}
- /// Ctor using an existing topology.
- image1d(const topo1d& topo)
+ template <typename T>
+ image1d<T>::image1d(const topo1d& topo)
: topo_(topo),
data_(new array_t(topo.bbox().pmin().index(),
topo.bbox().pmax().index()))
{
}
- const topo1d& impl_topo() const
+ template <typename T>
+ const topo1d& image1d<T>::impl_topo() const
{
return topo_;
}
- T impl_op_read(const point1d& p) const
+ template <typename T>
+ T image1d<T>::impl_op_read(const point1d& p) const
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
return data_->operator()(p.index());
}
- T& impl_op_readwrite(const point1d& p)
+ template <typename T>
+ T& image1d<T>::impl_op_readwrite(const point1d& p)
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
return data_->operator()(p.index());
}
- private:
+ template <typename T>
+ T* image1d<T>::adr_at(int index)
+ {
+ precondition(data_ != 0);
+ precondition(data_->has(index));
+ return &(data_->operator()(index));
+ }
- topo1d topo_;
- internal::tracked_ptr<array_t> data_;
- };
+ template <typename T>
+ const T* image1d<T>::adr_at(int index) const
+ {
+ precondition(data_ != 0);
+ precondition(data_->has(index));
+ return &(data_->operator()(index));
+ }
+
+# endif
} // end of namespace oln
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 622)
+++ oln/core/1d/point1d.hh (working copy)
@@ -76,32 +76,58 @@
{
typedef point1d_<C> self_t;
typedef stc_get_super(point1d_<C>) super_t;
- typedef oln_type_of(self_t, coord) coord_t;
using super_t::v_;
public:
/// Ctor.
- point1d_()
+ point1d_();
+
+ /// Ctor.
+ point1d_(C index);
+
+ /// Ctor.
+ point1d_(const xtd::vec<1,C>& v);
+
+ /// Dtor.
+ ~point1d_()
{
}
- /// Ctor.
- point1d_(coord_t index)
+ C index() const;
+ C& index();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename C>
+ point1d_<C>::point1d_()
+ {
+ }
+
+ template <typename C>
+ point1d_<C>::point1d_(C index)
: super_t (xtd::mk_vec(index))
{
}
- /// Ctor.
- point1d_(const xtd::vec<1,coord_t>& v)
+ template <typename C>
+ point1d_<C>::point1d_(const xtd::vec<1,C>& v)
: super_t(v)
{
}
- coord_t index() const { return v_[0]; }
- coord_t& index() { return v_[0]; }
- };
+ template <typename C>
+ C point1d_<C>::index() const { return v_[0]; }
+
+ template <typename C>
+ C& point1d_<C>::index() { return v_[0]; }
+
+# endif
} // end of namespace oln
Index: oln/basics1d.hh
--- oln/basics1d.hh (revision 622)
+++ oln/basics1d.hh (working copy)
@@ -35,15 +35,18 @@
# include <oln/core/1d/grid1d.hh>
# include <oln/core/1d/point1d.hh>
-
# include <oln/core/1d/dpoint1d.hh>
# include <oln/core/gen/bbox.hh>
+// FIXME: Inexplicably, this explicit instantiation is required to
+// have topo_lbbox_<point1d> work. See if we can get rid of it.
+namespace oln {
+ template class bbox_<point1d>;
+}
# include <oln/core/gen/topo_lbbox.hh>
# include <oln/core/gen/fwd_piter_bbox.hh>
-
# include <oln/core/gen/bkd_piter_bbox.hh>
# include <oln/core/gen/neighb.hh>
@@ -51,5 +54,7 @@
# include <oln/core/1d/image1d.hh>
+# include <oln/core/fwd_piter.hh>
+
#endif // ! OLN_BASICS1D_HH
Index: oln/core/fwd_piter.hh
--- oln/core/fwd_piter.hh (revision 622)
+++ oln/core/fwd_piter.hh (working copy)
@@ -111,6 +111,23 @@
};
+ // image1d<T>
+
+ template <typename T> class image1d;
+
+ template <typename T>
+ struct single_vtype< image1d<T>, typedef_::fwd_piter_type >
+ {
+ typedef fwd_piter1d ret;
+ };
+
+ template <typename T>
+ struct single_vtype< image1d<T>, typedef_::bkd_piter_type >
+ {
+ typedef bkd_piter1d ret;
+ };
+
+
// image2d<T>
template <typename T> class image2d;
Index: oln/core/abstract/image/hybrid/classical.hh
--- oln/core/abstract/image/hybrid/classical.hh (revision 622)
+++ oln/core/abstract/image/hybrid/classical.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/image/hierarchies.hh>
+# include <oln/core/abstract/image/dimension/1d.hh>
# include <oln/core/abstract/image/dimension/2d.hh>
# include <oln/core/abstract/image/bbox/hierarchy.hh>
# include <oln/core/abstract/image/accessibility/hierarchy.hh>
@@ -52,6 +53,15 @@
};
template <typename E>
+ struct classical_1d_image
+ : public virtual abstract::classical_image<E>,
+ public virtual abstract::image1d<E>
+ {
+ protected:
+ classical_1d_image();
+ };
+
+ template <typename E>
struct classical_2d_image
: public virtual abstract::classical_image<E>,
public virtual abstract::image2d<E>
@@ -69,6 +79,11 @@
}
template <typename E>
+ classical_1d_image<E>::classical_1d_image()
+ {
+ }
+
+ template <typename E>
classical_2d_image<E>::classical_2d_image()
{
}
@@ -79,12 +94,26 @@
// Fwd. decl.
+ class grid1d;
class grid2d;
- /// 2-D case.
+ /// 1D case.
template <typename E>
struct case_< image_hybrid_hierarchy_wrt_classical, E, 1 > :
+ where_< mlc::and_list_< mlc::eq_< oln_type_of(E, grid), oln::grid1d >,
+ mlc::eq_< oln_deduce_type_of(E, topo, is_random_accessible), mlc::true_ >,
+ mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >
+
+ >
+ {
+ typedef abstract::classical_1d_image<E> ret;
+ };
+
+
+ /// 2D case.
+ template <typename E>
+ struct case_< image_hybrid_hierarchy_wrt_classical, E, 2 > :
where_< mlc::and_list_< mlc::eq_< oln_type_of(E, grid), oln::grid2d >,
mlc::eq_< oln_deduce_type_of(E, topo, is_random_accessible), mlc::true_ >,
mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >
@@ -97,7 +126,7 @@
/// General case.
template <typename E>
- struct case_< image_hybrid_hierarchy_wrt_classical, E, 2 > :
+ struct case_< image_hybrid_hierarchy_wrt_classical, E, 3 > :
where_< mlc::and_< mlc::eq_< oln_deduce_type_of(E, topo,
is_random_accessible), mlc::true_ >,
mlc::neq_< oln_deduce_type_of(E, topo, bbox), mlc::not_found >