Mirror reflection library - Lagoon run-time layer 0.5.13

lagoon/range/extract.hpp

Go to the documentation of this file.
00001 
00010 #ifndef LAGOON_RANGE_EXTRACT_1011291729_HPP
00011 #define LAGOON_RANGE_EXTRACT_1011291729_HPP
00012 
00013 #include <lagoon/lagoon_fwd.hpp>
00014 #include <lagoon/range/only_if.hpp>
00015 #include <lagoon/range/transform.hpp>
00016 
00017 LAGOON_NAMESPACE_BEGIN
00018 namespace aux {
00019 
00020 template <class Interface>
00021 struct mo_has_intf
00022 {
00023     template <class MetaObject>
00024     inline bool operator()(const MetaObject& metaobject) const
00025     {
00026         return metaobject.template is<Interface>();
00027     }
00028 };
00029 
00030 template <class Interface>
00031 struct mo_query_intf
00032 {
00033     template <class MetaObject>
00034     inline auto operator()(const MetaObject& metaobject) const ->
00035         decltype(metaobject.template as<Interface>())
00036     {
00037         return metaobject.template as<Interface>();
00038     }
00039 };
00040 
00041 } // namespace aux
00042 
00043 #ifdef MIRROR_DOCUMENTATION_ONLY
00044 
00045 
00054 template <class Interface, class Range>
00055 UnspecifiedRange<Interface> extract(const Range& metaobjects);
00056 #else
00057 template <class Interface, class Range>
00058 auto extract(const Range& metaobjects) ->
00059 decltype(
00060     transform(
00061         only_if(
00062             metaobjects,
00063             aux::mo_has_intf<Interface>()
00064         ),
00065         aux::mo_query_intf<Interface>()
00066     )
00067 )
00068 {
00069     return transform(
00070         only_if(
00071             metaobjects,
00072             aux::mo_has_intf<Interface>()
00073         ),
00074         aux::mo_query_intf<Interface>()
00075     );
00076 }
00077 #endif
00078 
00079 LAGOON_NAMESPACE_END
00080 
00081 #endif //include guard
00082 

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.