2 #include "mof/stream/Manipulator.hpp"
3 #include <mof/Timer.hpp>
7 unsigned long get_global_ts();
10 class Cache : public Manipulator< T >
14 typedef typename std::shared_ptr<Cache> Handler;
18 virtual T value( FrameNumber frame ) const
20 if (local_ts_ < mof::get_global_ts() || m_lastFrame != frame) {
22 local_ts_ = mof::Timer::getSystemTime();
24 m_cached = m_pBody->value(frame);
31 typename Manipulator<T>::Handler m_pBody;
32 mutable FrameNumber m_lastFrame;
34 mutable unsigned long local_ts_;
36 Cache(const typename Manipulator<T>::Handler& pBody)
37 : m_pBody(pBody) , m_lastFrame(0), local_ts_(0)
41 template<typename T > friend
42 typename std::shared_ptr< Cache<T> > makeCacheHandler
44 const typename Manipulator<T>::Handler& pBody
51 template< typename T >
52 std::shared_ptr< Cache< T > > makeCacheHandler
54 const typename Manipulator< T >::Handler& pBody
57 return typename Cache< T >::Handler(
58 new Cache< T >( pBody )