libstorage-ng
Partitionable.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_PARTITIONABLE_H
25 #define STORAGE_PARTITIONABLE_H
26 
27 
28 #include <vector>
29 
30 #include "storage/Devices/BlkDevice.h"
31 #include "storage/Devices/PartitionTable.h"
32 
33 
34 namespace storage
35 {
36 
37  // abstract class
38 
39  class Partitionable : public BlkDevice
40  {
41  public:
42 
43  const Topology& get_topology() const; // deprecated since also available in BlkDevice
44  void set_topology(const Topology& topology); // deprecated since also available in BlkDevice
45 
46  unsigned int get_range() const;
47  void set_range(unsigned int range);
48 
56  bool is_usable_as_partitionable() const;
57 
64 
69  std::vector<PtType> get_possible_partition_table_types() const;
70 
80 
81  bool has_partition_table() const;
82 
87 
91  virtual std::string partition_name(int number) const;
92 
96  const PartitionTable* get_partition_table() const;
97 
101  static std::vector<Partitionable*> get_all(Devicegraph* devicegraph);
102 
106  static std::vector<const Partitionable*> get_all(const Devicegraph* devicegraph);
107 
108  static Partitionable* find_by_name(Devicegraph* devicegraph, const std::string& name);
109  static const Partitionable* find_by_name(const Devicegraph* devicegraph, const std::string& name);
110 
111  public:
112 
113  class Impl;
114 
115  Impl& get_impl();
116  const Impl& get_impl() const;
117 
118  protected:
119 
120  Partitionable(Impl* impl);
121 
122  };
123 
124 
125  bool is_partitionable(const Device* device);
126 
134 
138  const Partitionable* to_partitionable(const Device* device);
139 
140 }
141 
142 #endif
PartitionTable * create_partition_table(PtType pt_type)
Create a partition table on the partitionable.
PtType get_default_partition_table_type() const
Get the default partition table type for the partitionable.
static std::vector< Partitionable * > get_all(Devicegraph *devicegraph)
Get all Partitionables.
virtual std::string partition_name(int number) const
Return the name of the partition with the specified number.
PtType
Partition Table Type.
Definition: PartitionTable.h:42
std::vector< PtType > get_possible_partition_table_types() const
Get possible partition table types for the disk.
The master container of the libstorage.
Definition: Devicegraph.h:153
An abstract Block Device.
Definition: BlkDevice.h:44
Partitionable * to_partitionable(Device *device)
Converts pointer to Device to pointer to Partitionable.
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:75
Definition: Partitionable.h:39
PartitionTable * get_partition_table()
A class to represent hardware alignment information.
Definition: Topology.h:38
bool is_usable_as_partitionable() const
Checks whether the partitionable is in general usable as a partitionable (can hold a partition table)...
The storage namespace.
Definition: Actiongraph.h:37
Definition: PartitionTable.h:81