source: XIOS/dev/dev_olga/src/filter/garbage_collector.hpp @ 1654

Last change on this file since 1654 was 1653, checked in by oabramkina, 5 years ago

Developments for visualization of XIOS workflow.

Branch is spawned from trunk r1649.

Boost library is used for producing Graphviz DOT files. Current results: a DOT file representing a static workflow. For a complete proof of concept, DOT files for each timestamp should be generated. The necessary information has been collected by XIOS, it only requires rearranging the information for graphing (changes in classes CWorkflowGraph and CGraphviz).

File size: 1.9 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    static int count; //!< Counter used to identify a filter in case building workflow graph
24   
25  }; // struct InvalidableObject
26
27  /*!
28   * A basic garbage collector which ensures no old packets linger in the filter graph.
29   */
30  class CGarbageCollector
31  {
32    public:
33      /*!
34       * Constructs a garbage collector.
35       */
36      CGarbageCollector()
37      { /* Nothing to do */ };
38
39      /*!
40       * Registers an object for a specified timestamp.
41       *
42       * \param object the object to register
43       * \param timestamp the timestamp for which the object is registered
44       */
45      void registerObject(InvalidableObject* object, Time timestamp);
46
47      /*!
48       * Removes a object previously registered for a specified timestamp.
49       *
50       * \param object the object to unregister
51       * \param timestamp the timestamp for which the object is unregistered
52       */
53      void unregisterObject(InvalidableObject* object, Time timestamp);
54
55      /*!
56       * Ensures all registered objects invalidate packets older than the specified timestamp.
57       *
58       * \param timestamp the timestamp used for invalidation
59       */
60      void invalidate(Time timestamp);
61
62    private:
63      CGarbageCollector(const CGarbageCollector&);
64      CGarbageCollector& operator=(const CGarbageCollector&);
65
66      std::map<Time, std::set<InvalidableObject*> > registeredObjects; //!< Currently registered objects
67  }; // class CGarbageCollector
68} // namespace xios
69
70#endif //__XIOS_CGarbageCollector__
Note: See TracBrowser for help on using the repository browser.