26 #ifndef SHORE_PROCESSING_BUFFER_CHAIN_HPP__
27 #define SHORE_PROCESSING_BUFFER_CHAIN_HPP__
50 std::deque<T *> m_buffers;
53 std::vector<T *> m_unused;
56 std::vector<plugin_type *> m_plugins;
71 while(m_next_plugin<m_plugins.size())
74 m_plugins[m_next_plugin]->apply(m_buffers,
78 if(result&plugin_type::PLUGIN_STARVED)
80 if(result&plugin_type::PLUGIN_END)
86 if(result&plugin_type::PLUGIN_END)
94 return !m_buffers.empty();
113 throw_exception(std::logic_error(
"buffer_chain_push()"
114 " not allowed here"));
117 m_buffers.push_back(
new T);
120 m_buffers.push_back(m_unused.back());
124 return *(m_buffers.back());
133 throw_exception(std::logic_error(
"buffer_chain_prepare()"
134 " not allowed here"));
136 m_ready=apply_plugins();
149 throw_exception(std::logic_error(
"buffer_chain_flush()"
150 " not allowed here"));
152 if(undo_last_push&&(!m_buffers.empty()))
154 m_unused.push_back(m_buffers.back());
155 m_buffers.pop_back();
160 m_ready=apply_plugins();
170 return *m_buffers.front();
178 return !(m_ready||m_flushed);
186 m_unused.push_back(m_buffers.front());
187 m_buffers.pop_front();
189 m_ready=apply_plugins();
199 while(!m_buffers.empty())
201 m_unused.push_back(m_buffers.back());
202 m_buffers.pop_back();
204 m_ready=m_flushed=
false;
211 T *
const ret=m_buffers.back();
212 m_buffers.back()=buf;
234 while(!m_unused.empty())
236 delete m_unused.back();
246 m_plugins.push_back(p);
258 #endif // SHORE_PROCESSING_BUFFER_CHAIN_HPP__