Commit 649d49ab authored by Roland Levillain's avatar Roland Levillain
Browse files

Lay the foundation stone of abstract::image.

	* oln/core/abstract/any.hh, oln/core/typedefs.hh,
	* oln/core/abstract/image.hh,
	* oln/core/abstract/internal/image_impl.hh
	* oln/core/abstract/image_entry.hh
	* oln/core/abstract/image_dimension.hh: New files (imported from
	Olena proto-1.0, and modified).
	* oln/core/abstract/macros.hh: New file.
	* tests/image_entry.cc: New test.
	* Makefile.am, oln/Makefile.am, tests/Makefile.am: New files.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@462 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 9c31ec27
2006-04-21 Roland Levillain <roland@lrde.epita.fr>
Lay the foundation stone of abstract::image.
* oln/core/abstract/any.hh, oln/core/typedefs.hh,
* oln/core/abstract/image.hh,
* oln/core/abstract/internal/image_impl.hh
* oln/core/abstract/image_entry.hh
* oln/core/abstract/image_dimension.hh: New files (imported from
Olena proto-1.0, and modified).
* oln/core/abstract/macros.hh: New file.
* tests/image_entry.cc: New test.
* Makefile.am, oln/Makefile.am, tests/Makefile.am: New files.
## Process this file through Automake to create Makefile.in -*- Makefile -*-
SUBDIRS = oln tests
## Process this file through Automake to create Makefile.in -*- Makefile -*-
olndir = $(includedir)/oln
nobase_oln_HEADERS = \
core/typedefs.hh \
\
core/abstract/any.hh \
core/abstract/image.hh \
core/abstract/image_entry.hh \
core/abstract/image_dimension.hh \
core/abstract/macros.hh \
\
core/abstract/internal/image_impl.hh
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_ANY_HH
# define OLENA_CORE_ABSTRACT_ANY_HH
# include <mlc/any.hh>
# include <mlc/bool.hh>
# include <mlc/is_a.hh>
namespace oln {
namespace abstract {
template <typename E>
struct any : public mlc::any<E, mlc::dispatch_policy::simple>
{
protected:
typedef mlc::any<E, mlc::dispatch_policy::simple> super;
any(E* exact_ptr) : super(exact_ptr) {}
any() {}
};
template <typename E>
struct any_best_speed :
public mlc::any<E, mlc::dispatch_policy::best_speed>
{
protected:
typedef mlc::any<E, mlc::dispatch_policy::best_speed> super;
any_best_speed(E* exact_ptr = 0) : super(exact_ptr) {}
};
} // end of namespace oln::abstract
} // end of namespace oln
# define oln_is_any(Type) \
mlc::or_< mlc_is_a(Type, oln::abstract::any), \
mlc_is_a(Type, oln::abstract::any_best_speed) >
#endif // ! OLENA_CORE_ABSTRACT_ANY_HH
This diff is collapsed.
// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
# define OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
# include <oln/core/abstract/image.hh>
/*! \namespace oln
** \brief oln namespace.
*/
namespace oln {
/*! \namespace oln::abstract
** \brief oln::abstract namespace.
*/
namespace abstract {
/*! \class abstract::image1d<E>
**
** Class of 1d images.
*/
template <typename E>
struct image1d : public virtual image<E>
{
protected:
/*! \brief Constructor (protected, empty).
*/
image1d() {}
};
/*! \class abstract::image2d<E>
**
** Class of 2d images.
*/
template <typename E>
struct image2d : public virtual image<E>
{
protected:
/*! \brief Constructor (protected, empty).
*/
image2d() {}
};
/*! \class abstract::image3d<E>
**
** Class of 3d images.
*/
template <typename E>
struct image3d : public virtual image<E>
{
protected:
/*! \brief Constructor (protected, empty).
*/
image3d() {}
};
} // end of namespace oln::abstract
} // end of namespace oln
// Register the dimension switch for oln::abstract::image_entry.
namespace stc
{
template <typename E>
struct set_entry_node<E, oln::abstract::dimension_tag> :
// FIXME: Don't use the abstraction as a property, but the
// corresponding grid instead.
public oln_type_of_(E, image_dimension)
::template instantiated_with<E>::ret
{
};
}
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
# define OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
# include <oln/core/abstract/image.hh>
# include <stc/entry.hh>
namespace oln
{
namespace abstract
{
// Forward declaration.
template <typename E> struct image_entry;
}
/// \brief Uplink.
///
/// oln::abstract::image<E> is not the direct super type of
/// oln::abstract::image_entry<E>, however, it is declared as such
/// using set_super_type, to make the virtual type retrieval system
/// work.
template <typename E>
struct set_super_type< abstract::image_entry<E> >
{
typedef abstract::image<E> ret;
};
namespace abstract
{
template <typename E>
struct image_entry : public stc::entry<E>
{
protected:
image_entry() {}
};
/// \brief Tags for abstractions.
/// Use them instead of hard-coded numbers.
enum abstraction_tags
{
dimension_tag = 1,
constness_tag
// ...
};
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
# define OLENA_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
# include <mlc/flags.hh>
# include <oln/core/typedefs.hh>
# include <oln/core/abstract/any.hh>
# include <oln/core/abstract/macros.hh>
// FIXME: To be rewtitten using Metalic's switch/case?
namespace oln
{
/// Image category.
namespace category
{
struct image;
}
namespace abstract
{
namespace internal
{
/* A summary of the implementation retrieval mechanism.
any_best_speed<E> any_best_speed<E>
^ ^
| |
|(*) |
| |
set_image_impl<A, E> |
^ |
| |
get_image_impl_helper<A, D, E> get_image_impl_helper<A, mlc::no_type, E>
| |
`--------------. ,-----------------'
| |
o o
o
|
get_image_impl<E>
^
|
image<E>
^
|
...
^
|
E
(client)
The D parameter is the delegated type. If there is no
delegated type (i.e. D = mlc::none), get_image_impl inherits
from oln::any_best_speed (trough get_image_impl_helper);
otherwise, get_image_impl is plugged to set_image_impl, a
class than can specialized by the user.
(*) This relation is not mandatory (set_image_impl is to be
defined by the user), but it every specialization of
set_image_impl *should* inherit from oln::any_best_speed. */
template <typename A, typename D, typename E>
struct get_image_impl_helper;
// Entry point.
template <typename A, typename E>
struct get_image_impl :
public get_image_impl_helper <A, oln_type_of(E, delegated), E>
{
};
template <typename A, typename E>
struct get_image_impl_helper <A, mlc::none, E> :
public virtual oln::abstract::any_best_speed<E>
{
// No implementation.
};
// To be specialized.
template <typename A, typename E>
struct set_image_impl;
template <typename A, typename D, typename E>
struct get_image_impl_helper : public set_image_impl<A, E>
{
// Implementation comes from internal::set_image_impl<A, E>.
};
/// \brief Abstraction factorization for the delegation mechanism.
///
/// set_image_impl specializations should inherit from this
/// class (as a public virtual derivation).
template <typename E>
struct image_impl :
public virtual oln::abstract::any_best_speed<E>
{
typedef oln_type_of(E, delegated) D;
D& delegate() { return this->exact().impl_delegate(); }
const D& delegate() const { return this->exact().impl_delegate(); }
};
} // end of namespace oln::abstract::internal
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
// Copyright (C) 2006 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_MACROS_HH
# define OLENA_CORE_ABSTRACT_MACROS_HH
// FIXME: Perhaps only ``external'' versions are really useful (since
// they are more precise), and we could get rid of other versions.
// Likewise, we could drop the stc_typeof without namespace
// information.
/// \def Shortcuts for virtual types associated to images (version to
// be used inside a template).
# define oln_type_of(ImageType, Alias) \
stc_typeof_in_namespace(oln, oln::category::image, ImageType, Alias)
/// \def Shortcuts for virtual types associated to images (version to
// be used outside a template).
# define oln_type_of_(ImageType, Alias) \
stc_typeof_in_namespace_(oln, oln::category::image, ImageType, Alias)
#endif // ! OLENA_CORE_ABSTRACT_MACROS_HH
// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_TYPEDEFS_HH
# define OLENA_CORE_TYPEDEFS_HH
# include <iostream>
# include <mlc/contract.hh>
# include <mlc/flags.hh>
# include <mlc/cmp.hh>
# include <mlc/typedef.hh>
# include <stc/properties.hh>
# define oln_super_of_(Type) \
oln::internal::get_super_type<Type>::ret
# define oln_super2_of_(Type,_2) \
oln::internal::get_super_type<Type,_2>::ret
# define oln_super3_of_(Type,_2,_3) \
oln::internal::get_super_type<Type,_2,_3>::ret
# define oln_super_of(Type) \
typename oln_super_of_(Type)
namespace oln
{
// Namespace equipment.
stc_equip_namespace_with_properties();
// Misc.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(exact_type);
// --------------------------------------------------------------------
// General.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(grid_type);
// --------------------------------------------------------------------
// Iterators.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(iter_type);
// mlc_decl_typedef(fwd_iter_type);
// mlc_decl_typedef(bkd_iter_type);
// mlc_decl_typedef(piter_type);
// mlc_decl_typedef(fwd_piter_type);
// mlc_decl_typedef(bkd_piter_type);
// mlc_decl_typedef(qiter_type);
// mlc_decl_typedef(fwd_qiter_type);
// mlc_decl_typedef(bkd_qiter_type);
// mlc_decl_typedef(niter_type);
// mlc_decl_typedef(fwd_niter_type);
// mlc_decl_typedef(bkd_niter_type);
// --------------------------------------------------------------------
// category::image.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(data_type);
// mlc_decl_typedef(value_type);
// mlc_decl_typedef(neighb_type);
// mlc_decl_typedef(value_storage_type);
// mlc_decl_typedef(storage_type);
// mlc_decl_typedef(point_type);
// mlc_decl_typedef(dpoint_type);
// mlc_decl_typedef(image_type);
// mlc_decl_typedef(concrete_type);
// --------------------------------------------------------------------
mlc_decl_typedef(delegated_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(size_type);
// mlc_decl_typedef(window_type);
// mlc_decl_typedef(image_neighbness_type);
// mlc_decl_typedef(image_constness_type);
// --------------------------------------------------------------------
mlc_decl_typedef(image_dimension_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(image_typeness_type);
// mlc_decl_typedef(image_valuedness_type);
// mlc_decl_typedef(image_rawness_type);
// --------------------------------------------------------------------
// Extension in image_operators.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(output_type);
// mlc_decl_typedef(input_type);
// mlc_decl_typedef(input1_type);
// mlc_decl_typedef(input2_type);
// --------------------------------------------------------------------
// category::grid.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(dimvalue_type);
// mlc_decl_typedef(coord_type);
// --------------------------------------------------------------------