Since the topology types are not (so) exposed to the library clients,
the topology hierarchy can be simplified from the SCOOP 2 paradigm to
the SCOOP 1 one. Precisely, all abstract and *specific* interfaces
move from sub-abstractions to the top abstraction (abstract::topology).
As a result, the compilation of the code below decreases from 43 sec
to 31 sec. Several empirical compilation tests show that we save
between 20 and 30% of compilation time.
int main()
{
using namespace oln;
image2d<int> ima(3, 3);
local::iota(ima);
debug::println(ima, std::cout);
image2d<bool> msk(3, 3);
local::chessboard(msk);
msk(point2d(0,1)) = true;
debug::println(msk, std::cout);
debug::println(ima | msk, std::cout);
debug::println(ima + c4, std::cout);
local::bar((ima + c4) | msk); // iterates on p then on p's neighbors
}
Below the diff between this test version and the version 612.
tegucigalpa% \svn st
! olena/oln/core/automatic/topology_having_bbox.hh
! olena/oln/core/automatic/topology_being_random_accessible.hh
! olena/oln/core/automatic/topology_having_subset.hh
! olena/oln/core/automatic/topology_having_neighborhood.hh
! olena/oln/core/topology_entry.hh
! olena/oln/core/abstract/topology_having_bbox.hh
! olena/oln/core/abstract/topology_hierarchies.hh
! olena/oln/core/abstract/topology_being_random_accessible.hh
! olena/oln/core/abstract/topology_having_subset.hh
! olena/oln/core/abstract/topology_having_neighborhood.hh
M olena/oln/core/abstract/topology.hh
M olena/oln/core/gen/topo_bbox.hh
M olena/oln/core/gen/topo_lbbox.hh
M olena/oln/core/internal/topology_morpher.hh
Index: olena/oln/core/abstract/topology.hh
===================================================================
--- olena/oln/core/abstract/topology.hh (revision 612)
+++ olena/oln/core/abstract/topology.hh (working copy)
@@ -34,7 +34,23 @@
namespace oln
{
+ namespace abstract {
+ template <typename E> class topology;
+ }
+
+ template <typename E>
+ struct vtypes< abstract::topology<E> >
+ {
+ typedef mlc::undefined bbox_type;
+ typedef mlc::undefined is_random_accessible_type;
+ typedef mlc::undefined point_type;
+ typedef mlc::undefined neighborhood_type;
+ typedef mlc::undefined morpher_type;
+ };
+
+
+
namespace abstract
{
@@ -49,19 +65,29 @@
struct decl
{
oln_virtual_typedef(bbox);
- // for being bboxed; provides .bbox()
-
oln_virtual_typedef(is_random_accessible);
- // provides .has(p) and .has_large(p)
-
oln_virtual_typedef(point);
oln_virtual_typedef(neighborhood);
-
oln_virtual_typedef(morpher);
decl();
};
+
+ // Bbox.
+ const oln_type_of(E, bbox)& bbox() const;
+ oln_type_of(E, bbox)& bbox();
+
+ // Subset.
+ const oln_type_of(E, subset)& subset() const;
+
+ // Neighborhood.
+ const oln_type_of(E, neighborhood)& neighborhood() const;
+
+ // Random access.
+ bool has(const oln_type_of(E, point)& p) const;
+ bool has_large(const oln_type_of(E, point)& p) const;
+
protected:
topology();
@@ -77,9 +103,6 @@
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>
@@ -93,17 +116,61 @@
decl();
}
-# endif
+ // Bbox.
+ template <typename E>
+ const oln_type_of(E, bbox)&
+ topology<E>::bbox() const
+ {
+ return this->exact().impl_bbox();
+ }
- } // end of namespace oln::abstract
+ template <typename E>
+ oln_type_of(E, bbox)&
+ topology<E>::bbox()
+ {
+ return this->exact().impl_bbox();
+ }
-} // end of namespace oln
+ // Subset.
+ template <typename E>
+ const oln_type_of(E, subset)&
+ topology<E>::subset() const
+ {
+ return this->exact().impl_subset();
+ }
+ // Neighborhood.
-# include <oln/core/abstract/topology_hierarchies.hh>
+ template <typename E>
+ const oln_type_of(E, neighborhood)&
+ topology<E>::neighborhood() const
+ {
+ return this->exact().impl_neighborhood();
+ }
+ // Random access.
+ template <typename E>
+ bool topology<E>::has(const oln_type_of(E, point)& p) const
+ {
+ return this->exact().impl_has(p);
+ }
+ template <typename E>
+ bool topology<E>::has_large(const oln_type_of(E, point)& p) const
+ {
+ return this->exact().impl_has_large(p);
+ }
+
+# endif
+
+
+ } // end of namespace oln::abstract
+
+
+} // end of namespace oln
+
+
#endif // ! OLN_CORE_ABSTRACT_TOPOLOGY_HH
Index: olena/oln/core/gen/topo_bbox.hh
===================================================================
--- olena/oln/core/gen/topo_bbox.hh (revision 612)
+++ olena/oln/core/gen/topo_bbox.hh (working copy)
@@ -29,7 +29,7 @@
# define OLN_CORE_GEN_TOPO_BBOX_HH
# include <oln/core/gen/bbox.hh>
-# include <oln/core/topology_entry.hh>
+# include <oln/core/abstract/topology.hh>
@@ -41,15 +41,6 @@
template <typename point> class topo_bbox_;
- // Super type declaration.
- template <typename point>
- struct set_super_type< topo_bbox_<point> >
- {
- typedef topo_bbox_<point> self_t;
- typedef topology_entry<self_t> ret;
- };
-
-
/// Virtual types associated to oln::bbox_<point>.
template <typename point>
struct vtypes< topo_bbox_<point> >
@@ -57,12 +48,14 @@
typedef bbox_<point> bbox_type;
typedef point point_type;
typedef mlc::true_ is_random_accessible_type;
+ typedef mlc::none neighborhood_type;
+ typedef mlc::none morpher_type;
};
/// Bounding box topology based on a point class.
template <typename point>
- class topo_bbox_ : public topology_entry< topo_bbox_<point> >
+ class topo_bbox_ : public abstract::topology< topo_bbox_<point> >
{
typedef topo_bbox_<point> self_t;
typedef topology_entry<self_t> super_t;
Index: olena/oln/core/gen/topo_lbbox.hh
===================================================================
--- olena/oln/core/gen/topo_lbbox.hh (revision 612)
+++ olena/oln/core/gen/topo_lbbox.hh (working copy)
@@ -29,7 +29,7 @@
# define OLN_CORE_GEN_TOPO_LBBOX_HH
# include <oln/core/gen/bbox.hh>
-# include <oln/core/topology_entry.hh>
+# include <oln/core/abstract/topology.hh>
@@ -41,15 +41,6 @@
template <typename point> class topo_lbbox_;
- // Super type declaration.
- template <typename point>
- struct set_super_type< topo_lbbox_<point> >
- {
- typedef topo_lbbox_<point> self_t;
- typedef topology_entry<self_t> ret;
- };
-
-
/// Virtual types associated to oln::bbox_<point>.
template <typename point>
struct vtypes< topo_lbbox_<point> >
@@ -57,12 +48,14 @@
typedef bbox_<point> bbox_type;
typedef point point_type;
typedef mlc::true_ is_random_accessible_type;
+ typedef mlc::none neighborhood_type;
+ typedef mlc::none morpher_type;
};
/// Bounding box topology based on a point class.
template <typename point>
- class topo_lbbox_ : public topology_entry< topo_lbbox_<point> >
+ class topo_lbbox_ : public abstract::topology< topo_lbbox_<point> >
{
typedef bbox_<point> bbox_t;
Index: olena/oln/core/internal/tracked_ptr.hh
===================================================================
--- olena/oln/core/internal/tracked_ptr.hh (revision 612)
+++ olena/oln/core/internal/tracked_ptr.hh (working copy)
@@ -94,7 +94,6 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- tracked_ptr<T>::
tracked_ptr<T>::operator bool() const
{
invariant_();
@@ -227,6 +226,7 @@
invariant(holders_->size() > 0);
tracked_ptr<T>* this_ = const_cast<tracked_ptr<T>*>(this);
invariant(holders_->find(this_) != holders_->end());
+ this_ = 0;
typename holders_t::const_iterator i;
for (i = holders_->begin(); i != holders_->end(); ++i)
invariant((*i)->ptr_ == ptr_);
Index: olena/oln/core/internal/topology_morpher.hh
===================================================================
--- olena/oln/core/internal/topology_morpher.hh (revision 612)
+++ olena/oln/core/internal/topology_morpher.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_INTERNAL_TOPOLOGY_MORPHER_HH
# define OLN_CORE_INTERNAL_TOPOLOGY_MORPHER_HH
-# include <oln/core/topology_entry.hh>
+# include <oln/core/abstract/topology.hh>
@@ -42,17 +42,18 @@
} // end of namespace oln::internal
+
template <typename Topo, typename E>
- struct set_pseudosuper_type< internal::topology_morpher<Topo, E> >
+ struct vtypes< internal::topology_morpher<Topo, E> >
{
- typedef Topo ret;
- };
+ typedef oln_type_of(Topo, bbox) bbox_type;
+ typedef oln_type_of(Topo, is_random_accessible) is_random_accessible_type;
+ typedef oln_type_of(Topo, point) point_type;
+ typedef oln_type_of(Topo, neighborhood) neighborhood_type;
- template <typename Topo, typename E>
- struct single_vtype< internal::topology_morpher<Topo, E>,
typedef_::morpher_type >
- {
- typedef morpher::tag::identity ret;
+ typedef morpher::tag::identity morpher_type;
};
+
template <typename Topo, typename E>
struct single_vtype< internal::topology_morpher<Topo, E>,
typedef_::delegated_type >
@@ -67,8 +68,28 @@
/// Base internal class for morphers on topology.
template <typename Topo, typename E>
- struct topology_morpher : public topology_entry<E>
+ struct topology_morpher : public abstract::topology<E>
{
+ public:
+
+ // Bbox.
+
+ const oln_type_of(E, bbox)& impl_bbox() const;
+ oln_type_of(E, bbox)& impl_bbox();
+
+ // Subset.
+
+ const oln_type_of(E, subset)& impl_subset() const;
+
+ // Neighborhood.
+
+ const oln_type_of(E, neighborhood)& impl_neighborhood() const;
+
+ // Random access.
+
+ bool impl_has(const oln_type_of(E, point)& p) const;
+ bool impl_has_large(const oln_type_of(E, point)& p) const;
+
protected:
topology_morpher();
};
@@ -80,6 +101,56 @@
{
}
+ // Bbox.
+
+ template <typename Topo, typename E>
+ const oln_type_of(E, bbox)&
+ topology_morpher<Topo, E>::impl_bbox() const
+ {
+ return this->exact().delegate().bbox();
+ }
+
+ template <typename Topo, typename E>
+ oln_type_of(E, bbox)&
+ topology_morpher<Topo, E>::impl_bbox()
+ {
+ return this->exact().delegate().bbox();
+ }
+
+ // Subset.
+
+ template <typename Topo, typename E>
+ const oln_type_of(E, subset)&
+ topology_morpher<Topo, E>::impl_subset() const
+ {
+ return this->exact().delegate().subset();
+ }
+
+ // Neighborhood.
+
+ template <typename Topo, typename E>
+ const oln_type_of(E, neighborhood)&
+ topology_morpher<Topo, E>::impl_neighborhood() const
+ {
+ return this->exact().delegate().neighborhood();
+ }
+
+ // Random access.
+
+ template <typename Topo, typename E>
+ bool
+ topology_morpher<Topo, E>::impl_has(const oln_type_of(E, point)& p) const
+ {
+ return this->exact().delegate().has(p);
+ }
+
+ template <typename Topo, typename E>
+ bool
+ topology_morpher<Topo, E>::impl_has_large(const oln_type_of(E, point)& p)
const
+ {
+ return this->exact().delegate().has_large(p);
+ }
+
# endif
} // end of namespace oln::internal