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

Last change on this file since 1704 was 1704, checked in by yushan, 5 years ago

Introducing the new graph functionality. Attribute build_workflow_graph=.TRUE. is used in the field definition section in the xml file to enable the workflow graph of the field and other fields referecing to it. A more detailed document will be available soon on the graph fuctionality.

File size: 2.0 KB
Line 
1#ifndef __XIOS_CGarbageCollector__
2#define __XIOS_CGarbageCollector__
3
4#include <map>
5#include <set>
6
7#include "date.hpp"
8
9namespace xios
10{
11  /*!
12   * Interface shared by all objects that might need to invalidate packets.
13   */
14  struct InvalidableObject
15  {
16    /*!
17     * Removes all pending packets which are older than the specified timestamp.
18     *
19     * \param timestamp the timestamp used for invalidation
20     */
21    void virtual invalidate(Time timestamp) = 0;
22 
23   
24
25    static int filterIdGenerator;
26
27    static int edgeIdGenerator;
28
29    static int clusterIdGenerator;
30
31   
32   
33  }; // struct InvalidableObject
34
35  /*!
36   * A basic garbage collector which ensures no old packets linger in the filter graph.
37   */
38  class CGarbageCollector
39  {
40    public:
41      /*!
42       * Constructs a garbage collector.
43       */
44      CGarbageCollector()
45      { /* Nothing to do */ };
46
47      /*!
48       * Registers an object for a specified timestamp.
49       *
50       * \param object the object to register
51       * \param timestamp the timestamp for which the object is registered
52       */
53      void registerObject(InvalidableObject* object, Time timestamp);
54
55      /*!
56       * Removes a object previously registered for a specified timestamp.
57       *
58       * \param object the object to unregister
59       * \param timestamp the timestamp for which the object is unregistered
60       */
61      void unregisterObject(InvalidableObject* object, Time timestamp);
62
63      /*!
64       * Ensures all registered objects invalidate packets older than the specified timestamp.
65       *
66       * \param timestamp the timestamp used for invalidation
67       */
68      void invalidate(Time timestamp);
69
70    private:
71      CGarbageCollector(const CGarbageCollector&);
72      CGarbageCollector& operator=(const CGarbageCollector&);
73
74      std::map<Time, std::set<InvalidableObject*> > registeredObjects; //!< Currently registered objects
75  }; // class CGarbageCollector
76} // namespace xios
77
78#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.