libstorage-ng
Actiongraph.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) [2016-2018] 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 
75  void write_graphviz(const std::string& filename, GraphvizFlags flags = GraphvizFlags::NAME,
76  GraphvizFlags tooltip_flags = GraphvizFlags::NONE) const;
77 
78  void print_order() const;
79 
80  bool empty() const;
81 
82  size_t num_actions() const;
83 
87  std::vector<const Action::Base*> get_commit_actions() const;
88 
89  // TODO add Action to the public interface and use get_commit_actions instead
90  std::vector<std::string> get_commit_actions_as_strings() const;
91 
92  void generate_compound_actions();
93  std::vector<const CompoundAction*> get_compound_actions() const;
94 
95  public:
96 
97  class Impl;
98 
99  Impl& get_impl() { return *impl; }
100  const Impl& get_impl() const { return *impl; }
101 
102  private:
103 
104  const std::unique_ptr<Impl> impl;
105 
106  };
107 
108 }
109 
110 
111 #endif
GraphvizFlags
Bitfield to control graphviz output.
Definition: Graphviz.h:36
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:156
void write_graphviz(const std::string &filename, GraphvizFlags flags=GraphvizFlags::NAME, GraphvizFlags tooltip_flags=GraphvizFlags::NONE) const
The storage namespace.
Definition: Actiongraph.h:37