libstorage-ng
Pool.h
1 /*
2  * Copyright (c) 2020 Arvin Schnell
3  *
4  * All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as published
8  * by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, contact Novell, Inc.
17  *
18  * To contact Novell about this file by physical or electronic mail, you may
19  * find current contact information at www.novell.com.
20  */
21 
22 
23 #ifndef STORAGE_POOL_H
24 #define STORAGE_POOL_H
25 
26 
27 #include <vector>
28 #include <memory>
29 #include <boost/noncopyable.hpp>
30 
31 #include "storage/Utils/Exception.h"
32 
33 
34 namespace storage
35 {
36 
37  class Devicegraph;
38  class Device;
39  class Partition;
40 
41 
45  class PoolOutOfSpace : public Exception
46  {
47  public:
48 
50 
51  };
52 
53 
80  class Pool : private boost::noncopyable
81  {
82  public:
83 
84  Pool();
85  ~Pool();
86 
94  void add_device(const Device* device);
95 
103  void remove_device(const Device* device);
104 
109  size_t size(const Devicegraph* devicegraph) const;
110 
115  std::vector<const Device*> get_devices(const Devicegraph* devicegraph) const;
116 
123  unsigned long long max_partition_size(Devicegraph* devicegraph, unsigned int number) const;
124 
137  std::vector<Partition*> create_partitions(Devicegraph* devicegraph, unsigned int number,
138  unsigned long long size) const;
139 
140  public:
141 
142  class Impl;
143 
144  Impl& get_impl() { return *impl; }
145  const Impl& get_impl() const { return *impl; }
146 
147  private:
148 
149  const std::unique_ptr<Impl> impl;
150 
151  };
152 
153 }
154 
155 
156 #endif
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.
void remove_device(const Device *device)
Remove a device from the pool.
size_t size(const Devicegraph *devicegraph) const
Get the number of devices of the pool available in the devicegraph.
The main container of the libstorage-ng.
Definition: Devicegraph.h:169
void add_device(const Device *device)
Add a device to the pool.
An abstract base class for storage devices.
Definition: Device.h:81
Base class for storage exceptions.
Definition: Exception.h:113
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.
std::vector< const Device * > get_devices(const Devicegraph *devicegraph) const
Get the devices of the pool available in the devicegraph.
The storage namespace.
Definition: Actiongraph.h:38
Exception to report that the pool is out of space to fulfill the request.
Definition: Pool.h:45
A pool represents a collection of devices.
Definition: Pool.h:80