observer_collection.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/observer_collection.hpp
  4. [begin_description]
  5. Collection of observers, which are all called during the evolution of the ODE.
  6. [end_description]
  7. Copyright 2011-2012 Karsten Ahnert
  8. Copyright 2011-2012 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED
  15. #include <vector>
  16. #include <boost/function.hpp>
  17. namespace boost {
  18. namespace numeric {
  19. namespace odeint {
  20. template< class State , class Time >
  21. class observer_collection
  22. {
  23. public:
  24. typedef boost::function< void( const State& , const Time& ) > observer_type;
  25. typedef std::vector< observer_type > collection_type;
  26. void operator()( const State& x , Time t )
  27. {
  28. for( size_t i=0 ; i<m_observers.size() ; ++i )
  29. m_observers[i]( x , t );
  30. }
  31. collection_type& observers( void ) { return m_observers; }
  32. const collection_type& observers( void ) const { return m_observers; }
  33. private:
  34. collection_type m_observers;
  35. };
  36. } // namespace odeint
  37. } // namespace numeric
  38. } // namespace boost
  39. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_OBSERVER_COLLECTION_HPP_INCLUDED