Mirror reflection library - Lagoon run-time layer 0.5.13

lagoon/range/flatten.hpp

Go to the documentation of this file.
00001 
00010 #ifndef LAGOON_RANGE_FLATTEN_1011291729_HPP
00011 #define LAGOON_RANGE_FLATTEN_1011291729_HPP
00012 
00013 #include <lagoon/range/extract.hpp>
00014 #include <lagoon/range/link.hpp>
00015 #include <lagoon/range/container.hpp>
00016 #include <lagoon/range/for_each.hpp>
00017 #include <list>
00018 
00019 LAGOON_NAMESPACE_BEGIN
00020 
00021 
00022 namespace aux {
00023 
00024 void flatten_scope(
00025     linked<range<meta_named_scoped_object> >& dest,
00026     const shared<meta_scope>& scope
00027 )
00028 {
00029     dest.append(scope->members());
00030     for_each(
00031         extract<meta_scope>(scope->members()),
00032         [&dest](const shared<meta_scope>& member_scope) -> void
00033         {
00034             flatten_scope(dest, member_scope);
00035         }
00036     );
00037 }
00038 
00039 void flatten_in_order(
00040     std::list<shared<meta_named_scoped_object> >& dest,
00041     const shared<meta_scope>& scope
00042 )
00043 {
00044     for_each(
00045         scope->members(),
00046         [&dest](const shared<meta_named_scoped_object>& member) -> void
00047         {
00048             dest.push_back(member);
00049             if(member.is<meta_scope>())
00050                 flatten_in_order(dest,member.as<meta_scope>());
00051         }
00052     );
00053 }
00054 
00055 } // namespace aux
00056 
00057 #ifdef MIRROR_DOCUMENTATION_ONLY
00058 
00059 
00067 UnspecifiedRange<shared<meta_named_scoped_object> >
00068 flatten(const shared<meta_scope>& scope);
00069 
00071 
00080 UnspecifiedRange<shared<meta_named_scoped_object> >
00081 flatten_in_order(const shared<meta_scope>& scope);
00082 #else
00083 inline aux::linked<range<meta_named_scoped_object> >
00084 flatten(const shared<meta_scope>& scope)
00085 {
00086     aux::linked<range<meta_named_scoped_object> > result;
00087     aux::flatten_scope(result, scope);
00088     return result;
00089 }
00090 
00091 inline aux::simple_container_range<
00092     std::list<shared<meta_named_scoped_object> >
00093 > flatten_in_order(const shared<meta_scope>& scope)
00094 {
00095     std::list<shared<meta_named_scoped_object> > members;
00096     aux::flatten_in_order(members, scope);
00097     return aux::simple_container_range<
00098         std::list<shared<meta_named_scoped_object> >
00099     >(std::move(members));
00100 }
00101 #endif
00102 
00103 LAGOON_NAMESPACE_END
00104 
00105 #endif //include guard
00106 

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.