libstorage-ng
Loading...
Searching...
No Matches
Pool.h
1/*
2 * Copyright (c) 2020 Arvin Schnell
3 * Copyright (c) [2021-2022] 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_POOL_H
25#define STORAGE_POOL_H
26
27
28#include <vector>
29#include <map>
30#include <memory>
31#include <boost/noncopyable.hpp>
32
33#include "storage/Utils/Exception.h"
34
35
36namespace storage
37{
38
39 class Devicegraph;
40 class Device;
41 class Partition;
42
43
48 {
49 public:
50
52
53 };
54
55
82 class Pool : private boost::noncopyable
83 {
84 public:
85
86 Pool();
87 ~Pool();
88
92 const std::map<std::string, std::string>& get_userdata() const;
93
97 void set_userdata(const std::map<std::string, std::string>& userdata);
98
102 bool exists_device(const Device* device) const;
103
111 void add_device(const Device* device);
112
120 void remove_device(const Device* device);
121
126 bool empty(const Devicegraph* devicegraph) const;
127
132 size_t size(const Devicegraph* devicegraph) const;
133
138 std::vector<const Device*> get_devices(const Devicegraph* devicegraph) const;
139
146 unsigned long long max_partition_size(Devicegraph* devicegraph, unsigned int number) const;
147
160 std::vector<Partition*> create_partitions(Devicegraph* devicegraph, unsigned int number,
161 unsigned long long size) const;
162
163 public:
164
165 class Impl;
166
167 Impl& get_impl() { return *impl; }
168 const Impl& get_impl() const { return *impl; }
169
170 private:
171
172 const std::unique_ptr<Impl> impl;
173
174 };
175
176}
177
178
179#endif
An abstract base class for storage devices.
Definition: Device.h:82
The main container of the libstorage-ng.
Definition: Devicegraph.h:170
Base class for storage exceptions.
Definition: Exception.h:114
Exception to report that the pool is out of space to fulfill the request.
Definition: Pool.h:48
A pool represents a collection of devices.
Definition: Pool.h:83
std::vector< const Device * > get_devices(const Devicegraph *devicegraph) const
Get the devices of the pool available in the devicegraph.
void add_device(const Device *device)
Add a device to the pool.
unsigned long long max_partition_size(Devicegraph *devicegraph, unsigned int number) const
Find the maximum partition size the pool can provide for the given number of partitions.
size_t size(const Devicegraph *devicegraph) const
Get the number of devices of the pool available in the devicegraph.
bool exists_device(const Device *device) const
Check whether the device exists in the pool.
const std::map< std::string, std::string > & get_userdata() const
Return the userdata of the pool.
bool empty(const Devicegraph *devicegraph) const
Check whether the pool has any devices in the devicegraph.
void set_userdata(const std::map< std::string, std::string > &userdata)
Set the userdata of the pool.
void remove_device(const Device *device)
Remove a device from the pool.
std::vector< Partition * > create_partitions(Devicegraph *devicegraph, unsigned int number, unsigned long long size) const
Create a number of partitions of size in the pool.
The storage namespace.
Definition: Actiongraph.h:40