24#ifndef STORAGE_DEVICE_H
25#define STORAGE_DEVICE_H
28#include <libxml/tree.h>
33#include <boost/noncopyable.hpp>
35#include "storage/Utils/Exception.h"
36#include "storage/Utils/Swig.h"
37#include "storage/View.h"
81 class Device :
private boost::noncopyable
95 bool operator==(
const Device& rhs)
const;
96 bool operator!=(
const Device& rhs)
const;
132 std::string get_displayname()
const;
145 bool has_children()
const;
146 size_t num_children()
const;
148 bool has_parents()
const;
149 size_t num_parents()
const;
168 std::vector<Device*> get_children();
169 std::vector<const Device*> get_children()
const;
181 std::vector<Device*> get_parents();
182 std::vector<const Device*> get_parents()
const;
194 std::vector<Device*> get_siblings(
bool itself);
195 std::vector<const Device*> get_siblings(
bool itself)
const;
197 std::vector<Device*> get_descendants(
bool itself);
198 std::vector<const Device*> get_descendants(
bool itself)
const;
200 std::vector<Device*> get_descendants(
bool itself,
View view);
201 std::vector<const Device*> get_descendants(
bool itself,
View view)
const;
203 std::vector<Device*> get_ancestors(
bool itself);
204 std::vector<const Device*> get_ancestors(
bool itself)
const;
206 std::vector<Device*> get_leaves(
bool itself);
207 std::vector<const Device*> get_leaves(
bool itself)
const;
209 std::vector<Device*> get_roots(
bool itself);
210 std::vector<const Device*> get_roots(
bool itself)
const;
212 std::vector<Holder*> get_in_holders();
213 std::vector<const Holder*> get_in_holders()
const;
215 std::vector<Holder*> get_out_holders();
216 std::vector<const Holder*> get_out_holders()
const;
218 void remove_descendants() ST_DEPRECATED;
224 void remove_descendants(
View view);
236 friend std::ostream& operator<<(std::ostream& out, const
Device& device);
298 Impl& get_impl() {
return *impl; }
299 const Impl& get_impl()
const {
return *impl; }
301 virtual Device* clone()
const = 0;
303 void save(xmlNode* node)
const ST_DEPRECATED;
322 const std::unique_ptr<Impl> impl;
An abstract base class for storage devices.
Definition: Device.h:82
static std::vector< const Device * > get_all(const Devicegraph *devicegraph)
Get all Devices.
static bool compare_by_name(const Device *lhs, const Device *rhs)
Compare (less than) two Devices by name.
Devicegraph * get_devicegraph()
Return the devicegraph the device belongs to.
std::vector< const Device * > get_parents(View view) const
Get all parents of the device.
std::vector< Device * > get_children(View view)
Get all children of the device.
bool exists_in_system() const
Checks if the device exists in the system devicegraph.
void set_userdata(const std::map< std::string, std::string > &userdata)
Set the userdata of the device.
sid_t get_sid() const
Return the storage id (sid) of the device.
std::string get_name_sort_key() const
Get a sort-key based on the device name.
void create(Devicegraph *devicegraph)
Create a device in the devicegraph.
bool exists_in_staging() const
Checks if the device exists in the staging devicegraph.
bool exists_in_probed() const
Checks if the device exists in the probed devicegraph.
ResizeInfo detect_resize_info() const
Detect the resize info of the device.
const std::map< std::string, std::string > & get_userdata() const
Return the userdata of the device.
static std::vector< Device * > get_all(Devicegraph *devicegraph)
Get all Devices.
std::vector< const Device * > get_children(View view) const
Get all children of the device.
static bool compare_by_sid(const Device *lhs, const Device *rhs)
Compare (less than) two Devices by sid.
std::vector< Device * > get_parents(View view)
Get all parents of the device.
bool exists_in_devicegraph(const Devicegraph *devicegraph) const
Checks if the device exists in the devicegraph.
Device * copy_to_devicegraph(Devicegraph *devicegraph) const
Copies the device to the devicegraph.
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
Base class for storage exceptions.
Definition: Exception.h:114
Definition: FreeInfo.h:198
The storage namespace.
Definition: Actiongraph.h:40
View
Enum with possible views on the devicegraph.
Definition: View.h:34
unsigned int sid_t
An integer storage ID.
Definition: Device.h:67