libstorage-ng
StrayBlkDevice.h
1 /*
2  * Copyright (c) [2018-2020] SUSE LLC
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_STRAY_BLK_DEVICE_H
24 #define STORAGE_STRAY_BLK_DEVICE_H
25 
26 
27 #include "storage/Devices/BlkDevice.h"
28 
29 
30 namespace storage
31 {
32 
48  class StrayBlkDevice : public BlkDevice
49  {
50  public:
51 
58  static StrayBlkDevice* create(Devicegraph* devicegraph, const std::string& name);
59 
63  static StrayBlkDevice* create(Devicegraph* devicegraph, const std::string& name,
64  const Region& region);
65 
69  static StrayBlkDevice* create(Devicegraph* devicegraph, const std::string& name,
70  unsigned long long size);
71 
72  static StrayBlkDevice* load(Devicegraph* devicegraph, const xmlNode* node);
73 
77  static std::vector<StrayBlkDevice*> get_all(Devicegraph* devicegraph);
78 
82  static std::vector<const StrayBlkDevice*> get_all(const Devicegraph* devicegraph);
83 
90  static StrayBlkDevice* find_by_name(Devicegraph* devicegraph, const std::string& name);
91 
95  static const StrayBlkDevice* find_by_name(const Devicegraph* devicegraph, const std::string& name);
96 
97  public:
98 
99  class Impl;
100 
101  Impl& get_impl();
102  const Impl& get_impl() const;
103 
104  virtual StrayBlkDevice* clone() const override;
105 
106  protected:
107 
108  StrayBlkDevice(Impl* impl);
109 
110  };
111 
112 
118  bool is_stray_blk_device(const Device* device);
119 
127 
131  const StrayBlkDevice* to_stray_blk_device(const Device* device);
132 
133 }
134 
135 #endif
A start/length pair with a block size.
Definition: Region.h:84
The main container of the libstorage-ng.
Definition: Devicegraph.h:169
An abstract Block Device.
Definition: BlkDevice.h:48
An abstract base class for storage devices.
Definition: Device.h:81
StrayBlkDevice * to_stray_blk_device(Device *device)
Converts pointer to Device to pointer to StrayBlkDevice.
static StrayBlkDevice * create(Devicegraph *devicegraph, const std::string &name)
Create a device of type StrayBlkDevice.
static StrayBlkDevice * find_by_name(Devicegraph *devicegraph, const std::string &name)
Find a StrayBlkDevice by its name.
The storage namespace.
Definition: Actiongraph.h:38
static std::vector< StrayBlkDevice * > get_all(Devicegraph *devicegraph)
Get all StrayBlkDevices.
This class represents stray block devices.
Definition: StrayBlkDevice.h:48
bool is_stray_blk_device(const Device *device)
Checks whether device points to a StrayBlkDevice.