fifofilter.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __mia_fifofilter_hh
#define __mia_fifofilter_hh
#include <vector>
#include <memory>
#include <cstdlib>
#include <boost/call_traits.hpp>
#include <mia/core/msgstream.hh>
#ifndef EXPORT_HANDLER
#ifdef WIN32
#define EXPORT_HANDLER __declspec(dllimport)
#else
#define EXPORT_HANDLER
#endif
#endif
NS_MIA_BEGIN
template <typename T>
class EXPORT_HANDLER TFifoFilter
{
public:
typedef std::shared_ptr<TFifoFilter > Pointer;
TFifoFilter(size_t width, size_t min_fill, size_t read_start);
void push(typename ::boost::call_traits<T>::param_type x);
void finalize();
void append_filter(Pointer last);
protected:
size_t get_pos() const;
size_t get_buffer_size() const;
size_t get_start() const;
size_t get_end() const;
private:
Pointer next() const;
virtual void do_initialize(typename ::boost::call_traits<T>::param_type x);
virtual void do_push(typename ::boost::call_traits<T>::param_type x) = 0;
virtual T do_filter();
virtual void post_finalize();
virtual void shift_buffer();
virtual void evaluate(size_t slice);
size_t m_buf_size;
size_t m_min_fill;
size_t m_read_start;
size_t m_fill;
size_t m_start_slice;
size_t m_end_slice;
Pointer m_chain;
bool m_initialized;
};
template <typename T>
class EXPORT_HANDLER TFifoFilterSink : public TFifoFilter<T>
{
public:
typedef std::vector<T> result_type;
typedef std::shared_ptr< TFifoFilterSink<T>> Pointer;
TFifoFilterSink();
const result_type& result();
private:
virtual void do_push(typename ::boost::call_traits<T>::param_type x);
void shift_buffer();
result_type m_result;
};
template <typename T>
struct __copy_create_ptr {
static std::shared_ptr<T > apply (typename ::boost::call_traits<T>::param_type x)
{
return std::shared_ptr<T >(new T(x));
}
};
NS_MIA_END
#endif
TFifoFilterSink::Pointer
std::shared_ptr< TFifoFilterSink< T > > Pointer
smart pointer representing this class
Definition fifofilter.hh:165
TFifoFilterSink::TFifoFilterSink
TFifoFilterSink()
TFifoFilterSink::result_type
std::vector< T > result_type
The result of the processing.
Definition fifofilter.hh:162
TFifoFilterSink::result
const result_type & result()
TFifoFilter::Pointer
std::shared_ptr< TFifoFilter > Pointer
smart pointer representing this class
Definition fifofilter.hh:57
TFifoFilter::get_buffer_size
size_t get_buffer_size() const
TFifoFilter::finalize
void finalize()
TFifoFilter::get_start
size_t get_start() const
TFifoFilter::get_end
size_t get_end() const
TFifoFilter::get_pos
size_t get_pos() const
TFifoFilter::TFifoFilter
TFifoFilter(size_t width, size_t min_fill, size_t read_start)
TFifoFilter::push
void push(typename ::boost::call_traits< T >::param_type x)
TFifoFilter::append_filter
void append_filter(Pointer last)
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition fifofilter.hh:34
msgstream.hh