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
RevLine 
[639]1#ifndef __XIOS_CGarbageCollector__
2#define __XIOS_CGarbageCollector__
3
4#include <map>
5#include <set>
6
[1021]7#include "date.hpp"
[639]8
9namespace xios
10{
11  /*!
[1021]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;
[1704]22 
23   
24
25    static int filterIdGenerator;
26
27    static int edgeIdGenerator;
28
29    static int clusterIdGenerator;
30
31   
32   
[1021]33  }; // struct InvalidableObject
34
35  /*!
[639]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      /*!
[1021]48       * Registers an object for a specified timestamp.
[639]49       *
[1021]50       * \param object the object to register
51       * \param timestamp the timestamp for which the object is registered
[639]52       */
[1021]53      void registerObject(InvalidableObject* object, Time timestamp);
[639]54
55      /*!
[1021]56       * Removes a object previously registered for a specified timestamp.
[639]57       *
[1021]58       * \param object the object to unregister
59       * \param timestamp the timestamp for which the object is unregistered
[639]60       */
[1021]61      void unregisterObject(InvalidableObject* object, Time timestamp);
[639]62
63      /*!
[1021]64       * Ensures all registered objects invalidate packets older than the specified timestamp.
[639]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
[1021]74      std::map<Time, std::set<InvalidableObject*> > registeredObjects; //!< Currently registered objects
[639]75  }; // class CGarbageCollector
76} // namespace xios
77
78#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.