Mirror reflection library - Lagoon run-time layer 0.5.13

lagoon/range/container.hpp

Go to the documentation of this file.
00001 
00011 #ifndef LAGOON_RANGE_CONTAINER_1011291729_HPP
00012 #define LAGOON_RANGE_CONTAINER_1011291729_HPP
00013 
00014 #include <lagoon/utils.hpp>
00015 #include <cassert>
00016 
00017 LAGOON_NAMESPACE_BEGIN
00018 namespace aux {
00019 
00020 // Base class for the container range wrapping the container storing
00021 // the items
00022 template <class Container>
00023 class container_range_wrap
00024 {
00025 protected:
00026     Container container;
00027 
00028     container_range_wrap(void){ }
00029 
00030     container_range_wrap(container_range_wrap&& other)
00031      : container(std::move(other.container))
00032     { }
00033 
00034     container_range_wrap(Container&& cntr)
00035      : container(std::forward<Container>(cntr))
00036     { }
00037 
00038     template <class Iterator>
00039     container_range_wrap(const Iterator& b, const Iterator& e)
00040       : container(b, e)
00041     { }
00042 };
00043 
00044 // Forward declaration of the container range template
00045 //
00046 // MetaObject - the meta_object type traversed by the range
00047 // ItemContainer - container type used for storing the items from the
00048 //   adapted range in this range
00049 // ContainerFiller - helper class that fills the container with the elements
00050 //   from the adapted range during construction
00051 // ContainerTransform - helper class that transforms the container during
00052 //   construction of container_range
00053 template <
00054     class Container,
00055     class ContainerFiller,
00056     class ContainerTransform
00057 > class container_range;
00058 
00059 template <
00060     typename MetaObject,
00061     template <class ...> class ContainerTempl,
00062     class ... P,
00063     class ContainerFiller,
00064     class ContainerTransform
00065 > class container_range<
00066     ContainerTempl<shared<MetaObject>, P...>,
00067     ContainerFiller,
00068     ContainerTransform
00069 >: private container_range_wrap<ContainerTempl<shared<MetaObject>, P...> >
00070  , private ContainerFiller
00071  , private ContainerTransform
00072  , public range_base<
00073     MetaObject,
00074     typename ContainerTempl<shared<MetaObject>, P...>::const_iterator
00075 >
00076 {
00077 private:
00078     typedef ContainerTempl<shared<MetaObject>, P...> base_container;
00079     typedef container_range_wrap<base_container> base_wrapper;
00080     typedef ContainerFiller base_filler;
00081     typedef ContainerTransform base_transform;
00082     typedef range_base<
00083         MetaObject,
00084         typename base_container::const_iterator
00085     > base_range;
00086     friend class lagoon::aux::std_range_adapt<
00087         container_range<
00088             base_container,
00089             base_filler,
00090             base_transform
00091         >
00092     >;
00093 public:
00094     template <typename Range, typename TransformParam>
00095     inline container_range(
00096         const Range& other_range,
00097         TransformParam transf_param
00098     ): base_filler(other_range, this->container)
00099      , base_transform(transf_param, this->container)
00100      , base_range(this->container.begin(), this->container.end())
00101     { }
00102 
00103     template <typename StdRange, typename TransformParam>
00104     inline container_range(
00105         int,
00106         const StdRange& other_range,
00107         TransformParam transf_param
00108     ): base_wrapper(other_range.begin(), other_range.end())
00109      , base_transform(transf_param, this->container)
00110      , base_range(this->container.begin(), this->container.end())
00111     { }
00112 };
00113 
00114 template <class Container>
00115 class simple_container_range;
00116 
00117 template <
00118     class MetaObject,
00119     template <class ...> class ContainerTempl,
00120     class ... P
00121 > class simple_container_range<
00122     ContainerTempl<shared<MetaObject>, P...>
00123 >: private container_range_wrap<ContainerTempl<shared<MetaObject>, P...> >
00124  , public range_base<
00125     MetaObject,
00126     typename ContainerTempl<shared<MetaObject>, P...>::const_iterator
00127 >
00128 {
00129 private:
00130     typedef ContainerTempl<shared<MetaObject>, P...> base_container;
00131     typedef container_range_wrap<base_container> base_wrapper;
00132     typedef range_base<
00133         MetaObject,
00134         typename base_container::const_iterator
00135     > base_range;
00136 
00137     friend class lagoon::aux::std_range_adapt<
00138         simple_container_range<base_container>
00139     >;
00140 public:
00141     simple_container_range(base_container&& cntr)
00142      : base_wrapper(std::forward<base_container>(cntr))
00143      , base_range(this->container.begin(), this->container.end())
00144     { }
00145 
00146     simple_container_range(simple_container_range&& other)
00147      : base_wrapper(std::move(other))
00148      , base_range(this->container.begin(), this->container.end())
00149     { }
00150 
00151     simple_container_range(const simple_container_range& other)
00152      : base_wrapper(other)
00153      , base_range(this->container.begin(), this->container.end())
00154     { }
00155 };
00156 
00157 } // namespace aux
00158 LAGOON_NAMESPACE_END
00159 
00160 #endif //include guard
00161 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.