libstorage-ng
Disk.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_DISK_H
25 #define STORAGE_DISK_H
26 
27 
28 #include "storage/Devices/Partitionable.h"
29 
30 
31 namespace storage
32 {
33 
35  enum class Transport {
36  UNKNOWN, SBP, ATA, FC, ISCSI, SAS, SATA, SPI, USB, FCOE
37  };
38 
39  std::string get_transport_name(Transport transport);
40 
41 
43  class Disk : public Partitionable
44  {
45  public:
46 
47  static Disk* create(Devicegraph* devicegraph, const std::string& name);
48  static Disk* create(Devicegraph* devicegraph, const std::string& name,
49  const Region& region);
50  static Disk* create(Devicegraph* devicegraph, const std::string& name,
51  unsigned long long size);
52 
53  static Disk* load(Devicegraph* devicegraph, const xmlNode* node);
54 
58  static std::vector<Disk*> get_all(Devicegraph* devicegraph);
59 
63  static std::vector<const Disk*> get_all(const Devicegraph* devicegraph);
64 
65  bool is_rotational() const;
66 
67  Transport get_transport() const;
68 
75  static Disk* find_by_name(Devicegraph* devicegraph, const std::string& name);
76 
80  static const Disk* find_by_name(const Devicegraph* devicegraph, const std::string& name);
81 
82  public:
83 
84  class Impl;
85 
86  Impl& get_impl();
87  const Impl& get_impl() const;
88 
89  virtual Disk* clone() const override;
90 
91  protected:
92 
93  Disk(Impl* impl);
94 
95  };
96 
97 
98  bool is_disk(const Device* device);
99 
106  Disk* to_disk(Device* device);
107 
111  const Disk* to_disk(const Device* device);
112 
113 }
114 
115 #endif
A physical disk device.
Definition: Disk.h:43
Disk * to_disk(Device *device)
Converts pointer to Device to pointer to Disk.
A start/length pair with a block size.
Definition: Region.h:73
The master container of the libstorage.
Definition: Devicegraph.h:153
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:75
Definition: Partitionable.h:40
Transport
Data Transport Layer.
Definition: Disk.h:35
static Disk * find_by_name(Devicegraph *devicegraph, const std::string &name)
Find a Disk by its name.
static std::vector< Disk * > get_all(Devicegraph *devicegraph)
Get all Disks.
The storage namespace.
Definition: Actiongraph.h:37