608: Separate definition code from declaration code in olena.

2006-10-09 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> Separate definition code from declaration code in olena. * oln/core/type.hh: Split code. * oln/core/point_set_entry.hh: Likewise. * oln/core/automatic/image.hh: Likewise. * oln/core/automatic/topology_having_bbox.hh: Likewise. * oln/core/automatic/image_being_random_accessible.hh: Likewise. * oln/core/automatic/image_having_neighborhood.hh: Likewise. * oln/core/automatic/topology_being_random_accessible.hh: Likewise. * oln/core/automatic/topology_having_subset.hh: Likewise. * oln/core/automatic/image_being_mutable.hh: Likewise. * oln/core/automatic/topology_having_neighborhood.hh: Likewise. * oln/core/neighborhood_entry.hh: Likewise. * oln/core/topology_entry.hh: Likewise. * oln/core/image_entry.hh: Likewise. * oln/core/abstract/iterator_on_points.hh: Likewise. * oln/core/abstract/topology_having_bbox.hh: Likewise. * oln/core/abstract/image.hh: Likewise. * oln/core/abstract/image/type/binary.hh: Likewise. * oln/core/abstract/image/type/data.hh: Likewise. * oln/core/abstract/image/type/grey_level.hh: Likewise. * oln/core/abstract/image/type/color.hh: Likewise. * oln/core/abstract/image/type/label.hh: Likewise. * oln/core/abstract/image/hybrid/classical.hh: Likewise. * oln/core/abstract/image/mutability/hierarchy.hh: Likewise. * oln/core/abstract/image/dimension/2d.hh: Likewise. * oln/core/abstract/image/neighborhood/hierarchy.hh: Likewise. * oln/core/abstract/image/accessibility/hierarchy.hh: Likewise. * oln/core/abstract/image/bbox/hierarchy.hh: Likewise. * oln/core/abstract/point_set_being_random_accessible.hh: Likewise. * oln/core/abstract/grid.hh: Likewise. * oln/core/abstract/iterator.hh: Likewise. * oln/core/abstract/point.hh: Likewise. * oln/core/abstract/bbox.hh: Likewise. * oln/core/abstract/point_set_being_connected.hh: Likewise. * oln/core/abstract/dpoint.hh: Likewise. * oln/core/abstract/topology_being_random_accessible.hh: Likewise. * oln/core/abstract/topology_having_subset.hh: Likewise. * oln/core/abstract/topology_having_neighborhood.hh: Likewise. * oln/core/abstract/entry.hh: Likewise. * oln/core/abstract/point_set.hh: Likewise. * oln/core/abstract/point_set_having_known_size.hh: Likewise. * oln/core/abstract/neighborhood.hh: Likewise. * oln/core/abstract/point_set_having_bbox.hh: Likewise. * oln/core/abstract/topology.hh: Likewise. * oln/core/2d/neighb2d.hh: Likewise. * oln/core/2d/dpoint2d.hh: Likewise. * oln/core/2d/array2d.hh: Likewise. * oln/core/2d/image2d.hh: Likewise. * oln/core/2d/point2d.hh: Likewise. * oln/core/gen/piter_isubset.hh: Likewise. * oln/core/gen/topo_add_isubset.hh: Likewise. * oln/core/gen/bbox.hh: Likewise. * oln/core/gen/topo_bbox.hh: Likewise. * oln/core/gen/neighb.hh: Likewise. * oln/core/gen/fwd_piter_bbox.hh: Likewise. * oln/core/gen/bbox_fwd_piter.hh: Likewise. * oln/core/gen/fwd_niter_neighb.hh: Likewise. * oln/core/gen/fwd_qiter_win.hh: Likewise. * oln/core/gen/topo_lbbox.hh: Likewise. * oln/core/gen/window.hh: Likewise. * oln/core/gen/bbox_bkd_piter.hh: Likewise. * oln/core/gen/bkd_piter_bbox.hh: Likewise. * oln/core/gen/topo_add_nbh.hh: Likewise. * oln/core/gen/mapimage.hh: Likewise. * oln/core/internal/tracked_ptr.hh: Likewise. * oln/core/internal/topology_morpher.hh: Likewise. * oln/core/internal/point_nd.hh: Likewise. * oln/core/internal/bbox_bkd_piter.hh: Likewise. * oln/core/internal/bbox_fwd_piter.hh: Likewise. * oln/core/internal/dpoint_nd.hh: Likewise. * oln/basics2d.hh: Likewise. * oln/morpher/add_isubset.hh: Likewise. * oln/morpher/identity.hh: Likewise. * oln/morpher/internal/image_extension.hh: Likewise. * oln/morpher/add_neighborhood.hh: Likewise. Index: oln/core/type.hh =================================================================== --- oln/core/type.hh (revision 606) +++ oln/core/type.hh (working copy) @@ -35,9 +35,18 @@ struct type { protected: - type() {} + type(); }; + +# ifndef OLN_INCLUDE_ONLY + + type::type() + { + } + +# endif + } // end of namespace oln Index: oln/core/point_set_entry.hh =================================================================== --- oln/core/point_set_entry.hh (revision 606) +++ oln/core/point_set_entry.hh (working copy) @@ -44,10 +44,21 @@ struct point_set_entry : public entry< abstract::point_set, E> { protected: - point_set_entry() {} + point_set_entry(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + point_set_entry<E>::point_set_entry() + { + } + +# endif + + /// Virtual types associated to point_set_entry<E>. template <typename E> Index: oln/core/automatic/image.hh =================================================================== --- oln/core/automatic/image.hh (revision 606) +++ oln/core/automatic/image.hh (working copy) @@ -61,18 +61,30 @@ /// Delegation. - const topo_t& impl_topo() const - { - return this->exact().delegate().topo(); - } + const topo_t& impl_topo() const; + rvalue_t impl_op_read(const psite_t& p) const; - rvalue_t impl_op_read(const psite_t& p) const - { - return this->exact().delegate().operator()(p); - } - }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename set_impl<abstract::image, morpher::tag::identity, E>::topo_t& + set_impl<abstract::image, morpher::tag::identity, E>::impl_topo() const + { + return this->exact().delegate().topo(); + } + + template <typename E> + typename set_impl<abstract::image, morpher::tag::identity, E>::rvalue_t + set_impl<abstract::image, morpher::tag::identity, E>::impl_op_read(const typename set_impl<abstract::image, morpher::tag::identity, E>::psite_t& p) const + { + return this->exact().delegate().operator()(p); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/topology_having_bbox.hh =================================================================== --- oln/core/automatic/topology_having_bbox.hh (revision 606) +++ oln/core/automatic/topology_having_bbox.hh (working copy) @@ -60,13 +60,22 @@ public: - const bbox_t& impl_bbox() const - { - return this->exact().delegate().bbox(); - } + const bbox_t& impl_bbox() const; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename set_impl< abstract::topology_having_bbox, morpher::tag::identity, E >::bbox_t& + set_impl< abstract::topology_having_bbox, morpher::tag::identity, E >::impl_bbox() const + { + return this->exact().delegate().bbox(); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/image_being_random_accessible.hh =================================================================== --- oln/core/automatic/image_being_random_accessible.hh (revision 606) +++ oln/core/automatic/image_being_random_accessible.hh (working copy) @@ -59,19 +59,30 @@ public: - bool impl_has(const point_t& p) const - { - return this->exact().topo().has(p); - } + bool impl_has(const point_t& p) const; + bool impl_has_large(const point_t& p) const; - bool impl_has_large(const point_t& p) const - { - return this->exact().has(p); - } - }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E, typename M> + bool + set_impl<abstract::image_being_random_accessible, M, E>::impl_has(const typename set_impl<abstract::image_being_random_accessible, M, E>::point_t& p) const + { + return this->exact().topo().has(p); + } + + template <typename E, typename M> + bool + set_impl<abstract::image_being_random_accessible, M, E>::impl_has_large(const typename set_impl<abstract::image_being_random_accessible, M, E>::point_t& p) const + { + return this->exact().has(p); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/image_having_neighborhood.hh =================================================================== --- oln/core/automatic/image_having_neighborhood.hh (revision 606) +++ oln/core/automatic/image_having_neighborhood.hh (working copy) @@ -57,12 +57,21 @@ public: /// Accessor delegation. - const neighborhood_t& impl_neighborhood() const - { - return this->exact().delegate().neighborhood(); - } + const neighborhood_t& impl_neighborhood() const; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename set_impl< abstract::image_having_neighborhood, morpher::tag::identity, E>::neighborhood_t& + set_impl< abstract::image_having_neighborhood, morpher::tag::identity, E>::impl_neighborhood() const + { + return this->exact().delegate().neighborhood(); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/topology_being_random_accessible.hh =================================================================== --- oln/core/automatic/topology_being_random_accessible.hh (revision 606) +++ oln/core/automatic/topology_being_random_accessible.hh (working copy) @@ -61,18 +61,29 @@ public: - bool impl_has(const point_t& p) const - { - return this->exact().delegate().has(p); - } + bool impl_has(const point_t& p) const; + bool impl_has_large(const point_t& p) const; - bool impl_has_large(const point_t& p) const - { - return this->exact().delegate().has_large(p); - } - }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool + set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::impl_has(const typename set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::point_t& p) const + { + return this->exact().delegate().has(p); + } + + bool + set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::impl_has_large(const typename set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::point_t& p) const + { + return this->exact().delegate().has_large(p); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/topology_having_subset.hh =================================================================== --- oln/core/automatic/topology_having_subset.hh (revision 607) +++ oln/core/automatic/topology_having_subset.hh (working copy) @@ -60,13 +60,22 @@ public: - const subset_t& impl_subset() const - { - return this->exact().delegate().subset(); - } + const subset_t& impl_subset() const; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename set_impl< abstract::topology_having_subset, morpher::tag::identity, E >::subset_t& + set_impl< abstract::topology_having_subset, morpher::tag::identity, E >::impl_subset() const + { + return this->exact().delegate().subset(); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/image_being_mutable.hh =================================================================== --- oln/core/automatic/image_being_mutable.hh (revision 606) +++ oln/core/automatic/image_being_mutable.hh (working copy) @@ -56,12 +56,20 @@ public: /// Accessor delegation. - lvalue_t& impl_op_readwrite(const psite_t& p) const - { - return this->exact().delegate().operator()(p); - } + lvalue_t& impl_op_readwrite(const psite_t& p) const; }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + typename set_impl<abstract::image_being_mutable, morpher::tag::identity, E>::lvalue_t& + set_impl<abstract::image_being_mutable, morpher::tag::identity, E>::impl_op_readwrite(const typename set_impl<abstract::image_being_mutable, morpher::tag::identity, E>::psite_t& p) const + { + return this->exact().delegate().operator()(p); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/automatic/topology_having_neighborhood.hh =================================================================== --- oln/core/automatic/topology_having_neighborhood.hh (revision 606) +++ oln/core/automatic/topology_having_neighborhood.hh (working copy) @@ -60,13 +60,22 @@ public: - const neighborhood_t& impl_neighborhood() const - { - return this->exact().delegate().neighborhood(); - } + const neighborhood_t& impl_neighborhood() const; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename set_impl< abstract::topology_having_neighborhood, morpher::tag::identity, E >::neighborhood_t& + set_impl< abstract::topology_having_neighborhood, morpher::tag::identity, E >::impl_neighborhood() const + { + return this->exact().delegate().neighborhood(); + } + +# endif + } // end of namespace oln::automatic } // end of namespace oln Index: oln/core/neighborhood_entry.hh =================================================================== --- oln/core/neighborhood_entry.hh (revision 606) +++ oln/core/neighborhood_entry.hh (working copy) @@ -44,10 +44,20 @@ struct neighborhood_entry : public entry< abstract::neighborhood, E> { protected: - neighborhood_entry() {} + neighborhood_entry(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + neighborhood_entry<E>::neighborhood_entry() + { + } + +# endif + + /// Virtual types associated to neighborhood_entry<E>. template <typename E> Index: oln/core/topology_entry.hh =================================================================== --- oln/core/topology_entry.hh (revision 607) +++ oln/core/topology_entry.hh (working copy) @@ -44,10 +44,20 @@ struct topology_entry : public entry< abstract::topology, E> { protected: - topology_entry() {} + topology_entry(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + topology_entry<E>::topology_entry() + { + } + +# endif + + /// Virtual types associated to topology_entry<E>. template <typename E> Index: oln/core/image_entry.hh =================================================================== --- oln/core/image_entry.hh (revision 607) +++ oln/core/image_entry.hh (working copy) @@ -44,10 +44,21 @@ struct image_entry : public entry<abstract::image, E> { protected: - image_entry() {} + image_entry(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + image_entry<E>::image_entry() + { + } + +# endif + + + /// Virtual types associated to image_entry<E>. template <typename E> Index: oln/core/abstract/iterator_on_points.hh =================================================================== --- oln/core/abstract/iterator_on_points.hh (revision 606) +++ oln/core/abstract/iterator_on_points.hh (working copy) @@ -68,39 +68,63 @@ public: - point_t to_point() const - { - precondition(this->is_valid()); - return this->exact().impl_to_point(); - } + point_t to_point() const; - const point_t* point_adr() const - { - return this->exact().impl_point_adr(); - } + const point_t* point_adr() const; // Concrete method. - operator point_t() const - { - precondition(this->is_valid()); - return this->to_point(); - } + operator point_t() const; protected: - iterator_on_points() - { - } + iterator_on_points(); - ~iterator_on_points() - { - mlc::assert_defined_< point_t >::check(); - mlc::assert_< mlc_is_a(point_t, abstract::point) >::check(); - } + ~iterator_on_points(); }; // end of class oln::abstract::iterator_on_points<E> + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + typename iterator_on_points<E>::point_t + iterator_on_points<E>::to_point() const + { + precondition(this->is_valid()); + return this->exact().impl_to_point(); + } + + template <typename E> + const typename iterator_on_points<E>::point_t* + iterator_on_points<E>::point_adr() const + { + return this->exact().impl_point_adr(); + } + + template <typename E> + // Concrete method. + iterator_on_points<E>::operator typename iterator_on_points<E>::point_t() const + { + precondition(this->is_valid()); + return this->to_point(); + } + + template <typename E> + iterator_on_points<E>::iterator_on_points() + { + } + + template <typename E> + iterator_on_points<E>::~iterator_on_points() + { + mlc::assert_defined_< typename iterator_on_points<E>::point_t >::check(); + mlc::assert_< mlc_is_a(typename iterator_on_points<E>::point_t, abstract::point) >::check(); + } + + +# endif + } // end of namespace oln::abstract Index: oln/core/abstract/topology_having_bbox.hh =================================================================== --- oln/core/abstract/topology_having_bbox.hh (revision 606) +++ oln/core/abstract/topology_having_bbox.hh (working copy) @@ -48,30 +48,50 @@ public: // abstract - const bbox_t& bbox() const - { - return this->exact().impl_bbox(); - } + const bbox_t& bbox() const; // abstract - bbox_t& bbox() - { - return this->exact().impl_bbox(); - } + bbox_t& bbox(); // concrete - operator bbox_t() const - { - return this->bbox(); - } + operator bbox_t() const; protected: - topology_having_bbox() - {} + topology_having_bbox(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const oln_type_of(E, bbox)& + topology_having_bbox<E>::bbox() const + { + return this->exact().impl_bbox(); + } + + template <typename E> + oln_type_of(E, bbox)& + topology_having_bbox<E>::bbox() + { + return this->exact().impl_bbox(); + } + + template <typename E> + topology_having_bbox<E>::operator oln_type_of(E, bbox)() const + { + return this->bbox(); + } + + template <typename E> + topology_having_bbox<E>::topology_having_bbox() + { + } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/image.hh =================================================================== --- oln/core/abstract/image.hh (revision 606) +++ oln/core/abstract/image.hh (working copy) @@ -63,33 +63,24 @@ struct decl { - stc_virtual_typedef(topo); - stc_virtual_typedef(grid); +// stc_virtual_typedef(topo); +// stc_virtual_typedef(grid); - stc_virtual_typedef(psite); - stc_virtual_typedef(point); +// stc_virtual_typedef(psite); +// stc_virtual_typedef(point); - stc_virtual_typedef(piter); - stc_virtual_typedef(fwd_piter); - stc_virtual_typedef(bkd_piter); +// // stc_virtual_typedef(piter); +// // stc_virtual_typedef(fwd_piter); +// // stc_virtual_typedef(bkd_piter); - stc_virtual_typedef(value); - stc_virtual_typedef(rvalue); +// stc_virtual_typedef(value); +// stc_virtual_typedef(rvalue); - stc_virtual_typedef(concrete); +// stc_virtual_typedef(concrete); - stc_virtual_typedef(morpher); +// stc_virtual_typedef(morpher); - decl() - { - mlc::assert_< mlc_is_a(topo, abstract::topology) >::check(); - mlc::assert_< mlc_is_a(grid, abstract::grid) >::check(); - mlc::assert_< mlc_is_a(piter, abstract::iterator_on_points) >::check(); - mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check(); - mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check(); - // FIXME: Rec. - // mlc::assert_< mlc_is_a(concrete, abstract::image) >::check(); - } + decl(); }; @@ -116,34 +107,71 @@ ** topo2d. */ - const topo_t& topo() const - { - return this->exact().impl_topo(); - } + const topo_t& topo() const; /*! \brief Gives access to the value stored at \a p in the ** current image. */ - rvalue_t operator()(const psite_t& p) const - { - return this->exact().impl_op_read(p); - } + rvalue_t operator()(const psite_t& p) const; protected: /*! \brief Constructor (protected, empty). */ - image() {} + image(); /*! \brief Destructor. */ - virtual ~image() { decl(); } + virtual ~image(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + image<E>::decl::decl() + { +// mlc::assert_< mlc_is_a(topo, abstract::topology) >::check(); +// mlc::assert_< mlc_is_a(grid, abstract::grid) >::check(); +// mlc::assert_< mlc_is_a(piter, abstract::iterator_on_points) >::check(); +// mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check(); +// mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check(); + // FIXME: Rec. + // mlc::assert_< mlc_is_a(concrete, abstract::image) >::check(); + } + + template <typename E> + image<E>::image() + { + } + + template <typename E> + image<E>::~image() + { + decl(); + } + + template <typename E> + const typename image<E>::topo_t& + image<E>::topo() const + { + return this->exact().impl_topo(); + } + + template <typename E> + typename image<E>::rvalue_t + image<E>::operator()(const typename image<E>::psite_t& p) const + { + return this->exact().impl_op_read(p); + } + +# endif + + + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/image/type/binary.hh =================================================================== --- oln/core/abstract/image/type/binary.hh (revision 606) +++ oln/core/abstract/image/type/binary.hh (working copy) @@ -45,9 +45,19 @@ { protected: /// Constructor (protected, empty). - binary_image() {} + binary_image(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + binary_image<E>::binary_image() + { + } + +# endif + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/image/type/data.hh =================================================================== --- oln/core/abstract/image/type/data.hh (revision 606) +++ oln/core/abstract/image/type/data.hh (working copy) @@ -43,9 +43,18 @@ { protected: /// Constructor (protected, empty). - data_image() {} + data_image(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + data_image<E>::data_image() + { + } + +# endif + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/image/type/grey_level.hh =================================================================== --- oln/core/abstract/image/type/grey_level.hh (revision 606) +++ oln/core/abstract/image/type/grey_level.hh (working copy) @@ -49,9 +49,18 @@ { protected: /// Constructor (protected, empty). - grey_level_image() {} + grey_level_image(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + grey_level_image<E>::grey_level_image() + { + } + +# endif + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/image/type/color.hh =================================================================== --- oln/core/abstract/image/type/color.hh (revision 606) +++ oln/core/abstract/image/type/color.hh (working copy) @@ -43,9 +43,18 @@ { protected: /// Constructor (protected, empty). - color_image() {} + color_image(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + color_image<E>::color_image() + { + } + +# endif + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/image/type/label.hh =================================================================== --- oln/core/abstract/image/type/label.hh (revision 606) +++ oln/core/abstract/image/type/label.hh (working copy) @@ -45,9 +45,18 @@ { protected: /// Constructor (protected, empty). - label_image() {} + label_image(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + label_image<E>::label_image() + { + } + +# endif + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/image/hybrid/classical.hh =================================================================== --- oln/core/abstract/image/hybrid/classical.hh (revision 606) +++ oln/core/abstract/image/hybrid/classical.hh (working copy) @@ -47,8 +47,7 @@ public virtual abstract::image_being_random_accessible<E> { protected: - classical_image() - {} + classical_image(); }; template <typename E> @@ -57,10 +56,24 @@ public virtual abstract::image2d<E> { protected: - classical_2d_image() - {} + classical_2d_image(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + classical_image<E>::classical_image() + { + } + + template <typename E> + classical_2d_image<E>::classical_2d_image() + { + } + +# endif + } // end of namespace oln::abstract Index: oln/core/abstract/image/mutability/hierarchy.hh =================================================================== --- oln/core/abstract/image/mutability/hierarchy.hh (revision 606) +++ oln/core/abstract/image/mutability/hierarchy.hh (working copy) @@ -37,8 +37,8 @@ { /*-------------------------. - | Dimension abstractions. | - `-------------------------*/ + | Dimension abstractions. | + `-------------------------*/ namespace abstract { @@ -67,27 +67,47 @@ using image<E>::operator(); - lvalue_t& operator()(const psite_t& p) - { - return this->exact().impl_op_readwrite(p); - } + lvalue_t& operator()(const psite_t& p); protected: /// Constructor (protected, empty). - image_being_mutable() {} + image_being_mutable(); /// Destructor (protected). - ~image_being_mutable() { decl(); } + ~image_being_mutable(); }; - + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + typename image_being_mutable<E>::lvalue_t& + image_being_mutable<E>::operator()(const typename image_being_mutable<E>::psite_t& p) + { + return this->exact().impl_op_readwrite(p); + } + + template <typename E> + image_being_mutable<E>::image_being_mutable() + { + } + + template <typename E> + image_being_mutable<E>::~image_being_mutable() + { + decl(); + } + +# endif + } // end of namespace oln::abstract /*-------------------. - | Dimension switch. | - `-------------------*/ + | Dimension switch. | + `-------------------*/ /// With mutability. template <typename E> Index: oln/core/abstract/image/dimension/2d.hh =================================================================== --- oln/core/abstract/image/dimension/2d.hh (revision 606) +++ oln/core/abstract/image/dimension/2d.hh (working copy) @@ -45,8 +45,18 @@ { protected: /// Constructor (protected, empty). - image2d() {} + image2d(); }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + image2d<E>::image2d() + { + } + +# endif } // end of namespace oln::abstract Index: oln/core/abstract/image/neighborhood/hierarchy.hh =================================================================== --- oln/core/abstract/image/neighborhood/hierarchy.hh (revision 607) +++ oln/core/abstract/image/neighborhood/hierarchy.hh (working copy) @@ -70,20 +70,41 @@ stc_virtual_typedef(bkd_niter); }; - const neighborhood_t& neighborhood() const - { - return this->topo().neighborhood(); - } + const neighborhood_t& neighborhood() const; protected: /// Constructor (protected, empty). - image_having_neighborhood() {} + image_having_neighborhood(); /// Destructor (protected). - ~image_having_neighborhood() { decl(); } + ~image_having_neighborhood(); }; + + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename image_having_neighborhood<E>::neighborhood_t& + image_having_neighborhood<E>::neighborhood() const + { + return this->topo().neighborhood(); + } + + template <typename E> + image_having_neighborhood<E>::image_having_neighborhood() + { + } + + template <typename E> + image_having_neighborhood<E>::~image_having_neighborhood() + { + decl(); + } + +# endif } // end of namespace oln::abstract Index: oln/core/abstract/image/accessibility/hierarchy.hh =================================================================== --- oln/core/abstract/image/accessibility/hierarchy.hh (revision 606) +++ oln/core/abstract/image/accessibility/hierarchy.hh (working copy) @@ -53,22 +53,39 @@ public: // Abstract method. - bool has(const point_t& p) const - { - return this->exact().impl_has(p); - } + bool has(const point_t& p) const; // Abstract method. - bool has_large(const point_t& p) const - { - return this->exact().impl_has_large(p); - } + bool has_large(const point_t& p) const; protected: /// Constructor (protected, empty). - image_being_random_accessible() {} + image_being_random_accessible(); }; + + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool image_being_random_accessible<E>::has(const typename image_being_random_accessible<E>::point_t& p) const + { + return this->exact().impl_has(p); + } + + template <typename E> + bool image_being_random_accessible<E>::has_large(const typename image_being_random_accessible<E>::point_t& p) const + { + return this->exact().impl_has_large(p); + } + + template <typename E> + image_being_random_accessible<E>::image_being_random_accessible() + { + } + +# endif } // end of namespace oln::abstract Index: oln/core/abstract/image/bbox/hierarchy.hh =================================================================== --- oln/core/abstract/image/bbox/hierarchy.hh (revision 606) +++ oln/core/abstract/image/bbox/hierarchy.hh (working copy) @@ -36,8 +36,8 @@ { /*-------------------------. - | Dimension abstractions. | - `-------------------------*/ + | Dimension abstractions. | + `-------------------------*/ namespace abstract { @@ -59,45 +59,76 @@ { stc_virtual_typedef(bbox); - decl() - { - mlc::assert_< mlc_is_a(bbox, abstract::bbox) >::check(); - } + decl(); }; // Concrete method. - const bbox_t& bbox() const - { - return this->topo().bbox(); - } + const bbox_t& bbox() const; // Concrete method. - const point_t& pmin() const - { - return this->topo().bbox().pmin(); - } + const point_t& pmin() const; // Concrete method. - const point_t& pmax() const - { - return this->topo().bbox().pmax(); - } + const point_t& pmax() const; protected: /// Constructor (protected, empty). + image_having_bbox(); - image_having_bbox() {} /// Destructor. - virtual ~image_having_bbox() { decl(); } + virtual ~image_having_bbox(); }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + image_having_bbox<E>::decl::decl() + { + mlc::assert_< mlc_is_a(bbox, abstract::bbox) >::check(); + } + + template <typename E> + const typename image_having_bbox<E>::bbox_t& + image_having_bbox<E>::bbox() const + { + return this->topo().bbox(); + } + + template <typename E> + const typename image_having_bbox<E>::point_t& + image_having_bbox<E>::pmin() const + { + return this->topo().bbox().pmin(); + } + + template <typename E> + const typename image_having_bbox<E>::point_t& + image_having_bbox<E>::pmax() const + { + return this->topo().bbox().pmax(); + } + + template <typename E> + image_having_bbox<E>::image_having_bbox() + { + } + + template <typename E> + image_having_bbox<E>::~image_having_bbox() + { + decl(); + } + +# endif } // end of namespace oln::abstract /*-------------------. - | Dimension switch. | - `-------------------*/ + | Dimension switch. | + `-------------------*/ /// With bbox. template <typename E> Index: oln/core/abstract/point_set_being_random_accessible.hh =================================================================== --- oln/core/abstract/point_set_being_random_accessible.hh (revision 606) +++ oln/core/abstract/point_set_being_random_accessible.hh (working copy) @@ -46,17 +46,29 @@ public: - bool has(const point_t& p) const - { - return this->exact().impl_has(p); - } + bool has(const point_t& p) const; protected: - point_set_being_random_accessible() - {} + point_set_being_random_accessible(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool point_set_being_random_accessible<E>::has(const point_t& p) const + { + return this->exact().impl_has(p); + } + + template <typename E> + point_set_being_random_accessible<E>::point_set_being_random_accessible() + { + } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/grid.hh =================================================================== --- oln/core/abstract/grid.hh (revision 606) +++ oln/core/abstract/grid.hh (working copy) @@ -52,10 +52,19 @@ struct grid : public virtual stc::any__simple<E> { protected: - grid() - {} + grid(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + grid<E>::grid() + { + } + +# endif + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/iterator.hh =================================================================== --- oln/core/abstract/iterator.hh (revision 606) +++ oln/core/abstract/iterator.hh (working copy) @@ -46,36 +46,56 @@ { public: - void start() - { - this->exact().impl_start(); - } + void start(); - void next() - { - precondition(this->is_valid()); - this->exact().impl_next(); - } + void next(); - void invalidate() - { - this->exact().impl_invalidate(); - } + void invalidate(); - bool is_valid() const - { - return this->exact().impl_is_valid(); - } + bool is_valid() const; protected: - iterator() - { - } + iterator(); }; // end of class oln::abstract::iterator<E> + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + void iterator<E>::start() + { + this->exact().impl_start(); + } + + template <typename E> + void iterator<E>::next() + { + precondition(this->is_valid()); + this->exact().impl_next(); + } + + template <typename E> + void iterator<E>::invalidate() + { + this->exact().impl_invalidate(); + } + + template <typename E> + bool iterator<E>::is_valid() const + { + return this->exact().impl_is_valid(); + } + + template <typename E> + iterator<E>::iterator() + { + } + +# endif + } // end of namespace oln::abstract Index: oln/core/abstract/point.hh =================================================================== --- oln/core/abstract/point.hh (revision 606) +++ oln/core/abstract/point.hh (working copy) @@ -71,7 +71,6 @@ class point : public stc::any__simple<E>, public oln::type { - typedef E exact_t; typedef oln_type_of(E, dpoint) dpoint_t; public: @@ -80,19 +79,10 @@ /// \{ /// Operator ==. - bool operator==(const exact_t& rhs) const - { - return this->exact().impl_equal(rhs); - } + bool operator==(const E& rhs) const; template <typename P> - bool operator==(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_equal(rhs.exact()); - } + bool operator==(const abstract::point<P>& rhs) const; /// \} @@ -100,19 +90,10 @@ /// \{ /// Operator !=. - bool operator!=(const exact_t& rhs) const - { - return not (*this == rhs); - } + bool operator!=(const E& rhs) const; template <typename P> - bool operator!=(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return not (*this == rhs); - } + bool operator!=(const abstract::point<P>& rhs) const; /// \} @@ -120,19 +101,10 @@ /// \{ /// Operator <. - bool operator<(const exact_t& rhs) const - { - return this->exact().impl_less(rhs); - } + bool operator<(const E& rhs) const; template <typename P> - bool operator<(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_less(rhs.exact()); - } + bool operator<(const abstract::point<P>& rhs) const; /// \} @@ -140,19 +112,10 @@ /// \{ /// Operator >. - bool operator>(const exact_t& rhs) const - { - return rhs < *this; - } + bool operator>(const E& rhs) const; template <typename P> - bool operator>(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return rhs < *this; - } + bool operator>(const abstract::point<P>& rhs) const; /// \} @@ -160,19 +123,10 @@ /// \{ /// Operator >=. - bool operator>=(const exact_t& rhs) const - { - return not (*this < rhs); - } + bool operator>=(const E& rhs) const; template <typename P> - bool operator>=(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return not (*this < rhs); - } + bool operator>=(const abstract::point<P>& rhs) const; /// \} @@ -180,19 +134,10 @@ /// \{ /// Operator <=. - bool operator<=(const exact_t& rhs) const - { - return not (rhs < *this); - } + bool operator<=(const E& rhs) const; template <typename P> - bool operator<=(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return not (rhs < *this); - } + bool operator<=(const abstract::point<P>& rhs) const; /// \} @@ -200,19 +145,10 @@ /// \{ /// Operator +=. - exact_t& operator+=(const dpoint_t& rhs) - { - return this->exact().impl_plus_equal(rhs); - } + E& operator+=(const dpoint_t& rhs); template <typename D> - exact_t& operator+=(const abstract::dpoint<D>& rhs) - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(D, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_plus_equal(rhs.exact()); - } + E& operator+=(const abstract::dpoint<D>& rhs); /// \} @@ -220,19 +156,10 @@ /// \{ /// Operator +. - exact_t operator+(const dpoint_t& rhs) const - { - return this->exact().impl_plus(rhs); - } + E operator+(const dpoint_t& rhs) const; template <typename D> - xtd_op_plus_trait(E,D) operator+(const abstract::dpoint<D>& rhs) - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(D, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_plus(rhs.exact()); - } + xtd_op_plus_trait(E,D) operator+(const abstract::dpoint<D>& rhs) const; /// \} @@ -240,19 +167,10 @@ /// \{ /// Operator -=. - exact_t& operator-=(const dpoint_t& rhs) - { - return this->exact().impl_minus_equal(rhs); - } + E& operator-=(const dpoint_t& rhs); template <typename D> - exact_t& operator-=(const abstract::dpoint<D>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(D, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_minus_equal(rhs.exact()); - } + E& operator-=(const abstract::dpoint<D>& rhs) const; /// \} @@ -260,19 +178,10 @@ /// \{ /// Operator -. - exact_t operator-(const dpoint_t& rhs) const - { - return this->exact().impl_minus(rhs); - } + E operator-(const dpoint_t& rhs) const; template <typename D> - xtd_op_minus_trait(E, D) operator-(const abstract::dpoint<D>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(D, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_minus(rhs.exact()); - } + xtd_op_minus_trait(E, D) operator-(const abstract::dpoint<D>& rhs) const; /// \} @@ -280,39 +189,220 @@ /// \{ /// Operator -. - dpoint_t operator-(const exact_t& rhs) const - { - return this->exact().impl_minus(rhs); - } + dpoint_t operator-(const E& rhs) const; template <typename P> - xtd_op_minus_trait(E, P) operator-(const abstract::point<P>& rhs) const - { - mlc::assert_equal_< oln_type_of(E, grid), - oln_type_of(P, grid), - oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); - return this->exact().impl_minus(rhs.exact()); - } + xtd_op_minus_trait(E, P) operator-(const abstract::point<P>& rhs) const; /// \} - protected: - - point() - {} - ~point() { - mlc::assert_defined_< oln_type_of(E, grid) >::check(); - mlc::assert_defined_< oln_type_of(E, dpoint) >::check(); - mlc::assert_defined_< oln_type_of(E, coord) >::check(); - mlc::assert_defined_< oln_type_of(E, dim) >::check(); + // FIXME: See code below. } + protected: + + point(); + }; // end of class oln::abstract::point<E> +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool point<E>::operator==(const E& rhs) const + { + return this->exact().impl_equal(rhs); + } + + template <typename E> + template <typename P> + bool point<E>::operator==(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_equal(rhs.exact()); + } + + template <typename E> + bool point<E>::operator!=(const E& rhs) const + { + return not (*this == rhs); + } + + template <typename E> + template <typename P> + bool point<E>::operator!=(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return not (*this == rhs); + } + + template <typename E> + bool point<E>::operator<(const E& rhs) const + { + return this->exact().impl_less(rhs); + } + + template <typename E> + template <typename P> + bool point<E>::operator<(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_less(rhs.exact()); + } + + template <typename E> + bool point<E>::operator>(const E& rhs) const + { + return rhs < *this; + } + + template <typename E> + template <typename P> + bool point<E>::operator>(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return rhs < *this; + } + + template <typename E> + bool point<E>::operator>=(const E& rhs) const + { + return not (*this < rhs); + } + + template <typename E> + template <typename P> + bool point<E>::operator>=(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return not (*this < rhs); + } + + template <typename E> + bool point<E>::operator<=(const E& rhs) const + { + return not (rhs < *this); + } + + template <typename E> + template <typename P> + bool point<E>::operator<=(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return not (rhs < *this); + } + + template <typename E> + E& point<E>::operator+=(const typename point<E>::dpoint_t& rhs) + { + return this->exact().impl_plus_equal(rhs); + } + + template <typename E> + template <typename D> + E& point<E>::operator+=(const abstract::dpoint<D>& rhs) + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(D, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_plus_equal(rhs.exact()); + } + + template <typename E> + E point<E>::operator+(const typename point<E>::dpoint_t& rhs) const + { + return this->exact().impl_plus(rhs); + } + + template <typename E> + template <typename D> + xtd_op_plus_trait(E,D) point<E>::operator+(const abstract::dpoint<D>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(D, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_plus(rhs.exact()); + } + + template <typename E> + E& point<E>::operator-=(const typename point<E>::dpoint_t& rhs) + { + return this->exact().impl_minus_equal(rhs); + } + + template <typename E> + template <typename D> + E& point<E>::operator-=(const abstract::dpoint<D>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(D, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_minus_equal(rhs.exact()); + } + + template <typename E> + E point<E>::operator-(const typename point<E>::dpoint_t& rhs) const + { + return this->exact().impl_minus(rhs); + } + + template <typename E> + template <typename D> + xtd_op_minus_trait(E, D) point<E>::operator-(const abstract::dpoint<D>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(D, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_minus(rhs.exact()); + } + + template <typename E> + typename point<E>::dpoint_t point<E>::operator-(const E& rhs) const + { + return this->exact().impl_minus(rhs); + } + + template <typename E> + template <typename P> + xtd_op_minus_trait(E, P) point<E>::operator-(const abstract::point<P>& rhs) const + { + mlc::assert_equal_< oln_type_of(E, grid), + oln_type_of(P, grid), + oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check(); + return this->exact().impl_minus(rhs.exact()); + } + + template <typename E> + point<E>::point() + {} + +// template <typename E> +// point<E>::~point() +// { +// mlc::assert_defined_< oln_type_of(E, grid) >::check(); +// mlc::assert_defined_< oln_type_of(E, dpoint) >::check(); +// mlc::assert_defined_< oln_type_of(E, coord) >::check(); +// mlc::assert_defined_< oln_type_of(E, dim) >::check(); +// } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/bbox.hh =================================================================== --- oln/core/abstract/bbox.hh (revision 606) +++ oln/core/abstract/bbox.hh (working copy) @@ -45,32 +45,56 @@ { public: - void print(std::ostream& ostr) const - { - this->exact().impl_print(ostr); - } - - friend - std::ostream& operator<<(std::ostream& ostr, const abstract::bbox<E>& bb) - { - bb.print(ostr); - return ostr; - } + void print(std::ostream& ostr) const; - const E& impl_bbox() const + const E& impl_bbox() const; + + ~bbox() { - return this->exact(); } protected: - bbox() - { - } + bbox(); }; // end of class oln::abstract::bbox<E> +# ifndef OLN_INCLUDE_ONLY + + + template <typename E> + void bbox<E>::print(std::ostream& ostr) const + { + this->exact().impl_print(ostr); + } + + template <typename E> + std::ostream& operator<<(std::ostream& ostr, const abstract::bbox<E>& bb) + { + bb.print(ostr); + return ostr; + } + + template <typename E> + const E& bbox<E>::impl_bbox() const + { + return this->exact(); + } + + template <typename E> + bbox<E>::bbox() + { + } + +// template <typename E> +// bbox<E>::~bbox() +// { +// } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/point_set_being_connected.hh =================================================================== --- oln/core/abstract/point_set_being_connected.hh (revision 606) +++ oln/core/abstract/point_set_being_connected.hh (working copy) @@ -43,16 +43,11 @@ { public: - unsigned nindices() const - { - precondition(this->is_valid()); - return this->exact().len(0); - } + unsigned nindices() const; protected: - point_set_being_1d_connected() - {} + point_set_being_1d_connected(); }; @@ -61,54 +56,102 @@ { public: - unsigned nrows() const - { - precondition(this->is_valid()); - return this->exact().len(0); - } + unsigned nrows() const; - unsigned ncols() const - { - precondition(this->is_valid()); - return this->exact().len(1); - } + unsigned ncols() const; protected: - point_set_being_2d_connected() - {} + point_set_being_2d_connected(); + }; + template <typename E> class point_set_being_3d_connected : public virtual abstract::point_set<E> { public: - unsigned nslices() const - { - precondition(this->is_valid()); - return this->exact().len(0); - } + unsigned nslices() const; - unsigned nrows() const - { - precondition(this->is_valid()); - return this->exact().len(1); - } + unsigned nrows() const; - unsigned ncols() const - { - precondition(this->is_valid()); - return this->exact().len(2); - } + unsigned ncols() const; protected: - point_set_being_3d_connected() - {} + point_set_being_3d_connected(); + }; + +# ifndef OLN_INCLUDE_ONLY + + + template <typename E> + unsigned point_set_being_1d_connected<E>::nindices() const + { + precondition(this->is_valid()); + return this->exact().len(0); + } + + template <typename E> + point_set_being_1d_connected<E>::point_set_being_1d_connected() + { + } + + + template <typename E> + unsigned point_set_being_2d_connected<E>::nrows() const + { + precondition(this->is_valid()); + return this->exact().len(0); + } + + template <typename E> + unsigned point_set_being_2d_connected<E>::ncols() const + { + precondition(this->is_valid()); + return this->exact().len(1); + } + + template <typename E> + point_set_being_2d_connected<E>::point_set_being_2d_connected() + { + } + + + template <typename E> + unsigned point_set_being_3d_connected<E>::nslices() const + { + precondition(this->is_valid()); + return this->exact().len(0); + } + + template <typename E> + unsigned point_set_being_3d_connected<E>::nrows() const + { + precondition(this->is_valid()); + return this->exact().len(1); + } + + template <typename E> + unsigned point_set_being_3d_connected<E>::ncols() const + { + precondition(this->is_valid()); + return this->exact().len(2); + } + + template <typename E> + point_set_being_3d_connected<E>::point_set_being_3d_connected() + { + } + + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/dpoint.hh =================================================================== --- oln/core/abstract/dpoint.hh (revision 606) +++ oln/core/abstract/dpoint.hh (working copy) @@ -72,35 +72,66 @@ { public: - bool operator==(const abstract::dpoint<E>& rhs) const - { - return this->exact().impl_eq(rhs.exact()); - } + bool operator==(const abstract::dpoint<E>& rhs) const; + bool operator!=(const abstract::dpoint<E>& rhs) const; - bool operator!=(const abstract::dpoint<E>& rhs) const { return not (*this == rhs); } + bool operator< (const abstract::dpoint<E>& rhs) const; + bool operator> (const abstract::dpoint<E>& rhs) const; + bool operator>=(const abstract::dpoint<E>& rhs) const; + bool operator<=(const abstract::dpoint<E>& rhs) const; - bool operator<(const abstract::dpoint<E>& rhs) const + ~dpoint() { - return this->exact().impl_less(rhs.exact()); + // FIXME: Code is below. } - bool operator> (const abstract::dpoint<E>& rhs) const { return rhs < *this; } - bool operator>=(const abstract::dpoint<E>& rhs) const { return not (*this < rhs); } - bool operator<=(const abstract::dpoint<E>& rhs) const { return not (rhs < *this); } - protected: - dpoint() - {} - ~dpoint() { - mlc::assert_defined_< oln_type_of(E, grid) >::check(); - mlc::assert_defined_< oln_type_of(E, point) >::check(); - mlc::assert_defined_< oln_type_of(E, coord) >::check(); - mlc::assert_defined_< oln_type_of(E, dim) >::check(); - } + dpoint(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool dpoint<E>::operator==(const abstract::dpoint<E>& rhs) const + { + return this->exact().impl_eq(rhs.exact()); + } + + template <typename E> + bool dpoint<E>::operator!=(const abstract::dpoint<E>& rhs) const { return not (*this == rhs); } + + template <typename E> + bool dpoint<E>::operator<(const abstract::dpoint<E>& rhs) const + { + return this->exact().impl_less(rhs.exact()); + } + + template <typename E> + bool dpoint<E>::operator> (const abstract::dpoint<E>& rhs) const { return rhs < *this; } + + template <typename E> + bool dpoint<E>::operator>=(const abstract::dpoint<E>& rhs) const { return not (*this < rhs); } + + template <typename E> + bool dpoint<E>::operator<=(const abstract::dpoint<E>& rhs) const { return not (rhs < *this); } + + template <typename E> + dpoint<E>::dpoint() + {} + +// template <typename E> +// dpoint<E>::~dpoint() { +// mlc::assert_defined_< oln_type_of(E, grid) >::check(); +// mlc::assert_defined_< oln_type_of(E, point) >::check(); +// mlc::assert_defined_< oln_type_of(E, coord) >::check(); +// mlc::assert_defined_< oln_type_of(E, dim) >::check(); +// } + +# endif + + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/topology_being_random_accessible.hh =================================================================== --- oln/core/abstract/topology_being_random_accessible.hh (revision 606) +++ oln/core/abstract/topology_being_random_accessible.hh (working copy) @@ -47,23 +47,39 @@ public: - bool has(const point_t& p) const - { - return this->exact().impl_has(p); - } + bool has(const point_t& p) const; - bool has_large(const point_t& p) const - { - return this->exact().impl_has_large(p); - } + bool has_large(const point_t& p) const; protected: - topology_being_random_accessible() - {} + topology_being_random_accessible(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool topology_being_random_accessible<E>::has(const oln_type_of(E, point)& p) const + { + return this->exact().impl_has(p); + } + + template <typename E> + bool topology_being_random_accessible<E>::has_large(const oln_type_of(E, point)& p) const + { + return this->exact().impl_has_large(p); + } + + template <typename E> + topology_being_random_accessible<E>::topology_being_random_accessible() + { + } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/topology_having_subset.hh =================================================================== --- oln/core/abstract/topology_having_subset.hh (revision 607) +++ oln/core/abstract/topology_having_subset.hh (working copy) @@ -48,18 +48,30 @@ public: // abstract - const subset_t& subset() const - { - return this->exact().impl_subset(); - } + const subset_t& subset() const; protected: - topology_having_subset() - {} + topology_having_subset(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const oln_type_of(E, subset)& + topology_having_subset<E>::subset() const + { + return this->exact().impl_subset(); + } + + template <typename E> + topology_having_subset<E>::topology_having_subset() + {} + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/topology_having_neighborhood.hh =================================================================== --- oln/core/abstract/topology_having_neighborhood.hh (revision 606) +++ oln/core/abstract/topology_having_neighborhood.hh (working copy) @@ -48,24 +48,41 @@ public: // abstract - const neighborhood_t& neighborhood() const - { - return this->exact().impl_neighborhood(); - } + const neighborhood_t& neighborhood() const; // concrete - operator neighborhood_t() const - { - return this->neighborhood(); - } + operator neighborhood_t() const; protected: - topology_having_neighborhood() - {} + topology_having_neighborhood(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const oln_type_of(E, neighborhood)& + topology_having_neighborhood<E>::neighborhood() const + { + return this->exact().impl_neighborhood(); + } + + template <typename E> + topology_having_neighborhood<E>::operator oln_type_of(E, neighborhood)() const + { + return this->neighborhood(); + } + + template <typename E> + topology_having_neighborhood<E>::topology_having_neighborhood() + { + } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/entry.hh =================================================================== --- oln/core/abstract/entry.hh (revision 606) +++ oln/core/abstract/entry.hh (working copy) @@ -93,8 +93,21 @@ typename mlc::is_defined_< oln::case_< oln::hierarchy<abstraction, num>, E, 1 > >::eval > { + ~entry_node(); }; + +# ifndef OLN_INCLUDE_ONLY + + template < template <class> class abstraction, + typename E, + unsigned num > + entry_node<abstraction, E, num>::~entry_node() + { + } + +# endif + } // end of namespace oln::internal @@ -114,13 +127,29 @@ typename E > struct entry : public internal::entry_node<abstraction, E, 1> { + ~entry(); protected: - entry() - { - } + entry(); }; +# ifndef OLN_INCLUDE_ONLY + + template < template <class> class abstraction, + typename E > + entry<abstraction, E>::entry() + { + } + + template < template <class> class abstraction, + typename E > + entry<abstraction, E>::~entry() + { + } + +# endif + + // Super type declaration. template < template <class> class abstraction, typename E > Index: oln/core/abstract/point_set.hh =================================================================== --- oln/core/abstract/point_set.hh (revision 606) +++ oln/core/abstract/point_set.hh (working copy) @@ -45,10 +45,7 @@ { public: - bool is_valid() const - { - return this->exact().impl_is_valid(); - } + bool is_valid() const; struct decl { @@ -68,26 +65,52 @@ stc_virtual_typedef(grid); stc_virtual_typedef(dim); - decl() { - // coherence check: - mlc::assert_equal_< oln_type_of(fwd_piter, grid), - oln_type_of(point, grid) >::check(); - mlc::assert_equal_< oln_type_of(bkd_piter, grid), - oln_type_of(point, grid) >::check(); - } + decl(); }; + ~point_set() + { + } + protected: - point_set() - {} + point_set(); - ~point_set() { decl(); } - }; // end of class oln::abstract::point_set<E> +# ifndef OLN_INCLUDE_ONLY + template <typename E> + bool point_set<E>::is_valid() const + { + return this->exact().impl_is_valid(); + } + + template <typename E> + point_set<E>::decl::decl() + { + // coherence check: + mlc::assert_equal_< oln_type_of(fwd_piter, grid), + oln_type_of(point, grid) >::check(); + mlc::assert_equal_< oln_type_of(bkd_piter, grid), + oln_type_of(point, grid) >::check(); + } + + template <typename E> + point_set<E>::point_set() + { + } + +// template <typename E> +// point_set<E>::~point_set() +// { +// decl(); +// } + +# endif + + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/point_set_having_known_size.hh =================================================================== --- oln/core/abstract/point_set_having_known_size.hh (revision 606) +++ oln/core/abstract/point_set_having_known_size.hh (working copy) @@ -44,17 +44,30 @@ { public: - unsigned npoints() const - { - return this->exact().impl_npoints(); - } + unsigned npoints() const; protected: - point_set_having_known_size() - {} + point_set_having_known_size(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + unsigned + point_set_having_known_size<E>::npoints() const + { + return this->exact().impl_npoints(); + } + + template <typename E> + point_set_having_known_size<E>::point_set_having_known_size() + { + } + +# endif + + } // end of namespace oln::abstract Index: oln/core/abstract/neighborhood.hh =================================================================== --- oln/core/abstract/neighborhood.hh (revision 606) +++ oln/core/abstract/neighborhood.hh (working copy) @@ -45,30 +45,51 @@ { public: - bool is_valid() const - { - return this->exact().impl_is_valid(); - } + bool is_valid() const; struct decl { stc_virtual_typedef(grid); - decl() { - } + decl(); }; protected: - neighborhood() - {} + neighborhood(); + ~neighborhood(); - ~neighborhood() { decl(); } - }; // end of class oln::abstract::neighborhood<E> +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool neighborhood<E>::is_valid() const + { + return this->exact().impl_is_valid(); + } + + template <typename E> + neighborhood<E>::neighborhood() + { + } + + template <typename E> + neighborhood<E>::~neighborhood() + { + decl(); + } + + template <typename E> + neighborhood<E>::decl::decl() + { + } + +# endif + + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/abstract/point_set_having_bbox.hh =================================================================== --- oln/core/abstract/point_set_having_bbox.hh (revision 606) +++ oln/core/abstract/point_set_having_bbox.hh (working copy) @@ -50,52 +50,82 @@ public: - const bbox_t& bbox() const - { - return this->exact().impl_box(); - } + const bbox_t& bbox() const; - // FIXME: attributes should be removed from this abstract class. + const point_t& pmin() const; - const point_t& pmin() const - { - precondition(this->is_valid()); - return pmin_; - } + coord_t pmin(unsigned i) const; - coord_t pmin(unsigned i) const - { - precondition(this->is_valid() and i < n); - return pmin_[i]; - } + const point_t& pmax() const; - const point_t& pmax() const - { - precondition(this->is_valid()); - return pmax_; - } + coord_t pmax(unsigned i) const; - coord_t pmax(unsigned i) const - { - precondition(this->is_valid() and i < n); - return pmax_[i]; - } + unsigned len(unsigned i) const; - unsigned len(unsigned i) const - { - precondition(this->is_valid() and i < n); - return pmax_[i] - pmin_[i] + 1; - } - protected: - point_set_having_bbox() - {} + point_set_having_bbox(); point_t pmin_, pmax_; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + const typename point_set_having_bbox<E>::bbox_t& + point_set_having_bbox<E>::bbox() const + { + return this->exact().impl_box(); + } + + template <typename E> + const typename point_set_having_bbox<E>::point_t& + point_set_having_bbox<E>::pmin() const + { + precondition(this->is_valid()); + return pmin_; + } + + template <typename E> + typename point_set_having_bbox<E>::coord_t + point_set_having_bbox<E>::pmin(unsigned i) const + { + precondition(this->is_valid() and i < n); + return pmin_[i]; + } + + template <typename E> + const typename point_set_having_bbox<E>::point_t& + point_set_having_bbox<E>::pmax() const + { + precondition(this->is_valid()); + return pmax_; + } + + template <typename E> + typename point_set_having_bbox<E>::coord_t + point_set_having_bbox<E>::pmax(unsigned i) const + { + precondition(this->is_valid() and i < n); + return pmax_[i]; + } + + template <typename E> + unsigned + point_set_having_bbox<E>::len(unsigned i) const + { + precondition(this->is_valid() and i < n); + return pmax_[i] - pmin_[i] + 1; + } + + template <typename E> + point_set_having_bbox<E>::point_set_having_bbox() + {} + +# endif + } // end of namespace oln::abstract Index: oln/core/abstract/topology.hh =================================================================== --- oln/core/abstract/topology.hh (revision 606) +++ oln/core/abstract/topology.hh (working copy) @@ -59,24 +59,43 @@ stc_virtual_typedef(morpher); - decl() { - // constraint: -// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >, -// mlc_is_a(bbox, abstract::bbox) > >::check(); - } + decl(); }; protected: - topology() - {} + topology(); - ~topology() { decl(); } + ~topology(); }; // end of class oln::abstract::topology<E> +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + topology<E>::decl::decl() + { + // constraint: +// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >, +// mlc_is_a(bbox, abstract::bbox) > >::check(); + } + + template <typename E> + topology<E>::topology() + { + } + + template <typename E> + topology<E>::~topology() + { + decl(); + } + +# endif + + } // end of namespace oln::abstract } // end of namespace oln Index: oln/core/2d/neighb2d.hh =================================================================== --- oln/core/2d/neighb2d.hh (revision 607) +++ oln/core/2d/neighb2d.hh (working copy) @@ -40,71 +40,71 @@ namespace internal { + neighb2d mk_c4(); + neighb2d mk_c8(); + neighb2d mk_c2_row(); + neighb2d mk_c2_col(); + + +# ifndef OLN_INCLUDE_ONLY + neighb2d mk_c4() { - static bool flower = true; - static neighb2d the_; - if (flower) - { - the_ - .add(dpoint2d(0, 1)) - .add(dpoint2d(1, 0)); - flower = false; - } + neighb2d the_; + the_ + .add(dpoint2d(0, 1)) + .add(dpoint2d(1, 0)); return the_; } neighb2d mk_c8() { - static bool flower = true; - static neighb2d the_; - if (flower) - { - the_ - .add(dpoint2d(0, 1)) - .add(dpoint2d(1,-1)) - .add(dpoint2d(1, 0)) - .add(dpoint2d(1, 1)); - flower = false; - } + neighb2d the_; + the_ + .add(dpoint2d(0, 1)) + .add(dpoint2d(1,-1)) + .add(dpoint2d(1, 0)) + .add(dpoint2d(1, 1)); return the_; } neighb2d mk_c2_row() { - static bool flower = true; - static neighb2d the_; - if (flower) - { - the_ - .add(dpoint2d(0, 1)); - flower = false; - } + neighb2d the_; + the_ + .add(dpoint2d(0, 1)); return the_; } neighb2d mk_c2_col() { - static bool flower = true; - static neighb2d the_; - if (flower) - { - the_ - .add(dpoint2d(1, 0)); - flower = false; - } + neighb2d the_; + the_ + .add(dpoint2d(1, 0)); return the_; } +# endif + } // end of namespace oln::internal - static const neighb2d c4 = internal::mk_c4(); - static const neighb2d c8 = internal::mk_c8(); - static const neighb2d c2r = internal::mk_c2_row(); - static const neighb2d c2c = internal::mk_c2_col(); + extern const neighb2d c4; + extern const neighb2d c8; + extern const neighb2d c2r; + extern const neighb2d c2c; +# ifndef OLN_INCLUDE_ONLY + + const neighb2d c4 = internal::mk_c4(); + const neighb2d c8 = internal::mk_c8(); + const neighb2d c2r = internal::mk_c2_row(); + const neighb2d c2c = internal::mk_c2_col(); + +# endif + + } // end of namespace oln Index: oln/core/2d/dpoint2d.hh =================================================================== --- oln/core/2d/dpoint2d.hh (revision 606) +++ oln/core/2d/dpoint2d.hh (working copy) @@ -64,37 +64,63 @@ { typedef dpoint2d_<C> self_t; typedef stc_get_super(dpoint2d_<C>) super_t; - typedef oln_type_of(self_t, coord) coord_t; using super_t::v_; public: /// Ctor. - dpoint2d_() - { - } + dpoint2d_(); /// Ctor. - dpoint2d_(const xtd::vec<2,coord_t>& v) - : super_t(v) - { - } + dpoint2d_(const xtd::vec<2,C>& v); /// Ctor. - dpoint2d_(coord_t row, coord_t col) - : super_t(xtd::mk_vec(row, col)) - { - } + dpoint2d_(C row, C col); - coord_t row() const { return v_[0]; } - coord_t& row() { return v_[0]; } + C row() const; + C& row(); - coord_t col() const { return v_[1]; } - coord_t& col() { return v_[1]; } + C col() const; + C& col(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename C> + dpoint2d_<C>::dpoint2d_() + { + } + + /// Ctor. + template <typename C> + dpoint2d_<C>::dpoint2d_(const xtd::vec<2,C>& v) + : super_t(v) + { + } + + /// Ctor. + template <typename C> + dpoint2d_<C>::dpoint2d_(C row, C col) + : super_t(xtd::mk_vec(row, col)) + { + } + + template <typename C> + C dpoint2d_<C>::row() const { return v_[0]; } + + template <typename C> + C& dpoint2d_<C>::row() { return v_[0]; } + + template <typename C> + C dpoint2d_<C>::col() const { return v_[1]; } + + template <typename C> + C& dpoint2d_<C>::col() { return v_[1]; } + +# endif + } // end of namespace oln Index: oln/core/2d/array2d.hh =================================================================== --- oln/core/2d/array2d.hh (revision 606) +++ oln/core/2d/array2d.hh (working copy) @@ -44,65 +44,21 @@ /// Ctor. array2d(coord_t imin, coord_t jmin, - coord_t imax, coord_t jmax) : - imin_(imin), - jmin_(jmin), - imax_(imax), - jmax_(jmax) - { - precondition(imax >= imin and jmax >= jmin); - ilen_ = imax - imin + 1; - jlen_ = jmax - jmin + 1; - allocate_(); - } + coord_t imax, coord_t jmax); /// Ctor. - array2d(coord_t ilen, coord_t jlen) : - imin_(0), - jmin_(0), - ilen_(ilen), - jlen_(jlen) - { - precondition(ilen > 0 and jlen > 0); - imax_ = imin_ + ilen_; - jmax_ = jmin_ + ilen_; - allocate_(); - } + array2d(coord_t ilen, coord_t jlen); /// Dtor. - ~array2d() - { - deallocate_(); - } + ~array2d(); - value_t operator()(coord_t i, coord_t j) const - { - precondition(has(i, j)); - return array_[i][j]; - } + value_t operator()(coord_t i, coord_t j) const; - value_t& operator()(coord_t i, coord_t j) - { - precondition(has(i, j)); - return array_[i][j]; - } + value_t& operator()(coord_t i, coord_t j); - bool has(coord_t i, coord_t j) const - { - return - i >= imin_ and i <= imax_ and - j >= jmin_ and j <= jmax_; - } + bool has(coord_t i, coord_t j) const; - size_t memsize() const - { - return - // buffer_ - size_t(ilen_) * size_t(jlen_) * sizeof(value_t) - + - // array_ - size_t(ilen_) * sizeof(value_t*); - } + size_t memsize() const; protected: @@ -113,31 +69,112 @@ private: - void allocate_() - { - buffer_ = new value_t[size_t(ilen_) * size_t(jlen_)]; - array_ = new value_t*[size_t(ilen_)]; - value_t* buf = buffer_ - jmin_; - for (coord_t i = 0; i < ilen_; ++i) - { - array_[i] = buf; - buf += jlen_; - } - array_ -= imin_; - } + void allocate_(); - void deallocate_() - { - precondition(buffer_ != 0 and array_ != 0); - delete[] buffer_; - buffer_ = 0; // safety - array_ += imin_; - delete[] array_; - array_ = 0; // safety - } + void deallocate_(); }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename value_t, typename coord_t> + array2d<value_t, coord_t>::array2d(coord_t imin, coord_t jmin, + coord_t imax, coord_t jmax) : + imin_(imin), + jmin_(jmin), + imax_(imax), + jmax_(jmax) + { + precondition(imax >= imin and jmax >= jmin); + ilen_ = imax - imin + 1; + jlen_ = jmax - jmin + 1; + allocate_(); + } + + template <typename value_t, typename coord_t> + /// Ctor. + array2d<value_t, coord_t>::array2d(coord_t ilen, coord_t jlen) : + imin_(0), + jmin_(0), + ilen_(ilen), + jlen_(jlen) + { + precondition(ilen > 0 and jlen > 0); + imax_ = imin_ + ilen_; + jmax_ = jmin_ + ilen_; + allocate_(); + } + + template <typename value_t, typename coord_t> + /// Dtor. + array2d<value_t, coord_t>::~array2d() + { + deallocate_(); + } + + template <typename value_t, typename coord_t> + value_t array2d<value_t, coord_t>::operator()(coord_t i, coord_t j) const + { + precondition(has(i, j)); + return array_[i][j]; + } + + template <typename value_t, typename coord_t> + value_t& array2d<value_t, coord_t>::operator()(coord_t i, coord_t j) + { + precondition(has(i, j)); + return array_[i][j]; + } + + template <typename value_t, typename coord_t> + bool array2d<value_t, coord_t>::has(coord_t i, coord_t j) const + { + return + i >= imin_ and i <= imax_ and + j >= jmin_ and j <= jmax_; + } + + template <typename value_t, typename coord_t> + size_t array2d<value_t, coord_t>::memsize() const + { + return + // buffer_ + size_t(ilen_) * size_t(jlen_) * sizeof(value_t) + + + // array_ + size_t(ilen_) * sizeof(value_t*); + } + + template <typename value_t, typename coord_t> + void array2d<value_t, coord_t>::allocate_() + { + buffer_ = new value_t[size_t(ilen_) * size_t(jlen_)]; + array_ = new value_t*[size_t(ilen_)]; + value_t* buf = buffer_ - jmin_; + for (coord_t i = 0; i < ilen_; ++i) + { + array_[i] = buf; + buf += jlen_; + } + array_ -= imin_; + } + + template <typename value_t, typename coord_t> + void array2d<value_t, coord_t>::deallocate_() + { + precondition(buffer_ != 0 and array_ != 0); + delete[] buffer_; + buffer_ = 0; // safety + array_ += imin_; + delete[] array_; + array_ = 0; // safety + } + +# endif + + } // end of namespace oln Index: oln/core/2d/image2d.hh =================================================================== --- oln/core/2d/image2d.hh (revision 607) +++ oln/core/2d/image2d.hh (working copy) @@ -78,43 +78,16 @@ public: /// Ctor using sizes. - image2d(unsigned nrows, unsigned ncols, unsigned border = 2) - : topo_(bbox2d(point2d(0, 0 ), - point2d(nrows - 1, ncols - 1)), - border), - data_(new array_t(0 - border, 0 - border, - nrows - 1 + border, ncols - 1 + border)) - { - } + image2d(unsigned nrows, unsigned ncols, unsigned border = 2); /// Ctor using an existing topology. - image2d(const topo2d& topo) - : topo_(topo), - data_(new array_t(topo.bbox().pmin().row(), - topo.bbox().pmin().col(), - topo.bbox().pmax().row(), - topo.bbox().pmax().col())) - { - } + image2d(const topo2d& topo); - const topo2d& impl_topo() const - { - return topo_; - } + const topo2d& impl_topo() const; - T impl_op_read(const point2d& p) const - { - precondition(data_ != 0); - precondition(topo_.has_large(p)); - return data_->operator()(p.row(), p.col()); - } + T impl_op_read(const point2d& p) const; - T& impl_op_readwrite(const point2d& p) - { - precondition(data_ != 0); - precondition(topo_.has_large(p)); - return data_->operator()(p.row(), p.col()); - } + T& impl_op_readwrite(const point2d& p); private: @@ -123,6 +96,55 @@ }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename T> + image2d<T>::image2d(unsigned nrows, unsigned ncols, unsigned border) + : topo_(bbox2d(point2d(0, 0 ), + point2d(nrows - 1, ncols - 1)), + border), + data_(new array_t(0 - border, 0 - border, + nrows - 1 + border, ncols - 1 + border)) + { + } + + /// Ctor using an existing topology. + template <typename T> + image2d<T>::image2d(const topo2d& topo) + : topo_(topo), + data_(new array_t(topo.bbox().pmin().row(), + topo.bbox().pmin().col(), + topo.bbox().pmax().row(), + topo.bbox().pmax().col())) + { + } + + template <typename T> + const topo2d& image2d<T>::impl_topo() const + { + return topo_; + } + + template <typename T> + T image2d<T>::impl_op_read(const point2d& p) const + { + precondition(data_ != 0); + precondition(topo_.has_large(p)); + return data_->operator()(p.row(), p.col()); + } + + template <typename T> + T& image2d<T>::impl_op_readwrite(const point2d& p) + { + precondition(data_ != 0); + precondition(topo_.has_large(p)); + return data_->operator()(p.row(), p.col()); + } + +# endif + } // end of namespace oln Index: oln/core/2d/point2d.hh =================================================================== --- oln/core/2d/point2d.hh (revision 606) +++ oln/core/2d/point2d.hh (working copy) @@ -72,37 +72,72 @@ { typedef point2d_<C> self_t; typedef stc_get_super(point2d_<C>) super_t; - typedef oln_type_of(self_t, coord) coord_t; using super_t::v_; public: /// Ctor. - point2d_() - { - } + point2d_(); /// Ctor. - point2d_(coord_t row, coord_t col) - : super_t (xtd::mk_vec(row, col)) - { - } + point2d_(C row, C col); /// Ctor. - point2d_(const xtd::vec<2,coord_t>& v) - : super_t(v) + point2d_(const xtd::vec<2,C>& v); + + ///Dtor. + ~point2d_() { } - coord_t row() const { return v_[0]; } - coord_t& row() { return v_[0]; } + C row() const; + C& row(); - coord_t col() const { return v_[1]; } - coord_t& col() { return v_[1]; } + C col() const; + C& col(); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename C> + point2d_<C>::point2d_() + { + } + + template <typename C> + point2d_<C>::point2d_(C row, C col) + : super_t (xtd::mk_vec(row, col)) + { + } + + template <typename C> + point2d_<C>::point2d_(const xtd::vec<2,C>& v) + : super_t(v) + { + } + +// template <typename C> +// point2d_<C>::~point2d_() +// { +// } + + template <typename C> + C point2d_<C>::row() const { return v_[0]; } + + template <typename C> + C& point2d_<C>::row() { return v_[0]; } + + template <typename C> + C point2d_<C>::col() const { return v_[1]; } + + template <typename C> + C& point2d_<C>::col() { return v_[1]; } + +# endif + } // end of namespace oln # include <oln/core/2d/dpoint2d.hh> Index: oln/core/gen/piter_isubset.hh =================================================================== --- oln/core/gen/piter_isubset.hh (revision 607) +++ oln/core/gen/piter_isubset.hh (working copy) @@ -74,67 +74,108 @@ public: template <typename T> - piter_isubset_(const abstract::topology<T>& topo) - : p_(topo), - isubset_(topo.exact().subset()) - { - } - + piter_isubset_(const abstract::topology<T>& topo); + template <typename P, typename T> - piter_isubset_(const P& p, const abstract::topology<T>& topo) - : p_(p, topo), - isubset_(topo.exact().subset()) - { - } + piter_isubset_(const P& p, const abstract::topology<T>& topo); - void impl_start() - { - p_.start(); - while (p_.is_valid() and isubset_(p_) == false) - p_.next(); - } + void impl_start(); - void impl_next() - { - do - p_.next(); - while (p_.is_valid() and isubset_(p_) == false); - } + void impl_next(); - void impl_invalidate() - { - p_.invalidate(); - } + void impl_invalidate(); - bool impl_is_valid() const - { - return p_.is_valid(); - } + bool impl_is_valid() const; - point_t impl_to_point() const - { - return p_.to_point(); - } - - const point_t* impl_point_adr() const - { - return p_.point_adr(); - } + point_t impl_to_point() const; - const topo_t topo() const - { - topo_t tmp(p_.topo(), isubset_); - return tmp; - } + const point_t* impl_point_adr() const; + const topo_t topo() const; + protected: piter_t p_; const isubset_t& isubset_; }; // end of class oln::piter_isubset_<point> - + + +# ifndef OLN_INCLUDE_ONLY + + template <typename piter_t, typename isubset_t> + template <typename T> + piter_isubset_<piter_t, isubset_t>::piter_isubset_(const abstract::topology<T>& topo) + : p_(topo), + isubset_(topo.exact().subset()) + { + } + + template <typename piter_t, typename isubset_t> + template <typename P, typename T> + piter_isubset_<piter_t, isubset_t>::piter_isubset_(const P& p, const abstract::topology<T>& topo) + : p_(p, topo), + isubset_(topo.exact().subset()) + { + } + + template <typename piter_t, typename isubset_t> + void + piter_isubset_<piter_t, isubset_t>::impl_start() + { + p_.start(); + while (p_.is_valid() and isubset_(p_) == false) + p_.next(); + } + + template <typename piter_t, typename isubset_t> + void + piter_isubset_<piter_t, isubset_t>::impl_next() + { + do + p_.next(); + while (p_.is_valid() and isubset_(p_) == false); + } + + template <typename piter_t, typename isubset_t> + void + piter_isubset_<piter_t, isubset_t>::impl_invalidate() + { + p_.invalidate(); + } + + template <typename piter_t, typename isubset_t> + bool + piter_isubset_<piter_t, isubset_t>::impl_is_valid() const + { + return p_.is_valid(); + } + + template <typename piter_t, typename isubset_t> + typename piter_isubset_<piter_t, isubset_t>::point_t + piter_isubset_<piter_t, isubset_t>::impl_to_point() const + { + return p_.to_point(); + } + + template <typename piter_t, typename isubset_t> + const typename piter_isubset_<piter_t, isubset_t>::point_t* + piter_isubset_<piter_t, isubset_t>::impl_point_adr() const + { + return p_.point_adr(); + } + + template <typename piter_t, typename isubset_t> + const typename piter_isubset_<piter_t, isubset_t>::topo_t + piter_isubset_<piter_t, isubset_t>::topo() const + { + topo_t tmp(p_.topo(), isubset_); + return tmp; + } + +# endif + } // end of namespace oln Index: oln/core/gen/topo_add_isubset.hh =================================================================== --- oln/core/gen/topo_add_isubset.hh (revision 607) +++ oln/core/gen/topo_add_isubset.hh (working copy) @@ -67,41 +67,20 @@ public: - topo_add_isubset() - { - } + topo_add_isubset(); - topo_add_isubset(const topo_t& topo, const isubset_t& isubset) - : topo_(topo), - isubset_(isubset) - { - } + topo_add_isubset(const topo_t& topo, const isubset_t& isubset); - bool impl_has(const point_t& p) const - { - return topo_.has(p) and isubset_(p) == true; - } - - bool impl_has_large(const point_t& p) const - { - return topo_.has(p) and isubset_(p) == true; - } + bool impl_has(const point_t& p) const; - const topo_t& delegate() const - { - return topo_; - } + bool impl_has_large(const point_t& p) const; - const isubset_t& impl_subset() const - { - return isubset_; - } + const topo_t& delegate() const; - operator topo_t() const - { - return topo_; - } + const isubset_t& impl_subset() const; + operator topo_t() const; + protected: topo_t topo_; @@ -109,6 +88,57 @@ }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename topo_t, typename isubset_t> + topo_add_isubset<topo_t, isubset_t>::topo_add_isubset() + { + } + + template <typename topo_t, typename isubset_t> + topo_add_isubset<topo_t, isubset_t>::topo_add_isubset(const topo_t& topo, const isubset_t& isubset) + : topo_(topo), + isubset_(isubset) + { + } + + template <typename topo_t, typename isubset_t> + bool + topo_add_isubset<topo_t, isubset_t>::impl_has(const point_t& p) const + { + return topo_.has(p) and isubset_(p) == true; + } + + template <typename topo_t, typename isubset_t> + bool + topo_add_isubset<topo_t, isubset_t>::impl_has_large(const point_t& p) const + { + return topo_.has(p) and isubset_(p) == true; + } + + template <typename topo_t, typename isubset_t> + const topo_t& + topo_add_isubset<topo_t, isubset_t>::delegate() const + { + return topo_; + } + + template <typename topo_t, typename isubset_t> + const isubset_t& + topo_add_isubset<topo_t, isubset_t>::impl_subset() const + { + return isubset_; + } + + template <typename topo_t, typename isubset_t> + topo_add_isubset<topo_t, isubset_t>::operator topo_t() const + { + return topo_; + } + +# endif + } // end of namespace oln Index: oln/core/gen/bbox.hh =================================================================== --- oln/core/gen/bbox.hh (revision 606) +++ oln/core/gen/bbox.hh (working copy) @@ -37,29 +37,29 @@ { // Forward declarations. - template <typename point> class bbox_; - template <typename point> class bbox_fwd_piter_; - template <typename point> class bbox_bkd_piter_; + template <typename point_t> class bbox_; + template <typename point_t> class bbox_fwd_piter_; + template <typename point_t> class bbox_bkd_piter_; // Super type declaration. - template <typename point> - struct set_super_type< bbox_<point> > + template <typename point_t> + struct set_super_type< bbox_<point_t> > { - typedef bbox_<point> self_t; + typedef bbox_<point_t> self_t; typedef point_set_entry<self_t> ret; }; - /// Virtual types associated to oln::bbox_<point>. - template <typename point> - struct vtypes< bbox_<point> > + /// Virtual types associated to oln::bbox_<point_t>. + template <typename point_t> + struct vtypes< bbox_<point_t> > { - typedef point point_type; - typedef bbox_fwd_piter_<point> fwd_piter_type; - typedef bbox_bkd_piter_<point> bkd_piter_type; + typedef point_t point_type; + typedef bbox_fwd_piter_<point_t> fwd_piter_type; + typedef bbox_bkd_piter_<point_t> bkd_piter_type; - typedef bbox_<point> bbox_type; + typedef bbox_<point_t> bbox_type; typedef mlc::true_ is_random_accessible_type; typedef mlc::true_ has_know_size_type; @@ -68,153 +68,197 @@ /// Bounding box class based on a point class. - template <typename point> - class bbox_ : public point_set_entry< bbox_<point> >, - private mlc::assert_< mlc_is_a(point, abstract::point) > + template <typename point_t> + class bbox_ : public point_set_entry< bbox_<point_t> >, + private mlc::assert_< mlc_is_a(point_t, abstract::point) > { - typedef point point_t; - typedef bbox_<point> self_t; + typedef bbox_<point_t> self_t; typedef point_set_entry<self_t> super_t; - typedef oln_type_of(point, coord) coord_t; + typedef oln_type_of(point_t, coord) coord_t; typedef oln_type_of(point_t, dim) dim; enum { n = mlc_value(dim) }; public: - bbox_() - { - flush(); - } + bbox_(); - bbox_(const point_t& pmin, const point_t& pmax) - { - this->pmin_ = pmin; - this->pmax_ = pmax; - is_valid_ = true; + bbox_(const point_t& pmin, const point_t& pmax); - for (unsigned i = 0; i < n; ++i) - precondition(pmax[i] >= pmin[i]); - } + bbox_(const bbox_<point_t>& rhs); - bbox_(const self_t& rhs) - { - // FIXME: Remove these 3 lines? - precondition(rhs.is_valid()); - for (unsigned i = 0; i < n; ++i) - precondition(rhs.pmax_[i] >= rhs.pmin_[i]); + bbox_<point_t>& operator=(const bbox_<point_t>& rhs); - this->pmin_ = rhs.pmin_; - this->pmax_ = rhs.pmax_; - is_valid_ = rhs.is_valid_; + unsigned impl_npoints() const; - for (unsigned i = 0; i < n; ++i) - postcondition(this->pmax_[i] >= this->pmin_[i]); - } + bool impl_has(const point_t& p) const; - self_t& operator=(const self_t& rhs) - { - // FIXME: Remove these 3 lines? - precondition(rhs.is_valid()); - for (unsigned i = 0; i < n; ++i) - precondition(rhs.pmax_[i] >= rhs.pmin_[i]); + void flush(); - this->pmin_ = rhs.pmin_; - this->pmax_ = rhs.pmax_; - is_valid_ = rhs.is_valid_; + void init_with(const point_t& p); - for (unsigned i = 0; i < n; ++i) - postcondition(this->pmax_[i] >= this->pmin_[i]); + void update_with(const point_t& p); - return *this; - } - - unsigned impl_npoints() const - { - unsigned count = 1; - for (unsigned i = 0; i < n; ++i) - count *= this->len(i); - return count; - } + void take(const point_t& p); - bool impl_has(const point_t& p) const - { - precondition(is_valid_); - for (unsigned i = 0; i < n; ++i) - if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i]) - return false; - return true; - } + // FIXME: Add "update : (rhs : exact)" - void flush() - { - is_valid_ = false; - } + bool includes(const bbox_<point_t>& rhs) const; - void init_with(const point_t& p) - { - precondition(not is_valid_); - this->pmin_ = p; - this->pmax_ = p; - is_valid_ = true; - } + bool impl_is_valid() const; - void update_with(const point_t& p) - { - precondition(is_valid_); - for (unsigned i = 0; i < n; ++i) - if (p[i] < this->pmin_[i]) - this->pmin_[i] = p[i]; - else if (p[i] > this->pmax_[i]) - this->pmax_[i] = p[i]; - } + void impl_print(std::ostream& ostr) const; - void take(const point_t& p) - { - if (not is_valid_) - { - init_with(p); - return; - } - for (unsigned i = 0; i < n; ++i) - if (p[i] < this->pmin_[i]) - this->pmin_[i] = p[i]; - else if (p[i] > this->pmax_[i]) - this->pmax_[i] = p[i]; - } + protected: - // FIXME: Add "update : (rhs : exact)" + bool is_valid_; - bool includes(const self_t& rhs) const - { - precondition(is_valid_ and rhs.is_valid()); - for (unsigned i = 0; i < n; ++i) - if (rhs.pmin()[i] < this->pmin_[i] or rhs.pmax()[i] > this->pmax_[i]) - return false; - return true; - } + }; // end of class oln::bbox_<point_t> - bool impl_is_valid() const - { - return is_valid_; - } - void impl_print(std::ostream& ostr) const + +# ifndef OLN_INCLUDE_ONLY + + template <typename point_t> + bbox_<point_t>::bbox_() + { + flush(); + } + + template <typename point_t> + bbox_<point_t>::bbox_(const point_t& pmin, const point_t& pmax) + { + this->pmin_ = pmin; + this->pmax_ = pmax; + is_valid_ = true; + + for (unsigned i = 0; i < n; ++i) + precondition(pmax[i] >= pmin[i]); + } + + template <typename point_t> + bbox_<point_t>::bbox_(const bbox_<point_t>& rhs) + { + // FIXME: Remove these 3 lines? + precondition(rhs.is_valid()); + for (unsigned i = 0; i < n; ++i) + precondition(rhs.pmax_[i] >= rhs.pmin_[i]); + + this->pmin_ = rhs.pmin_; + this->pmax_ = rhs.pmax_; + is_valid_ = rhs.is_valid_; + + for (unsigned i = 0; i < n; ++i) + postcondition(this->pmax_[i] >= this->pmin_[i]); + } + + template <typename point_t> + bbox_<point_t>& bbox_<point_t>::operator=(const bbox_<point_t>& rhs) + { + // FIXME: Remove these 3 lines? + precondition(rhs.is_valid()); + for (unsigned i = 0; i < n; ++i) + precondition(rhs.pmax_[i] >= rhs.pmin_[i]); + + this->pmin_ = rhs.pmin_; + this->pmax_ = rhs.pmax_; + is_valid_ = rhs.is_valid_; + + for (unsigned i = 0; i < n; ++i) + postcondition(this->pmax_[i] >= this->pmin_[i]); + + return *this; + } + + template <typename point_t> + unsigned bbox_<point_t>::impl_npoints() const + { + unsigned count = 1; + for (unsigned i = 0; i < n; ++i) + count *= this->len(i); + return count; + } + + template <typename point_t> + bool bbox_<point_t>::impl_has(const point_t& p) const + { + precondition(is_valid_); + for (unsigned i = 0; i < n; ++i) + if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i]) + return false; + return true; + } + + template <typename point_t> + void bbox_<point_t>::flush() + { + is_valid_ = false; + } + + template <typename point_t> + void bbox_<point_t>::init_with(const point_t& p) + { + precondition(not is_valid_); + this->pmin_ = p; + this->pmax_ = p; + is_valid_ = true; + } + + template <typename point_t> + void bbox_<point_t>::update_with(const point_t& p) + { + precondition(is_valid_); + for (unsigned i = 0; i < n; ++i) + if (p[i] < this->pmin_[i]) + this->pmin_[i] = p[i]; + else if (p[i] > this->pmax_[i]) + this->pmax_[i] = p[i]; + } + + template <typename point_t> + void bbox_<point_t>::take(const point_t& p) + { + if (not is_valid_) { - ostr << "{ pmin=" << this->pmin_ - << ", pmax=" << this->pmax_ - << ", valid=" << is_valid_ - << " }"; + init_with(p); + return; } + for (unsigned i = 0; i < n; ++i) + if (p[i] < this->pmin_[i]) + this->pmin_[i] = p[i]; + else if (p[i] > this->pmax_[i]) + this->pmax_[i] = p[i]; + } - protected: + template <typename point_t> + bool bbox_<point_t>::includes(const bbox_<point_t>& rhs) const + { + precondition(is_valid_ and rhs.is_valid()); + for (unsigned i = 0; i < n; ++i) + if (rhs.pmin()[i] < this->pmin_[i] or rhs.pmax()[i] > this->pmax_[i]) + return false; + return true; + } - bool is_valid_; + template <typename point_t> + bool bbox_<point_t>::impl_is_valid() const + { + return is_valid_; + } - }; // end of class oln::bbox_<point> + template <typename point_t> + void bbox_<point_t>::impl_print(std::ostream& ostr) const + { + ostr << "{ pmin=" << this->pmin_ + << ", pmax=" << this->pmax_ + << ", valid=" << is_valid_ + << " }"; + } +# endif + } // end of namespace oln Index: oln/core/gen/topo_bbox.hh =================================================================== --- oln/core/gen/topo_bbox.hh (revision 607) +++ oln/core/gen/topo_bbox.hh (working copy) @@ -70,39 +70,19 @@ public: - topo_bbox_() - { - } + topo_bbox_(); - topo_bbox_(const bbox_t& bb) - : bb_(bb) - { - } + topo_bbox_(const bbox_t& bb); - const bbox_t& impl_bbox() const - { - return bb_; - } + const bbox_t& impl_bbox() const; - bbox_t& impl_bbox() - { - return bb_; - } + bbox_t& impl_bbox(); - bbox_t& impl_lbbox() - { - return bb_; - } + bbox_t& impl_lbbox(); - bool impl_has(const point& p) const - { - return bb_.has(p); - } + bool impl_has(const point& p) const; - bool impl_has_large(const point& p) const - { - return bb_.has(p); - } + bool impl_has_large(const point& p) const; protected: @@ -111,6 +91,57 @@ }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename point> + topo_bbox_<point>::topo_bbox_() + { + } + + template <typename point> + topo_bbox_<point>::topo_bbox_(const typename topo_bbox_<point>::bbox_t& bb) + : bb_(bb) + { + } + + template <typename point> + const typename topo_bbox_<point>::bbox_t& + topo_bbox_<point>::impl_bbox() const + { + return bb_; + } + + template <typename point> + typename topo_bbox_<point>::bbox_t& + topo_bbox_<point>::impl_bbox() + { + return bb_; + } + + template <typename point> + typename topo_bbox_<point>::bbox_t& + topo_bbox_<point>::impl_lbbox() + { + return bb_; + } + + template <typename point> + bool + topo_bbox_<point>::impl_has(const point& p) const + { + return bb_.has(p); + } + + template <typename point> + bool + topo_bbox_<point>::impl_has_large(const point& p) const + { + return lbb_.has(p); + } + +# endif + } // end of namespace oln Index: oln/core/gen/neighb.hh =================================================================== --- oln/core/gen/neighb.hh (revision 606) +++ oln/core/gen/neighb.hh (working copy) @@ -70,34 +70,16 @@ public: - neighb_() - { - } + neighb_(); - self_t& add(const dpoint& dp) - { - s_.insert(dp); - s_.insert(-dp); - update_(); - return *this; - } + neighb_<dpoint>& add(const dpoint& dp); template <typename D> - self_t& add(const abstract::dpoint<D>& dp) - { - return this->add(dp.exact()); - } + neighb_<dpoint>& add(const abstract::dpoint<D>& dp); - unsigned card() const - { - return v_.size(); - } + unsigned card() const; - dpoint dp(unsigned i) const - { - precondition(i < v_.size()); - return v_[i]; - } + dpoint dp(unsigned i) const; // void print(std::ostream& ostr) const; // friend std::ostream& operator<<(std::ostream& ostr, const neighb_<dpoint>& nbh); @@ -107,14 +89,58 @@ std::set<dpoint> s_; std::vector<dpoint> v_; - void update_() - { - v_.clear(); - std::copy(s_.begin(), s_.end(), - std::back_inserter(v_)); - } + void update_(); }; // end of class oln::neighb_<dpoint> + + + +# ifndef OLN_INCLUDE_ONLY + + + template <typename dpoint> + neighb_<dpoint>::neighb_() + { + } + + template <typename dpoint> + neighb_<dpoint>& neighb_<dpoint>::add(const dpoint& dp) + { + s_.insert(dp); + s_.insert(-dp); + update_(); + return *this; + } + + template <typename dpoint> + template <typename D> + neighb_<dpoint>& neighb_<dpoint>::add(const abstract::dpoint<D>& dp) + { + return this->add(dp.exact()); + } + + template <typename dpoint> + unsigned neighb_<dpoint>::card() const + { + return v_.size(); + } + + template <typename dpoint> + dpoint neighb_<dpoint>::dp(unsigned i) const + { + precondition(i < v_.size()); + return v_[i]; + } + + template <typename dpoint> + void neighb_<dpoint>::update_() + { + v_.clear(); + std::copy(s_.begin(), s_.end(), + std::back_inserter(v_)); + } + +# endif } // end of namespace oln Index: oln/core/gen/fwd_niter_neighb.hh =================================================================== --- oln/core/gen/fwd_niter_neighb.hh (revision 607) +++ oln/core/gen/fwd_niter_neighb.hh (working copy) @@ -73,80 +73,49 @@ template <typename P, typename T> fwd_niter_neighb_(const abstract::iterator_on_points<P>& it, - const abstract::topology<T>& topo) - : p_ref_(it.point_adr()), - nbh_(topo.exact().neighborhood()) - { - precondition(nbh_.card() > 0); - i_ = -1; - } + const abstract::topology<T>& topo); -// template <typename P, typename N> -// fwd_niter_neighb_(const abstract::iterator_on_points<P>& it, -// const abstract::neighborhood<N>& nbh) -// : p_ref_(it.point_adr()), -// nbh_(nbh.exact()) -// { -// precondition(nbh_.card() > 0); -// i_ = -1; -// } + // template <typename P, typename N> + // fwd_niter_neighb_(const abstract::iterator_on_points<P>& it, + // const abstract::neighborhood<N>& nbh) + // : p_ref_(it.point_adr()), + // nbh_(nbh.exact()) + // { + // precondition(nbh_.card() > 0); + // i_ = -1; + // } -// template <typename P, typename T> -// fwd_niter_neighb_(const abstract::point<P>& p, -// const abstract::topology<T>& topo) -// : p_ref_(&(p.exact())), -// nbh_(topo.exact().neighborhood()) -// { -// precondition(nbh_.card() > 0); -// i_ = -1; -// } + // template <typename P, typename T> + // fwd_niter_neighb_(const abstract::point<P>& p, + // const abstract::topology<T>& topo) + // : p_ref_(&(p.exact())), + // nbh_(topo.exact().neighborhood()) + // { + // precondition(nbh_.card() > 0); + // i_ = -1; + // } -// template <typename P, typename N> -// fwd_niter_neighb_(const abstract::point<P>& p, -// const abstract::neighborhood<N>& nbh) -// : p_ref_(&(p.exact())), -// nbh_(nbh.exact()) -// { -// precondition(nbh_.card() > 0); -// i_ = -1; -// } + // template <typename P, typename N> + // fwd_niter_neighb_(const abstract::point<P>& p, + // const abstract::neighborhood<N>& nbh) + // : p_ref_(&(p.exact())), + // nbh_(nbh.exact()) + // { + // precondition(nbh_.card() > 0); + // i_ = -1; + // } - void impl_start() - { - i_ = 0; - p_ = *p_ref_+ nbh_.dp(i_); - } + void impl_start(); - void impl_next() - { - ++i_; - if (i_ == int(nbh_.card())) - { - i_ = -1; - return; - } - p_ = *p_ref_ + nbh_.dp(i_); - } + void impl_next(); - void impl_invalidate() - { - i_ = -1; - } + void impl_invalidate(); - bool impl_is_valid() const - { - return i_ != -1; - } + bool impl_is_valid() const; - point_t impl_to_point() const - { - return p_; - } + point_t impl_to_point() const; - const point_t* impl_point_adr() const - { - return &p_; - } + const point_t* impl_point_adr() const; protected: @@ -158,6 +127,73 @@ }; // end of class oln::fwd_niter_neighb_<point_t> + + +# ifndef OLN_INCLUDE_ONLY + + template <typename point_t> + template <typename P, typename T> + fwd_niter_neighb_<point_t>::fwd_niter_neighb_(const abstract::iterator_on_points<P>& it, + const abstract::topology<T>& topo) + : p_ref_(it.point_adr()), + nbh_(topo.exact().neighborhood()) + { + precondition(nbh_.card() > 0); + i_ = -1; + } + + template <typename point_t> + void + fwd_niter_neighb_<point_t>::impl_start() + { + i_ = 0; + p_ = *p_ref_+ nbh_.dp(i_); + } + + template <typename point_t> + void + fwd_niter_neighb_<point_t>::impl_next() + { + ++i_; + if (i_ == int(nbh_.card())) + { + i_ = -1; + return; + } + p_ = *p_ref_ + nbh_.dp(i_); + } + + template <typename point_t> + void + fwd_niter_neighb_<point_t>::impl_invalidate() + { + i_ = -1; + } + + template <typename point_t> + bool + fwd_niter_neighb_<point_t>::impl_is_valid() const + { + return i_ != -1; + } + + template <typename point_t> + point_t + fwd_niter_neighb_<point_t>::impl_to_point() const + { + return p_; + } + + template <typename point_t> + const point_t* + fwd_niter_neighb_<point_t>::impl_point_adr() const + { + return &p_; + } + +# endif + + } // end of namespace oln Index: oln/core/gen/bbox_fwd_piter.hh =================================================================== --- oln/core/gen/bbox_fwd_piter.hh (revision 606) +++ oln/core/gen/bbox_fwd_piter.hh (working copy) @@ -69,14 +69,21 @@ public: - bbox_fwd_piter_(const bbox_<point>& bb) - : super_t(bb) - { - } - + bbox_fwd_piter_(const bbox_<point>& bb); + }; // end of class oln::bbox_fwd_piter_<point> - + +# ifndef OLN_INCLUDE_ONLY + + template <typename point> + bbox_fwd_piter_<point>::bbox_fwd_piter_(const bbox_<point>& bb) + : super_t(bb) + { + } + +# endif + } // end of namespace oln Index: oln/core/gen/fwd_piter_bbox.hh =================================================================== --- oln/core/gen/fwd_piter_bbox.hh (revision 607) +++ oln/core/gen/fwd_piter_bbox.hh (working copy) @@ -72,27 +72,44 @@ public: template <typename T> - fwd_piter_bbox_(const abstract::topology<T>& topo) - : super_t(topo.exact().bbox()) - { - } + fwd_piter_bbox_(const abstract::topology<T>& topo); - void print(std::ostream& ostr) const - { - ostr << "{ p=" << this->p_ - << " }"; - } + void print(std::ostream& ostr) const; - friend - std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t) - { - t.print(ostr); - return ostr; - } - }; // end of class oln::fwd_piter_bbox_<point> - + + template <typename point_t> + std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t); + + + +# ifndef OLN_INCLUDE_ONLY + + template <typename point_t> + template <typename T> + fwd_piter_bbox_<point_t>::fwd_piter_bbox_(const abstract::topology<T>& topo) + : super_t(topo.exact().bbox()) + { + } + + template <typename point_t> + void fwd_piter_bbox_<point_t>::print(std::ostream& ostr) const + { + ostr << "{ p=" << this->p_ + << " }"; + } + + template <typename point_t> + std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t) + { + t.print(ostr); + return ostr; + } + + +# endif + } // end of namespace oln Index: oln/core/gen/fwd_qiter_win.hh =================================================================== --- oln/core/gen/fwd_qiter_win.hh (revision 607) +++ oln/core/gen/fwd_qiter_win.hh (working copy) @@ -73,60 +73,22 @@ template <typename P, typename D> fwd_qiter_win_(const abstract::iterator_on_points<P>& it, - const window_<D>& win) - : p_ref_(it.point_adr()), - win_(win) - { - precondition(win_.card() > 0); - i_ = -1; - } - + const window_<D>& win); template <typename P, typename D> fwd_qiter_win_(const abstract::point<P>& p, - const window_<D>& win) - : p_ref_(&(p.exact())), - win_(win) - { - precondition(win_.card() > 0); - i_ = -1; - } + const window_<D>& win); - void impl_start() - { - i_ = 0; - p_ = *p_ref_+ win_.dp(i_); - } + void impl_start(); - void impl_next() - { - ++i_; - if (i_ == int(win_.card())) - { - i_ = -1; - return; - } - p_ = *p_ref_ + win_.dp(i_); - } + void impl_next(); - void impl_invalidate() - { - i_ = -1; - } + void impl_invalidate(); - bool impl_is_valid() const - { - return i_ != -1; - } + bool impl_is_valid() const; - point_t impl_to_point() const - { - return p_; - } + point_t impl_to_point() const; - const point_t* impl_point_adr() const - { - return &p_; - } + const point_t* impl_point_adr() const; protected: @@ -136,8 +98,84 @@ point_t p_; }; // end of class oln::fwd_qiter_win_<point_t> + +# ifndef OLN_INCLUDE_ONLY + + template <typename point_t> + template <typename P, typename D> + fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::iterator_on_points<P>& it, + const window_<D>& win) + : p_ref_(it.point_adr()), + win_(win) + { + precondition(win_.card() > 0); + i_ = -1; + } + + template <typename point_t> + template <typename P, typename D> + fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::point<P>& p, + const window_<D>& win) + : p_ref_(&(p.exact())), + win_(win) + { + precondition(win_.card() > 0); + i_ = -1; + } + + template <typename point_t> + void + fwd_qiter_win_<point_t>::impl_start() + { + i_ = 0; + p_ = *p_ref_+ win_.dp(i_); + } + + template <typename point_t> + void + fwd_qiter_win_<point_t>::impl_next() + { + ++i_; + if (i_ == int(win_.card())) + { + i_ = -1; + return; + } + p_ = *p_ref_ + win_.dp(i_); + } + + template <typename point_t> + void + fwd_qiter_win_<point_t>::impl_invalidate() + { + i_ = -1; + } + + template <typename point_t> + bool + fwd_qiter_win_<point_t>::impl_is_valid() const + { + return i_ != -1; + } + + template <typename point_t> + point_t + fwd_qiter_win_<point_t>::impl_to_point() const + { + return p_; + } + + template <typename point_t> + const point_t* + fwd_qiter_win_<point_t>::impl_point_adr() const + { + return &p_; + } + +# endif + } // end of namespace oln Index: oln/core/gen/window.hh =================================================================== --- oln/core/gen/window.hh (revision 607) +++ oln/core/gen/window.hh (working copy) @@ -44,49 +44,77 @@ public: - window_() - { - } + window_(); - self_t& add(const dpoint& dp) - { - s_.insert(dp); - update_(); - return *this; - } + window_<dpoint>& add(const dpoint& dp); template <typename D> - self_t& add(const abstract::dpoint<D>& dp) - { - return this->add(dp.exact()); - } + window_<dpoint>& add(const abstract::dpoint<D>& dp); - unsigned card() const - { - return v_.size(); - } + unsigned card() const; - dpoint dp(unsigned i) const - { - precondition(i < v_.size()); - return v_[i]; - } + dpoint dp(unsigned i) const; protected: std::set<dpoint> s_; std::vector<dpoint> v_; - void update_() - { - v_.clear(); - std::copy(s_.begin(), s_.end(), - std::back_inserter(v_)); - } + void update_(); }; // end of class oln::window_<dpoint> - + +# ifndef OLN_INCLUDE_ONLY + + template <typename dpoint> + window_<dpoint>::window_() + { + } + + template <typename dpoint> + window_<dpoint>& + window_<dpoint>::add(const dpoint& dp) + { + s_.insert(dp); + update_(); + return *this; + } + + template <typename dpoint> + template <typename D> + window_<dpoint>& + window_<dpoint>::add(const abstract::dpoint<D>& dp) + { + return this->add(dp.exact()); + } + + template <typename dpoint> + unsigned + window_<dpoint>::card() const + { + return v_.size(); + } + + template <typename dpoint> + dpoint + window_<dpoint>::dp(unsigned i) const + { + precondition(i < v_.size()); + return v_[i]; + } + + template <typename dpoint> + void + window_<dpoint>::update_() + { + v_.clear(); + std::copy(s_.begin(), s_.end(), + std::back_inserter(v_)); + } + +# endif + } // end of namespace oln Index: oln/core/gen/topo_lbbox.hh =================================================================== --- oln/core/gen/topo_lbbox.hh (revision 606) +++ oln/core/gen/topo_lbbox.hh (working copy) @@ -68,38 +68,17 @@ public: - topo_lbbox_() - { - } + topo_lbbox_(); - topo_lbbox_(const bbox_t& bb, unsigned border) - : bb_(bb), border_(border) - { - typedef oln_type_of(point, dpoint) dpoint_t; - dpoint_t dp; - dp.set_all(border); - lbb_ = bbox_<point>(bb_.pmin() - dp, bb_.pmax() + dp); - } + topo_lbbox_(const bbox_t& bb, unsigned border); - const bbox_t& impl_bbox() const - { - return bb_; - } + const bbox_t& impl_bbox() const; - bool impl_has(const point& p) const - { - return bb_.has(p); - } + bool impl_has(const point& p) const; - bool impl_has_large(const point& p) const - { - return lbb_.has(p); - } + bool impl_has_large(const point& p) const; - const bbox_t& lbbox() const - { - return lbb_; - } + const bbox_t& lbbox() const; protected: @@ -110,6 +89,54 @@ }; +# ifndef OLN_INCLUDE_ONLY + + template <typename point> + topo_lbbox_<point>::topo_lbbox_() + { + } + + template <typename point> + topo_lbbox_<point>::topo_lbbox_(const typename topo_lbbox_<point>::bbox_t& bb, + unsigned border) + : bb_(bb), border_(border) + { + typedef oln_type_of(point, dpoint) dpoint_t; + dpoint_t dp; + dp.set_all(border); + lbb_ = bbox_<point>(bb_.pmin() - dp, bb_.pmax() + dp); + } + + template <typename point> + const typename topo_lbbox_<point>::bbox_t& + topo_lbbox_<point>::impl_bbox() const + { + return bb_; + } + + template <typename point> + bool + topo_lbbox_<point>::impl_has(const point& p) const + { + return bb_.has(p); + } + + template <typename point> + bool + topo_lbbox_<point>::impl_has_large(const point& p) const + { + return lbb_.has(p); + } + + template <typename point> + const typename topo_lbbox_<point>::bbox_t& + topo_lbbox_<point>::lbbox() const + { + return lbb_; + } + +# endif + } // end of namespace oln Index: oln/core/gen/bkd_piter_bbox.hh =================================================================== --- oln/core/gen/bkd_piter_bbox.hh (revision 607) +++ oln/core/gen/bkd_piter_bbox.hh (working copy) @@ -72,27 +72,43 @@ public: template <typename T> - bkd_piter_bbox_(const abstract::topology<T>& topo) - : super_t(topo.exact().bbox()) - { - } + bkd_piter_bbox_(const abstract::topology<T>& topo); - void print(std::ostream& ostr) const - { - ostr << "{ p=" << this->p_ - << " }"; - } + void print(std::ostream& ostr) const; - friend - std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t) - { - t.print(ostr); - return ostr; - } - }; // end of class oln::bkd_piter_bbox_<point_t> - + + template <typename point_t> + std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t); + + + +# ifndef OLN_INCLUDE_ONLY + + template <typename point_t> + template <typename T> + bkd_piter_bbox_<point_t>::bkd_piter_bbox_(const abstract::topology<T>& topo) + : super_t(topo.exact().bbox()) + { + } + + template <typename point_t> + void bkd_piter_bbox_<point_t>::print(std::ostream& ostr) const + { + ostr << "{ p=" << this->p_ + << " }"; + } + + template <typename point_t> + std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t) + { + t.print(ostr); + return ostr; + } + +# endif + } // end of namespace oln Index: oln/core/gen/bbox_bkd_piter.hh =================================================================== --- oln/core/gen/bbox_bkd_piter.hh (revision 606) +++ oln/core/gen/bbox_bkd_piter.hh (working copy) @@ -69,14 +69,21 @@ public: - bbox_bkd_piter_(const bbox_<point>& bb) - : super_t(bb) - { - } + bbox_bkd_piter_(const bbox_<point>& bb); }; // end of class oln::bbox_bkd_piter_<point> +# ifndef OLN_INCLUDE_ONLY + + template <typename point> + bbox_bkd_piter_<point>::bbox_bkd_piter_(const bbox_<point>& bb) + : super_t(bb) + { + } + +# endif + } // end of namespace oln Index: oln/core/gen/mapimage.hh =================================================================== --- oln/core/gen/mapimage.hh (revision 606) +++ oln/core/gen/mapimage.hh (working copy) @@ -81,33 +81,15 @@ public: /// Ctor. - mapimage(const value_t& val) - : val_(val) - { - } + mapimage(const value_t& val); - const topo_t& impl_topo() const - { - return topo_; - } + const topo_t& impl_topo() const; - value_t impl_op_read(const point_t& p) const - { - if (not has(p)) - return val_; - return data_[p]; - } + value_t impl_op_read(const point_t& p) const; - value_t& impl_op_readwrite(const point_t& p) - { - topo_.bbox().take(p); - return data_[p]; - } + value_t& impl_op_readwrite(const point_t& p); - bool impl_has(const point_t& p) const - { - return data_.find(p) != data_.end(); - } + bool impl_has(const point_t& p) const; private: @@ -117,6 +99,47 @@ }; +# ifndef OLN_INCLUDE_ONLY + + template <typename point_t, typename value_t> + mapimage<point_t, value_t>::mapimage(const value_t& val) + : val_(val) + { + } + + template <typename point_t, typename value_t> + const typename mapimage<point_t, value_t>::topo_t& + mapimage<point_t, value_t>::impl_topo() const + { + return topo_; + } + + template <typename point_t, typename value_t> + value_t + mapimage<point_t, value_t>::impl_op_read(const point_t& p) const + { + if (not has(p)) + return val_; + return data_[p]; + } + + template <typename point_t, typename value_t> + value_t& + mapimage<point_t, value_t>::impl_op_readwrite(const point_t& p) + { + topo_.bbox().take(p); + return data_[p]; + } + + template <typename point_t, typename value_t> + bool + mapimage<point_t, value_t>::impl_has(const point_t& p) const + { + return data_.find(p) != data_.end(); + } + +# endif + } // end of namespace oln Index: oln/core/gen/topo_add_nbh.hh =================================================================== --- oln/core/gen/topo_add_nbh.hh (revision 606) +++ oln/core/gen/topo_add_nbh.hh (working copy) @@ -69,31 +69,15 @@ { public: - topo_add_nbh() - { - } + topo_add_nbh(); - topo_add_nbh(const topo_t& topo, const nbh_t& nbh) - : topo_(topo), - nbh_(nbh) - { - } + topo_add_nbh(const topo_t& topo, const nbh_t& nbh); + const nbh_t& impl_neighborhood() const; - const nbh_t& impl_neighborhood() const - { - return nbh_; - } + const topo_t& delegate() const; - const topo_t& delegate() const - { - return topo_; - } + operator topo_t() const; - operator topo_t() const - { - return topo_; - } - protected: topo_t topo_; @@ -101,6 +85,40 @@ }; +# ifndef OLN_INCLUDE_ONLY + + template <typename topo_t, typename nbh_t> + topo_add_nbh<topo_t, nbh_t>::topo_add_nbh() + { + } + + template <typename topo_t, typename nbh_t> + topo_add_nbh<topo_t, nbh_t>::topo_add_nbh(const topo_t& topo, const nbh_t& nbh) + : topo_(topo), + nbh_(nbh) + { + } + + template <typename topo_t, typename nbh_t> + const nbh_t& topo_add_nbh<topo_t, nbh_t>::impl_neighborhood() const + { + return nbh_; + } + + template <typename topo_t, typename nbh_t> + const topo_t& topo_add_nbh<topo_t, nbh_t>::delegate() const + { + return topo_; + } + + template <typename topo_t, typename nbh_t> + topo_add_nbh<topo_t, nbh_t>::operator topo_t() const + { + return topo_; + } + +# endif + } // end of namespace oln Index: oln/core/internal/tracked_ptr.hh =================================================================== --- oln/core/internal/tracked_ptr.hh (revision 606) +++ oln/core/internal/tracked_ptr.hh (working copy) @@ -47,164 +47,233 @@ holders_t* holders_; /// Coercion towards Boolean (for arithmetical tests). - operator bool() const - { - invariant_(); - return ptr_ != 0; - } + operator bool() const; /// Negation (for arithmetical tests). - bool operator not() const - { - invariant_(); - return not bool(*this); - } + bool operator not() const; /*! \brief Mimics the behavior of op-> for a pointer in the const case. ** ** \invariant Pointer proxy exists. */ - const T*const operator->() const - { - invariant_(); - precondition(ptr_ != 0); - return ptr_; - } + const T*const operator->() const; /*! \brief Mimics the behavior of op-> for a pointer in the mutable case. ** ** \invariant Pointer proxy exists. */ - T*const operator->() - { - invariant_(); - precondition(ptr_ != 0); - return ptr_; - } + T*const operator->(); /// Ctor. - tracked_ptr() : - ptr_(0), - holders_(0) - { - invariant_(); - } + tracked_ptr(); /// Ctor. - tracked_ptr(T* ptr) : - ptr_(ptr) - { - if (ptr == 0) - holders_ = 0; - else - { - holders_ = new holders_t; - holders_->insert(this); - } - invariant_(); - } + tracked_ptr(T* ptr); /// Cpy ctor. - tracked_ptr(const self_t& rhs) : - ptr_(rhs.ptr_), - holders_(rhs.holders_) - { - rhs.invariant_(); - if (ptr_ != 0) - holders_->insert(this); - invariant_(); - } + tracked_ptr(const tracked_ptr<T>& rhs); /// Assignment. - self_t& operator=(const self_t& rhs) - { - invariant_(); - rhs.invariant_(); - if (&rhs == this or rhs.ptr_ == ptr_) - // no-op - return *this; - clean_(); - ptr_ = rhs.ptr_; - holders_ = rhs.holders_; - holders_->insert(this); - return *this; - } + tracked_ptr<T>& operator=(const tracked_ptr<T>& rhs); /// Assignment. - self_t& operator=(T* ptr) - { - invariant_(); - if (ptr == ptr_) - // no-op - return *this; - clean_(); - ptr_ = ptr; - if (ptr == 0) - holders_ = 0; - else - { - holders_ = new holders_t; - holders_->insert(this); - } - return *this; - } + tracked_ptr<T>& operator=(T* ptr); /// Dtor. - ~tracked_ptr() - { - clean_(); - } + ~tracked_ptr(); - void invariant_() const - { - invariant((ptr_ and holders_) or (not ptr_ and not holders_)); - if (ptr_ == 0) - return; - invariant(holders_->size() > 0); - self_t* this_ = const_cast<self_t*>(this); - invariant(holders_->find(this_) != holders_->end()); - typename holders_t::const_iterator i; - for (i = holders_->begin(); i != holders_->end(); ++i) - invariant((*i)->ptr_ == ptr_); - } + void invariant_() const; - void clean_() - { - invariant_(); - if (ptr_ == 0) - // no-op - return; - if (holders_->size() == 1) - { - delete ptr_; - delete holders_; - } - else - holders_->erase(this); - ptr_ = 0; - holders_ = 0; - invariant_(); - } + void clean_(); - friend std::ostream& operator<<(std::ostream& ostr, const self_t& tp) - { - ostr << "tracked_ptr @ " << (&tp) - << " { ptr = " << tp.ptr_ - << " / holders = "; - if (tp.holders_ == 0) - ostr << "0"; - else - { - typename holders_t::const_iterator i; - for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i) - ostr << (*i) << ' '; - } - ostr << " }"; - return ostr; - } }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename T> + tracked_ptr<T>:: + tracked_ptr<T>::operator bool() const + { + invariant_(); + return ptr_ != 0; + } + + template <typename T> + /// Negation (for arithmetical tests). + bool tracked_ptr<T>::operator not() const + { + invariant_(); + return not bool(*this); + } + + template <typename T> + /*! \brief Mimics the behavior of op-> for a pointer in the const case. + ** + ** \invariant Pointer proxy exists. + */ + const T*const tracked_ptr<T>::operator->() const + { + invariant_(); + precondition(ptr_ != 0); + return ptr_; + } + + template <typename T> + /*! \brief Mimics the behavior of op-> for a pointer in the mutable case. + ** + ** \invariant Pointer proxy exists. + */ + T*const tracked_ptr<T>::operator->() + { + invariant_(); + precondition(ptr_ != 0); + return ptr_; + } + + template <typename T> + /// Ctor. + tracked_ptr<T>::tracked_ptr() : + ptr_(0), + holders_(0) + { + invariant_(); + } + + template <typename T> + /// Ctor. + tracked_ptr<T>::tracked_ptr(T* ptr) : + ptr_(ptr) + { + typedef std::set<tracked_ptr<T>*> holders_t; + + if (ptr == 0) + holders_ = 0; + else + { + holders_ = new holders_t; + holders_->insert(this); + } + invariant_(); + } + + template <typename T> + /// Cpy ctor. + tracked_ptr<T>::tracked_ptr(const tracked_ptr<T>& rhs) : + ptr_(rhs.ptr_), + holders_(rhs.holders_) + { + rhs.invariant_(); + if (ptr_ != 0) + holders_->insert(this); + invariant_(); + } + + template <typename T> + /// Assignment. + tracked_ptr<T>& tracked_ptr<T>::operator=(const tracked_ptr<T>& rhs) + { + invariant_(); + rhs.invariant_(); + if (&rhs == this or rhs.ptr_ == ptr_) + // no-op + return *this; + clean_(); + ptr_ = rhs.ptr_; + holders_ = rhs.holders_; + holders_->insert(this); + return *this; + } + + template <typename T> + /// Assignment. + tracked_ptr<T>& tracked_ptr<T>::operator=(T* ptr) + { + typedef std::set<tracked_ptr<T>*> holders_t; + + invariant_(); + if (ptr == ptr_) + // no-op + return *this; + clean_(); + ptr_ = ptr; + if (ptr == 0) + holders_ = 0; + else + { + holders_ = new holders_t; + holders_->insert(this); + } + return *this; + } + + /// Dtor. + template <typename T> + tracked_ptr<T>::~tracked_ptr() + { + clean_(); + } + + template <typename T> + void tracked_ptr<T>::invariant_() const + { + typedef std::set<tracked_ptr<T>*> holders_t; + + invariant((ptr_ and holders_) or (not ptr_ and not holders_)); + if (ptr_ == 0) + return; + invariant(holders_->size() > 0); + tracked_ptr<T>* this_ = const_cast<tracked_ptr<T>*>(this); + invariant(holders_->find(this_) != holders_->end()); + typename holders_t::const_iterator i; + for (i = holders_->begin(); i != holders_->end(); ++i) + invariant((*i)->ptr_ == ptr_); + } + + template <typename T> + void tracked_ptr<T>::clean_() + { + invariant_(); + if (ptr_ == 0) + // no-op + return; + if (holders_->size() == 1) + { + delete ptr_; + delete holders_; + } + else + holders_->erase(this); + ptr_ = 0; + holders_ = 0; + invariant_(); + } + + template <typename T> + std::ostream& operator<<(std::ostream& ostr, const tracked_ptr<T>& tp) + { + typedef std::set<tracked_ptr<T>*> holders_t; + + ostr << "tracked_ptr @ " << (&tp) + << " { ptr = " << tp.ptr_ + << " / holders = "; + if (tp.holders_ == 0) + ostr << "0"; + else + { + typename holders_t::const_iterator i; + for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i) + ostr << (*i) << ' '; + } + ostr << " }"; + return ostr; + } + + +# endif + } // end of namespace oln::internal } // end of namespace oln Index: oln/core/internal/topology_morpher.hh =================================================================== --- oln/core/internal/topology_morpher.hh (revision 606) +++ oln/core/internal/topology_morpher.hh (working copy) @@ -70,9 +70,18 @@ struct topology_morpher : public topology_entry<E> { protected: - topology_morpher() {} + topology_morpher(); }; +# ifndef OLN_INCLUDE_ONLY + + template <typename Topo, typename E> + topology_morpher<Topo, E>::topology_morpher() + { + } + +# endif + } // end of namespace oln::internal Index: oln/core/internal/point_nd.hh =================================================================== --- oln/core/internal/point_nd.hh (revision 606) +++ oln/core/internal/point_nd.hh (working copy) @@ -75,100 +75,164 @@ typedef oln_type_of(E, coord) coord_t; typedef oln_type_of(E, dpoint) dpoint_t; + public: enum { n = mlc_value(dim) }; + typedef xtd::vec<n,coord_t> vec_t; - coord_t operator[](unsigned i) const - { - assert(i < n); - return v_[i]; - } - - coord_t& operator[](unsigned i) - { - assert(i < n); - return v_[i]; - } + coord_t operator[](unsigned i) const; + coord_t& operator[](unsigned i); - bool impl_equal(const self_t& rhs) const - { - return v_ == rhs.vec(); - } + bool impl_equal(const self_t& rhs) const; - bool impl_less(const self_t& rhs) const - { - return xtd::lexi_less(v_, rhs.vec()); - } + bool impl_less(const self_t& rhs) const; - E& impl_plus_equal(const dpoint_t& rhs) - { - v_ += rhs.vec(); - return this->exact(); - } + E& impl_plus_equal(const dpoint_t& rhs); - E impl_plus(const dpoint_t& rhs) const - { - E tmp(v_ + rhs.vec()); - return tmp; - } + E impl_plus(const dpoint_t& rhs) const; - E& impl_minus_equal(const dpoint_t& rhs) - { - v_ += rhs.vec(); - return this->exact(); - } + E& impl_minus_equal(const dpoint_t& rhs); - E impl_minus(const dpoint_t& rhs) const - { - E tmp(v_ - rhs.vec()); - return tmp; - } + E impl_minus(const dpoint_t& rhs) const; - dpoint_t impl_minus(const self_t& rhs) const - { - dpoint_t tmp(v_ - rhs.vec()); - return tmp; - } + dpoint_t impl_minus(const self_t& rhs) const; - const xtd::vec<n,coord_t>& vec() const - { - return v_; - } + const vec_t& vec() const; protected: /// Ctor. - point_nd() - {} + point_nd(); /// Ctor. - point_nd(const xtd::vec<n,coord_t>& v) : - v_(v) - {} + point_nd(const vec_t& v); - typedef xtd::vec<n,coord_t> vec_t; + /// Dtor. + ~point_nd() + { + } + vec_t v_; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + typename point_nd<E>::coord_t + point_nd<E>::operator[](unsigned i) const + { + assert(i < n); + return v_[i]; + } + + template <typename E> + typename point_nd<E>::coord_t& + point_nd<E>::operator[](unsigned i) + { + assert(i < n); + return v_[i]; + } + + template <typename E> + bool point_nd<E>::impl_equal(const self_t& rhs) const + { + return v_ == rhs.vec(); + } + + template <typename E> + bool point_nd<E>::impl_less(const self_t& rhs) const + { + return xtd::lexi_less(v_, rhs.vec()); + } + + template <typename E> + E& point_nd<E>::impl_plus_equal(const dpoint_t& rhs) + { + v_ += rhs.vec(); + return this->exact(); + } + + template <typename E> + E point_nd<E>::impl_plus(const dpoint_t& rhs) const + { + E tmp(v_ + rhs.vec()); + return tmp; + } + + template <typename E> + E& point_nd<E>::impl_minus_equal(const typename point_nd<E>::dpoint_t& rhs) + { + v_ += rhs.vec(); + return this->exact(); + } + + template <typename E> + E point_nd<E>::impl_minus(const typename point_nd<E>::dpoint_t& rhs) const + { + E tmp(v_ - rhs.vec()); + return tmp; + } + + template <typename E> + typename point_nd<E>::dpoint_t + point_nd<E>::impl_minus(const self_t& rhs) const + { + typename point_nd<E>::dpoint_t tmp(v_ - rhs.vec()); + return tmp; + } + + template <typename E> + const typename point_nd<E>::vec_t& + point_nd<E>::vec() const + { + return v_; + } + + template <typename E> + point_nd<E>::point_nd() + {} + + template <typename E> + point_nd<E>::point_nd(const typename point_nd<E>::vec_t& v) : + v_(v) + {} + +// template <typename E> +// point_nd<E>::~point_nd() +// {} + +# endif + + + } // end of namespace oln::internal + template <typename E> + std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p); + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p) { ostr << p.vec(); return ostr; } +# endif + /// internal::point_nd + internal::dpoint_nd template <typename P, typename D> struct case_ < xtd::op_plus, mlc::pair_<P,D>, oln::id::op_plus_pointnd_dpointnd > - : where_< mlc::and_< mlc_is_a(P, internal::point_nd), - mlc_is_a(D, internal::dpoint_nd) > > + : where_< mlc::and_< mlc_is_a(P, internal::point_nd), + mlc_is_a(D, internal::dpoint_nd) > > { typedef oln_type_of(P, coord) P_coord; typedef oln_type_of(D, coord) D_coord; @@ -182,8 +246,8 @@ template <typename P, typename D> struct case_ < xtd::op_minus, mlc::pair_<P,D>, oln::id::op_minus_pointnd_dpointnd > - : where_< mlc::and_< mlc_is_a(P, internal::point_nd), - mlc_is_a(D, internal::dpoint_nd) > > + : where_< mlc::and_< mlc_is_a(P, internal::point_nd), + mlc_is_a(D, internal::dpoint_nd) > > { typedef oln_type_of(P, coord) P_coord; typedef oln_type_of(D, coord) D_coord; @@ -197,8 +261,8 @@ template <typename P1, typename P2> struct case_ < xtd::op_minus, mlc::pair_<P1,P2>, oln::id::op_minus_pointnd_pointnd > - : where_< mlc::and_< mlc_is_a(P1, internal::point_nd), - mlc_is_a(P2, internal::point_nd) > > + : where_< mlc::and_< mlc_is_a(P1, internal::point_nd), + mlc_is_a(P2, internal::point_nd) > > { typedef oln_type_of(P1, coord) P1_coord; typedef oln_type_of(P2, coord) P2_coord; Index: oln/core/internal/bbox_bkd_piter.hh =================================================================== --- oln/core/internal/bbox_bkd_piter.hh (revision 606) +++ oln/core/internal/bbox_bkd_piter.hh (working copy) @@ -64,61 +64,21 @@ public: - bbox_bkd_piter(const bbox_<point_t>& bb) - : p_(), - bb_(bb) - { - nop_ = bb_.pmin(); - --nop_[0]; - } + bbox_bkd_piter(const bbox_<point_t>& bb); - const bbox_<point_t>& bbox() const - { - return bb_; - } + const bbox_<point_t>& bbox() const; - void impl_start() - { - p_ = bb_.pmax(); - invariant(implies(p_ != nop_, bb_.has(p_))); - } + void impl_start(); - void impl_next() - { - invariant(implies(p_ != nop_, bb_.has(p_))); - for (int i = point_t::n - 1; i >= 0; --i) - if (p_[i] == bb_.pmin(i)) - p_[i] = bb_.pmax(i); - else - { - --p_[i]; - break; - } - if (p_ == bb_.pmax()) - p_ = nop_; - } + void impl_next(); - void impl_invalidate() - { - invariant(implies(p_ != nop_, bb_.has(p_))); - p_ = nop_; - } + void impl_invalidate(); - bool impl_is_valid() const - { - invariant(implies(p_ != nop_, bb_.has(p_))); - return p_ != nop_; - } + bool impl_is_valid() const; - point_t impl_to_point() const - { - return p_; - } + point_t impl_to_point() const; - const point_t* impl_point_adr() const - { - return &p_; - } + const point_t* impl_point_adr() const; protected: @@ -129,6 +89,85 @@ }; // end of class oln::internal::bbox_bkd_piter<E> + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bbox_bkd_piter<E>::bbox_bkd_piter(const bbox_<oln_type_of(E, point)>& bb) + : p_(), + bb_(bb) + { + nop_ = bb_.pmin(); + --nop_[0]; + } + + template <typename E> + const bbox_<oln_type_of(E, point)>& + bbox_bkd_piter<E>::bbox() const + { + return bb_; + } + + template <typename E> + void + bbox_bkd_piter<E>::impl_start() + { + p_ = bb_.pmax(); + invariant(implies(p_ != nop_, bb_.has(p_))); + } + + template <typename E> + void + bbox_bkd_piter<E>::impl_next() + { + typedef oln_type_of(E, point) point_t; + invariant(implies(p_ != nop_, bb_.has(p_))); + for (int i = point_t::n - 1; i >= 0; --i) + if (p_[i] == bb_.pmin(i)) + p_[i] = bb_.pmax(i); + else + { + --p_[i]; + break; + } + if (p_ == bb_.pmax()) + p_ = nop_; + } + + template <typename E> + void + bbox_bkd_piter<E>::impl_invalidate() + { + invariant(implies(p_ != nop_, bb_.has(p_))); + p_ = nop_; + } + + template <typename E> + bool + bbox_bkd_piter<E>::impl_is_valid() const + { + invariant(implies(p_ != nop_, bb_.has(p_))); + return p_ != nop_; + } + + template <typename E> + oln_type_of(E, point) + bbox_bkd_piter<E>::impl_to_point() const + { + return p_; + } + + template <typename E> + const oln_type_of(E, point)* + bbox_bkd_piter<E>::impl_point_adr() const + { + return &p_; + } + +# endif + + } // end of namespace oln::internal } // end of namespace oln Index: oln/core/internal/bbox_fwd_piter.hh =================================================================== --- oln/core/internal/bbox_fwd_piter.hh (revision 606) +++ oln/core/internal/bbox_fwd_piter.hh (working copy) @@ -64,61 +64,21 @@ public: - bbox_fwd_piter(const bbox_<point_t>& bb) - : p_(), - bb_(bb) - { - nop_ = bb_.pmax(); - ++nop_[0]; - } + bbox_fwd_piter(const bbox_<point_t>& bb); - const bbox_<point_t>& bbox() const - { - return bb_; - } + const bbox_<point_t>& bbox() const; - void impl_start() - { - p_ = bb_.pmin(); - invariant(implies(p_ != nop_, bb_.has(p_))); - } + void impl_start(); - void impl_next() - { - invariant(implies(p_ != nop_, bb_.has(p_))); - for (int i = point_t::n - 1; i >= 0; --i) - if (p_[i] == bb_.pmax(i)) - p_[i] = bb_.pmin(i); - else - { - ++p_[i]; - break; - } - if (p_ == bb_.pmin()) - p_ = nop_; - } + void impl_next(); - void impl_invalidate() - { - invariant(implies(p_ != nop_, bb_.has(p_))); - p_ = nop_; - } + void impl_invalidate(); - bool impl_is_valid() const - { - invariant(implies(p_ != nop_, bb_.has(p_))); - return p_ != nop_; - } + bool impl_is_valid() const; - point_t impl_to_point() const - { - return p_; - } + point_t impl_to_point() const; - const point_t* impl_point_adr() const - { - return &p_; - } + const point_t* impl_point_adr() const; protected: @@ -129,6 +89,85 @@ }; // end of class oln::internal::bbox_fwd_piter<E> + + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bbox_fwd_piter<E>::bbox_fwd_piter(const bbox_<typename bbox_fwd_piter<E>::point_t>& bb) + : p_(), + bb_(bb) + { + nop_ = bb_.pmax(); + ++nop_[0]; + } + + template <typename E> + const bbox_<typename bbox_fwd_piter<E>::point_t>& + bbox_fwd_piter<E>::bbox() const + { + return bb_; + } + + template <typename E> + void + bbox_fwd_piter<E>::impl_start() + { + p_ = bb_.pmin(); + invariant(implies(p_ != nop_, bb_.has(p_))); + } + + template <typename E> + void + bbox_fwd_piter<E>::impl_next() + { + invariant(implies(p_ != nop_, bb_.has(p_))); + typedef typename bbox_fwd_piter<E>::point_t point_t; + for (int i = point_t::n - 1; i >= 0; --i) + if (p_[i] == bb_.pmax(i)) + p_[i] = bb_.pmin(i); + else + { + ++p_[i]; + break; + } + if (p_ == bb_.pmin()) + p_ = nop_; + } + + template <typename E> + void + bbox_fwd_piter<E>::impl_invalidate() + { + invariant(implies(p_ != nop_, bb_.has(p_))); + p_ = nop_; + } + + template <typename E> + bool + bbox_fwd_piter<E>::impl_is_valid() const + { + invariant(implies(p_ != nop_, bb_.has(p_))); + return p_ != nop_; + } + + template <typename E> + typename bbox_fwd_piter<E>::point_t + bbox_fwd_piter<E>::impl_to_point() const + { + return p_; + } + + template <typename E> + const typename bbox_fwd_piter<E>::point_t* + bbox_fwd_piter<E>::impl_point_adr() const + { + return &p_; + } + +# endif + + } // end of namespace oln::internal } // end of namespace oln Index: oln/core/internal/dpoint_nd.hh =================================================================== --- oln/core/internal/dpoint_nd.hh (revision 606) +++ oln/core/internal/dpoint_nd.hh (working copy) @@ -64,59 +64,101 @@ public: enum { n = mlc_value(dim) }; + typedef xtd::vec<n,coord_t> vec_t; - bool impl_equal(const self_t& rhs) const - { - return v_ == rhs.v_; - } + bool impl_equal(const dpoint_nd<E>& rhs) const; - coord_t operator[](unsigned i) const - { - assert(i < n); - return v_[i]; - } + coord_t operator[](unsigned i) const; - coord_t& operator[](unsigned i) - { - assert(i < n); - return v_[i]; - } + coord_t& operator[](unsigned i); - void set_all(const coord_t& c) - { - v_.set_all(c); - } + void set_all(const coord_t& c); - const xtd::vec<n,coord_t>& vec() const - { - return v_; - } + const vec_t& vec() const; - exact_t operator-() const - { - exact_t tmp(-v_); - return tmp; - } + E operator-() const; - bool impl_less(const self_t& rhs) const - { - return xtd::lexi_less(v_, rhs.vec()); - } + bool impl_less(const dpoint_nd<E>& rhs) const; protected: /// Ctor. - dpoint_nd() - {} + dpoint_nd(); /// Ctor. - dpoint_nd(const xtd::vec<n,coord_t>& v) : - v_(v) - {} + dpoint_nd(const vec_t& v); - xtd::vec<n,coord_t> v_; + vec_t v_; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename E> + bool + dpoint_nd<E>::impl_equal(const dpoint_nd<E>& rhs) const + { + return v_ == rhs.v_; + } + + template <typename E> + typename dpoint_nd<E>::coord_t + dpoint_nd<E>::operator[](unsigned i) const + { + assert(i < n); + return v_[i]; + } + + template <typename E> + typename dpoint_nd<E>::coord_t& + dpoint_nd<E>::operator[](unsigned i) + { + assert(i < n); + return v_[i]; + } + + template <typename E> + void + dpoint_nd<E>::set_all(const typename dpoint_nd<E>::coord_t& c) + { + v_.set_all(c); + } + + template <typename E> + const typename dpoint_nd<E>::vec_t& + dpoint_nd<E>::vec() const + { + return v_; + } + + template <typename E> + E + dpoint_nd<E>::operator-() const + { + E tmp(-v_); + return tmp; + } + + template <typename E> + bool + dpoint_nd<E>::impl_less(const dpoint_nd<E>& rhs) const + { + return xtd::lexi_less(v_, rhs.vec()); + } + + template <typename E> + dpoint_nd<E>::dpoint_nd() + {} + + template <typename E> + dpoint_nd<E>::dpoint_nd(const typename dpoint_nd<E>::vec_t& v) : + v_(v) + {} + + +# endif + + } // end of namespace oln::internal @@ -125,7 +167,7 @@ template <typename D> struct case_ < xtd::op_uminus, D, oln::id::op_uminus_dpointnd > - : where_< mlc_is_a(D, internal::dpoint_nd) > + : where_< mlc_is_a(D, internal::dpoint_nd) > { typedef stc_to_exact(D) ret; }; Index: oln/basics2d.hh =================================================================== --- oln/basics2d.hh (revision 607) +++ oln/basics2d.hh (working copy) @@ -35,25 +35,17 @@ # include <oln/core/2d/grid2d.hh> # include <oln/core/2d/point2d.hh> -namespace oln { template class point2d_<int>; } - # include <oln/core/2d/dpoint2d.hh> -namespace oln { template class dpoint2d_<int>; } # include <oln/core/gen/bbox.hh> namespace oln { template class bbox_<point2d>; } # include <oln/core/gen/topo_lbbox.hh> -namespace oln { template class topo_lbbox_<point2d>; } # include <oln/core/gen/fwd_piter_bbox.hh> -namespace oln { template class fwd_piter_bbox_<point2d>; } - # include <oln/core/gen/bkd_piter_bbox.hh> -namespace oln { template class bkd_piter_bbox_<point2d>; } # include <oln/core/gen/neighb.hh> -namespace oln { template class neighb_<dpoint2d>; } # include <oln/core/2d/neighb2d.hh> # include <oln/core/2d/image2d.hh> Index: oln/morpher/add_isubset.hh =================================================================== --- oln/morpher/add_isubset.hh (revision 607) +++ oln/morpher/add_isubset.hh (working copy) @@ -106,29 +106,54 @@ // FIXME: Handle the constness. - add_isubset(const Image& image, const Isubset& isubset) : - super_t(image), - topo_(image.topo(), isubset) - { - mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Isubset, grid)>::check(); - // FIXME: check that Image is without a isubset - } + add_isubset(const Image& image, const Isubset& isubset); + const topo_t& impl_topo() const; - const topo_t& impl_topo() const - { - return topo_; - } - protected: topo_t topo_; }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename Image, typename Isubset> + add_isubset<Image, Isubset>::add_isubset(const Image& image, const Isubset& isubset) : + super_t(image), + topo_(image.topo(), isubset) + { + mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Isubset, grid)>::check(); + // FIXME: check that Image is without a isubset + } + + template <typename Image, typename Isubset> + const typename add_isubset<Image, Isubset>::topo_t& + add_isubset<Image, Isubset>::impl_topo() const + { + return topo_; + } + +# endif + + } // end of namespace oln::morpher + template <typename I, typename S> morpher::add_isubset<I, S> operator | (const abstract::image<I>& image, + const abstract::binary_image<S>& isubset); + + // FIXME: Register this operator. + // FIXME: Add mutable version. + + +# ifndef OLN_INCLUDE_ONLY + + template <typename I, typename S> + morpher::add_isubset<I, S> + operator | (const abstract::image<I>& image, const abstract::binary_image<S>& isubset) { mlc::assert_equal_<oln_type_of(I, grid), oln_type_of(S, grid)>::check(); @@ -137,10 +162,8 @@ return tmp; } - // FIXME: Register this operator. - // FIXME: Add mutable version. +# endif - } // end of namespace oln Index: oln/morpher/identity.hh =================================================================== --- oln/morpher/identity.hh (revision 606) +++ oln/morpher/identity.hh (working copy) @@ -63,13 +63,21 @@ public: // FIXME: Handle the constness. - identity(const Image& image) : - super_t(image) - { - } + identity(const Image& image); }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename Image> + identity<Image>::identity(const Image& image) : + super_t(image) + { + } + +# endif + } // end of namespace oln::morpher } // end of namespace oln Index: oln/morpher/internal/image_extension.hh =================================================================== --- oln/morpher/internal/image_extension.hh (revision 607) +++ oln/morpher/internal/image_extension.hh (working copy) @@ -85,20 +85,32 @@ // } // FIXME: Handle the constness. - image_extension(const Image& image) : - image_(image) - { - } + image_extension(const Image& image); + const Image& delegate() const; - const Image& delegate() const - { - return image_; - } - protected: Image image_; }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename Image, typename Exact> + image_extension<Image, Exact>::image_extension(const Image& image) : + image_(image) + { + } + + template <typename Image, typename Exact> + const Image& + image_extension<Image, Exact>::delegate() const + { + return image_; + } + +# endif + } // end of namespace oln::morpher::internal } // end of namespace oln::morpher Index: oln/morpher/add_neighborhood.hh =================================================================== --- oln/morpher/add_neighborhood.hh (revision 607) +++ oln/morpher/add_neighborhood.hh (working copy) @@ -81,34 +81,53 @@ // FIXME: Handle the constness. -// template <typename I, typename N> -// add_neighborhood(const abstract::image<I>& image, const N& nbh) -// : super_t(image) -// { -// } + // template <typename I, typename N> + // add_neighborhood(const abstract::image<I>& image, const N& nbh) + // : super_t(image) + // { + // } - add_neighborhood(const Image& image, const Neighb& nbh) : - super_t(image), - topo_(image.topo(), nbh) - { - mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Neighb, grid)>::check(); - // FIXME: check that Image is without a nbh - } + add_neighborhood(const Image& image, const Neighb& nbh); + const topo_t& impl_topo() const; - const topo_t& impl_topo() const - { - return topo_; - } - protected: topo_t topo_; }; + +# ifndef OLN_INCLUDE_ONLY + + template <typename Image, typename Neighb> + add_neighborhood<Image, Neighb>::add_neighborhood(const Image& image, const Neighb& nbh) : + super_t(image), + topo_(image.topo(), nbh) + { + mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Neighb, grid)>::check(); + // FIXME: check that Image is without a nbh + } + + template <typename Image, typename Neighb> + const typename add_neighborhood<Image, Neighb>::topo_t& + add_neighborhood<Image, Neighb>::impl_topo() const + { + return topo_; + } + +# endif + } // end of namespace oln::morpher + template <typename I, typename N> morpher::add_neighborhood<I, N> + operator + (const abstract::image<I>& image, const abstract::neighborhood<N>& nbh); + + +# ifndef OLN_INCLUDE_ONLY + + template <typename I, typename N> + morpher::add_neighborhood<I, N> operator + (const abstract::image<I>& image, const abstract::neighborhood<N>& nbh) { @@ -118,6 +137,7 @@ return tmp; } +# endif } // end of namespace oln
participants (1)
-
Thierry GERAUD