]> granicus.if.org Git - icinga2/blob - lib/base/dependencygraph.hpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / dependencygraph.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef DEPENDENCYGRAPH_H
4 #define DEPENDENCYGRAPH_H
5
6 #include "base/i2-base.hpp"
7 #include "base/object.hpp"
8 #include <boost/thread/mutex.hpp>
9 #include <map>
10
11 namespace icinga {
12
13 /**
14  * A graph that tracks dependencies between objects.
15  *
16  * @ingroup base
17  */
18 class DependencyGraph
19 {
20 public:
21         static void AddDependency(Object *parent, Object *child);
22         static void RemoveDependency(Object *parent, Object *child);
23         static std::vector<Object::Ptr> GetParents(const Object::Ptr& child);
24
25 private:
26         DependencyGraph();
27
28         static boost::mutex m_Mutex;
29         static std::map<Object *, std::map<Object *, int> > m_Dependencies;
30 };
31
32 }
33
34 #endif /* DEPENDENCYGRAPH_H */