BVB Source Codes

mars Show pipeline.hpp Source code

Return Download mars: download pipeline.hpp Source code - Download mars Source code - Type:.hpp
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2003-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5.  
  6. // See http://www.boost.org/libs/iostreams for documentation.
  7.  
  8. #ifndef BOOST_IOSTREAMS_PIPABLE_HPP_INCLUDED
  9. #define BOOST_IOSTREAMS_PIPABLE_HPP_INCLUDED
  10.  
  11. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  12. # pragma once
  13. #endif
  14.  
  15. #include <boost/config.hpp> // BOOST_MSVC.
  16. #include <boost/detail/workaround.hpp>          
  17. #include <boost/iostreams/detail/template_params.hpp>
  18. #include <boost/iostreams/traits.hpp>
  19. #include <boost/mpl/bool.hpp>
  20. #include <boost/preprocessor/punctuation/comma_if.hpp>
  21. #include <boost/preprocessor/repetition/enum_params.hpp>
  22. #include <boost/static_assert.hpp>
  23. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  24. # include <boost/type_traits/is_base_and_derived.hpp>
  25. #endif
  26.  
  27. #define BOOST_IOSTREAMS_PIPABLE(filter, arity) \
  28.     template< BOOST_PP_ENUM_PARAMS(arity, typename T) \
  29.               BOOST_PP_COMMA_IF(arity) typename Component> \
  30.     ::mars_boost::iostreams::pipeline< \
  31.         ::mars_boost::iostreams::detail::pipeline_segment< \
  32.             filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T) \
  33.         >, \
  34.         Component \
  35.     > operator|( const filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)& f, \
  36.                  const Component& c ) \
  37.     { \
  38.         typedef ::mars_boost::iostreams::detail::pipeline_segment< \
  39.                     filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T) \
  40.                 > segment; \
  41.         return ::mars_boost::iostreams::pipeline<segment, Component> \
  42.                    (segment(f), c); \
  43.     } \
  44.     /**/
  45.  
  46. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace iostreams {
  47.  
  48. template<typename Pipeline, typename Component>
  49. struct pipeline;
  50.    
  51. namespace detail {
  52.  
  53. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
  54.     struct pipeline_base { };
  55.  
  56.     template<typename T>
  57.     struct is_pipeline
  58.         : is_base_and_derived<pipeline_base, T>
  59.         { };
  60. #endif
  61. #if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
  62.     template<typename T>
  63.     struct is_pipeline : mpl::false_ { };
  64.  
  65.     template<typename Pipeline, typename Component>
  66.     struct is_pipeline< pipeline<Pipeline, Component> > : mpl::true_ { };
  67. #endif
  68.  
  69. template<typename Component>
  70. class pipeline_segment
  71. #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
  72.     : pipeline_base
  73. #endif
  74. {
  75. public:
  76.     pipeline_segment(const Component& component)
  77.         : component_(component)
  78.         { }
  79.     template<typename Fn>
  80.     void for_each(Fn fn) const { fn(component_); }
  81.     template<typename Chain>
  82.     void push(Chain& chn) const { chn.push(component_); }
  83. private:
  84.     pipeline_segment operator=(const pipeline_segment&);
  85.     const Component& component_;
  86. };
  87.  
  88. } // End namespace detail.
  89.                    
  90. //------------------Definition of Pipeline------------------------------------//
  91.  
  92. template<typename Pipeline, typename Component>
  93. struct pipeline : Pipeline {
  94.     typedef Pipeline   pipeline_type;
  95.     typedef Component  component_type;
  96.     pipeline(const Pipeline& p, const Component& component)
  97.         : Pipeline(p), component_(component)
  98.         { }
  99.     template<typename Fn>
  100.     void for_each(Fn fn) const
  101.     {
  102.         Pipeline::for_each(fn);
  103.         fn(component_);
  104.     }
  105.     template<typename Chain>
  106.     void push(Chain& chn) const
  107.     {
  108.         Pipeline::push(chn);
  109.         chn.push(component_);
  110.     }
  111.     const Pipeline& tail() const { return *this; }
  112.     const Component& head() const { return component_; }
  113. private:
  114.     pipeline operator=(const pipeline&);
  115.     const Component& component_;
  116. };
  117.  
  118. template<typename Pipeline, typename Filter, typename Component>
  119. pipeline<pipeline<Pipeline, Filter>, Component>
  120. operator|(const pipeline<Pipeline, Filter>& p, const Component& cmp)
  121. {
  122.     BOOST_STATIC_ASSERT(is_filter<Filter>::value);
  123.     return pipeline<pipeline<Pipeline, Filter>, Component>(p, cmp);
  124. }
  125.  
  126. } } // End namespaces iostreams, boost.
  127.  
  128. #endif // #ifndef BOOST_IOSTREAMS_PIPABLE_HPP_INCLUDED
  129.  
downloadpipeline.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top