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 
52  unsigned int get_range() const;
53 
62  void set_range(unsigned int range);
63 
72 
79 
84  std::vector<PtType> get_possible_partition_table_types() const;
85 
95 
99  bool has_partition_table() const;
100 
107 
111  virtual std::string partition_name(int number) const;
112 
117 
121  static std::vector<Partitionable*> get_all(Devicegraph* devicegraph);
122 
126  static std::vector<const Partitionable*> get_all(const Devicegraph* devicegraph);
127 
128  static Partitionable* find_by_name(Devicegraph* devicegraph, const std::string& name);
129  static const Partitionable* find_by_name(const Devicegraph* devicegraph, const std::string& name);
130 
131  public:
132 
133  class Impl;
134 
135  Impl& get_impl();
136  const Impl& get_impl() const;
137 
138  protected:
139 
140  Partitionable(Impl* impl);
141 
142  };
143 
144 
150  bool is_partitionable(const Device* device);
151 
159 
163  const Partitionable* to_partitionable(const Device* device);
164 
165 }
166 
167 #endif
storage::Partitionable
Definition: Partitionable.h:40
storage::Partitionable::get_default_partition_table_type
PtType get_default_partition_table_type() const
Get the default partition table type for the partitionable.
storage::Topology
A class to represent hardware alignment information.
Definition: Topology.h:39
storage::Partitionable::get_partition_table
PartitionTable * get_partition_table()
Return the partition table of the partitionable.
storage::PtType
PtType
Partition Table Type.
Definition: PartitionTable.h:42
storage
The storage namespace.
Definition: Actiongraph.h:39
storage::PartitionTable
Definition: PartitionTable.h:88
storage::Partitionable::partition_name
virtual std::string partition_name(int number) const
Return the name of the partition with the specified number.
storage::Partitionable::get_range
unsigned int get_range() const
Query the range of device nodes available.
storage::Partitionable::has_partition_table
bool has_partition_table() const
Check whether the partitionable has a partition table.
storage::to_partitionable
Partitionable * to_partitionable(Device *device)
Converts pointer to Device to pointer to Partitionable.
storage::BlkDevice
An abstract Block Device.
Definition: BlkDevice.h:47
storage::Partitionable::get_all
static std::vector< Partitionable * > get_all(Devicegraph *devicegraph)
Get all Partitionables.
storage::Devicegraph
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
storage::Partitionable::create_partition_table
PartitionTable * create_partition_table(PtType pt_type)
Create a partition table on the partitionable.
storage::Partitionable::set_range
void set_range(unsigned int range)
Set the range of device nodes available.
storage::Device
An abstract base class for storage devices.
Definition: Device.h:82
storage::Partitionable::get_all
static std::vector< const Partitionable * > get_all(const Devicegraph *devicegraph)
Get all Partitionables.
storage::is_partitionable
bool is_partitionable(const Device *device)
Checks whether device points to a Partitionable.
storage::Partitionable::is_usable_as_partitionable
bool is_usable_as_partitionable() const
Checks whether the partitionable is in general usable as a partitionable (can hold a partition table)...
storage::Partitionable::get_partition_table
const PartitionTable * get_partition_table() const
Return the partition table of the partitionable.
storage::Partitionable::get_possible_partition_table_types
std::vector< PtType > get_possible_partition_table_types() const
Get possible partition table types for the disk.