libstorage-ng
Actiongraph.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) [2016-2019] SUSE LLC
4  *
5  * All Rights Reserved.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of version 2 of the GNU General Public License as published
9  * by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, contact Novell, Inc.
18  *
19  * To contact Novell about this file by physical or electronic mail, you may
20  * find current contact information at www.novell.com.
21  */
22 
23 
24 #ifndef STORAGE_ACTIONGRAPH_H
25 #define STORAGE_ACTIONGRAPH_H
26 
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 #include <boost/noncopyable.hpp>
32 
33 #include "storage/Graphviz.h"
34 #include "storage/CompoundAction.h"
35 
36 
37 namespace storage
38 {
39 
40  class Storage;
41  class Devicegraph;
42 
43 
44  namespace Action
45  {
46  class Base;
47  }
48 
49 
50  enum Side {
51  LHS, RHS
52  };
53 
54 
55  class Actiongraph : private boost::noncopyable
56  {
57  public:
58 
63 
64  ~Actiongraph();
65 
66  const Storage& get_storage() const;
67 
68  const Devicegraph* get_devicegraph(Side side) const;
69 
70  void print_graph() const;
71 
79  void write_graphviz(const std::string& filename, ActiongraphStyleCallbacks* style_callbacks) const;
80 
88  void write_graphviz(const std::string& filename, GraphvizFlags flags = GraphvizFlags::NAME,
89  GraphvizFlags tooltip_flags = GraphvizFlags::NONE) const;
90 
91  void print_order() const;
92 
93  bool empty() const;
94 
95  size_t num_actions() const;
96 
100  std::vector<const Action::Base*> get_commit_actions() const;
101 
102  // TODO add Action to the public interface and use get_commit_actions instead
103  std::vector<std::string> get_commit_actions_as_strings() const;
104 
105  void generate_compound_actions();
106  std::vector<const CompoundAction*> get_compound_actions() const;
107 
108  public:
109 
110  class Impl;
111 
112  Impl& get_impl() { return *impl; }
113  const Impl& get_impl() const { return *impl; }
114 
115  private:
116 
117  const std::unique_ptr<Impl> impl;
118 
119  };
120 
121 }
122 
123 
124 #endif
GraphvizFlags
Bitfield to control graphviz output.
Definition: Graphviz.h:44
std::vector< const Action::Base * > get_commit_actions() const
Sorted according to dependencies among actions.
Actiongraph(const Storage &storage, Devicegraph *lhs, Devicegraph *rhs)
The master container of the libstorage.
Definition: Devicegraph.h:153
Definition: Actiongraph.h:55
The main entry point to libstorage.
Definition: Storage.h:259
The storage namespace.
Definition: Actiongraph.h:37
void write_graphviz(const std::string &filename, ActiongraphStyleCallbacks *style_callbacks) const
Writes the actiongraph in graphviz format.