source: XIOS/trunk/src/filter/garbage_collector.hpp @ 639

Last change on this file since 639 was 639, checked in by rlacroix, 9 years ago

Add a basic garbage collector to ensure no packets linger in the filter graph.

File size: 1.5 KB
Line 
1#ifndef __XIOS_CGarbageCollector__
2#define __XIOS_CGarbageCollector__
3
4#include <map>
5#include <set>
6
7#include "input_pin.hpp"
8
9namespace xios
10{
11  /*!
12   * A basic garbage collector which ensures no old packets linger in the filter graph.
13   */
14  class CGarbageCollector
15  {
16    public:
17      /*!
18       * Constructs a garbage collector.
19       */
20      CGarbageCollector()
21      { /* Nothing to do */ };
22
23      /*!
24       * Registers a filter for a specified timestamp.
25       *
26       * \param inputPin the input pin of the filter to register
27       * \param timestamp the timestamp for which the filter is registered
28       */
29      void registerFilter(CInputPin* inputPin, Time timestamp);
30
31      /*!
32       * Removes a filter previously registered for a specified timestamp.
33       *
34       * \param inputPin the input pin of the filter to unregister
35       * \param timestamp the timestamp for which the filter is unregistered
36       */
37      void unregisterFilter(CInputPin* inputPin, Time timestamp);
38
39      /*!
40       * Ensures all registered filters invalidate packets older than the specified timestamp.
41       *
42       * \param timestamp the timestamp used for invalidation
43       */
44      void invalidate(Time timestamp);
45
46    private:
47      CGarbageCollector(const CGarbageCollector&);
48      CGarbageCollector& operator=(const CGarbageCollector&);
49
50      std::map<Time, std::set<CInputPin*> > registeredFilters; //!< Currently registered filters
51  }; // class CGarbageCollector
52} // namespace xios
53
54#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.