4399: Introduce new structures for objects links and groups.

* core/object_groups.hh, * core/object_links.hh: New. --- scribo/ChangeLog | 7 ++ scribo/core/object_groups.hh | 125 ++++++++++++++++++++++++++++++++++++++++++ scribo/core/object_links.hh | 114 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+), 0 deletions(-) create mode 100644 scribo/core/object_groups.hh create mode 100644 scribo/core/object_links.hh diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 23c8c0d..24f7305 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,3 +1,10 @@ +2009-08-25 Guillaume Lazzara <lazzara@lrde.epita.fr> + + Introduce new structures for objects links and groups. + + * core/object_groups.hh, + * core/object_links.hh: New. + 2009-08-24 Guillaume Lazzara <lazzara@lrde.epita.fr> New object grouping routine based on a rag. diff --git a/scribo/core/object_groups.hh b/scribo/core/object_groups.hh new file mode 100644 index 0000000..3e49942 --- /dev/null +++ b/scribo/core/object_groups.hh @@ -0,0 +1,125 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to produce +// an executable, this file does not by itself cause the resulting +// executable to be covered by the GNU General Public License. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef SCRIBO_CORE_OBJECT_GROUPS_HH +# define SCRIBO_CORE_OBJECT_GROUPS_HH + +/// \file +/// +/// \brief Object groups representation. +/// +/// \fixme Should not inherit from util::array. + +# include <mln/util/array.hh> + +# include <scribo/core/object_links.hh> +# include <scribo/core/object_image.hh> + +namespace scribo +{ + + using namespace mln; + + + /// \brief Object group representation. + // + template <typename L> + class object_groups + : public mln::util::array<unsigned> + { + typedef mln::util::array<unsigned> super_t; + + public: + object_groups(const object_image(L)& objects); + object_groups(const object_image(L)& objects, unsigned n); + object_groups(const object_image(L)& objects, unsigned n, unsigned value); + + const void* objects_id_() const; + const object_image(L)& object_image_() const; + + void init_(const object_links<L>& links); + + private: + object_image(L) objects_; + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename L> + object_groups<L>::object_groups(const object_image(L)& objects) + : objects_(objects) + { + + } + + + template <typename L> + object_groups<L>::object_groups(const object_image(L)& objects, unsigned n) + : super_t(n), objects_(objects) + { + + } + + + template <typename L> + object_groups<L>::object_groups(const object_image(L)& objects, + unsigned n, unsigned value) + : super_t(n, value), objects_(objects) + { + + } + + template <typename L> + const void* + object_groups<L>::objects_id_() const + { + return objects_.id_(); + } + + template <typename L> + const object_image(L)& + object_groups<L>::object_image_() const + { + return objects_; + } + + + template <typename L> + void + object_groups<L>::init_(const object_links<L>& links) + { + objects_ = links.object_image_(); + this->hook_std_vector_() = links.std_vector(); + } + + +# endif // ! MLN_INCLUDE_ONLY + + +} // end of namespace scribo + + +#endif // ! SCRIBO_CORE_OBJECT_GROUPS_HH diff --git a/scribo/core/object_links.hh b/scribo/core/object_links.hh new file mode 100644 index 0000000..aa70bf8 --- /dev/null +++ b/scribo/core/object_links.hh @@ -0,0 +1,114 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to produce +// an executable, this file does not by itself cause the resulting +// executable to be covered by the GNU General Public License. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +#ifndef SCRIBO_CORE_OBJECT_LINKS_HH +# define SCRIBO_CORE_OBJECT_LINKS_HH + +/// \file +/// +/// \brief Object links representation. +/// +/// \fixme Should not inherit from util::array. + +# include <mln/util/array.hh> + +# include <scribo/core/object_image.hh> + + +namespace scribo +{ + + using namespace mln; + + /// \brief Object group representation. + // + template <typename L> + class object_links + : public mln::util::array<unsigned> + { + typedef mln::util::array<unsigned> super_t; + + public: + object_links(const object_image(L)& objects); + object_links(const object_image(L)& objects, unsigned n); + object_links(const object_image(L)& objects, unsigned n, unsigned value); + + + const void* objects_id_() const; + const object_image(L)& object_image_() const; + + private: + object_image(L) objects_; + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename L> + object_links<L>::object_links(const object_image(L)& objects) + : objects_(objects) + { + + } + + template <typename L> + object_links<L>::object_links(const object_image(L)& objects, unsigned n) + : super_t(n), objects_(objects) + { + + } + + + template <typename L> + object_links<L>::object_links(const object_image(L)& objects, + unsigned n, unsigned value) + : super_t(n, value), objects_(objects) + { + + } + + + template <typename L> + const void * + object_links<L>::objects_id_() const + { + return objects_.id_(); + } + + template <typename L> + const object_image(L)& + object_links<L>::object_image_() const + { + return objects_; + } + + +# endif // ! MLN_INCLUDE_ONLY + + +} // end of namespace scribo + + +#endif // ! SCRIBO_CORE_OBJECT_LINKS_HH -- 1.5.6.5
participants (1)
-
Guillaume Lazzara