libstorage-ng
 All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
Storage.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) 2016 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_STORAGE_H
25 #define STORAGE_STORAGE_H
26 
27 
28 #include <string>
29 #include <vector>
30 #include <memory>
31 #include <boost/noncopyable.hpp>
32 
33 
34 namespace storage
35 {
69  class Environment;
70  class Arch;
71  class Devicegraph;
72  class Actiongraph;
73 
74 
75  namespace Action
76  {
77  class Base;
78  }
79 
80 
82  {
83  public:
84 
85  virtual ~CommitCallbacks() {}
86 
87  virtual void message(const std::string& message) const = 0;
88  virtual bool error(const std::string& message, const std::string& what) const = 0;
89 
90  // TODO to make pre and post generally usable the Action classes must
91  // be included in the public libstorage interface
92  virtual void pre(const Action::Base* action) const {}
93  virtual void post(const Action::Base* action) const {}
94 
95  };
96 
97 
99  class Storage : private boost::noncopyable
100  {
101  public:
102 
103  Storage(const Environment& environment);
104  ~Storage();
105 
106  public:
107 
108  const Environment& get_environment() const;
109  const Arch& get_arch() const;
110 
111  Devicegraph* create_devicegraph(const std::string& name);
112  Devicegraph* copy_devicegraph(const std::string& source_name, const std::string& dest_name);
113  void remove_devicegraph(const std::string& name);
114  void restore_devicegraph(const std::string& name);
115 
116  bool equal_devicegraph(const std::string& lhs, const std::string& rhs) const;
117 
118  bool exist_devicegraph(const std::string& name) const;
119  std::vector<std::string> get_devicegraph_names() const;
120 
124  Devicegraph* get_devicegraph(const std::string& name);
125 
129  const Devicegraph* get_devicegraph(const std::string& name) const;
130 
135 
139  const Devicegraph* get_staging() const;
140 
144  const Devicegraph* get_probed() const;
145 
146  void check() const;
147 
148  const std::string& get_rootprefix() const;
149  void set_rootprefix(const std::string& rootprefix);
150 
154  std::string prepend_rootprefix(const std::string& mountpoint) const;
155 
161 
165  void commit(const CommitCallbacks* commit_callbacks = nullptr);
166 
167  public:
168 
169  class Impl;
170 
171  Impl& get_impl() { return *impl; }
172  const Impl& get_impl() const { return *impl; }
173 
174  private:
175 
176  const std::unique_ptr<Impl> impl;
177 
178  };
179 
180 }
181 
182 #endif
Definition: Environment.h:52
void commit(const CommitCallbacks *commit_callbacks=nullptr)
The actiongraph must be valid.
std::string prepend_rootprefix(const std::string &mountpoint) const
Prepends the root prefix to a mountpoint if necessary.
const Actiongraph * calculate_actiongraph()
The actiongraph is only valid until either the probed or staging devicegraph is modified.
The master container of the libstorage.
Definition: Devicegraph.h:133
Devicegraph * get_devicegraph(const std::string &name)
Return a devicegraph by name.
Definition: Storage.h:81
Definition: Actiongraph.h:54
Devicegraph * get_staging()
Return the staging devicegraph.
The main entry point to libstorage.
Definition: Storage.h:99
The storage namespace.
Definition: Actiongraph.h:36
const Devicegraph * get_probed() const
Return the probed devicegraph.