libstorage-ng
Bcache.h
1 /*
2  * Copyright (c) 2016 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_BCACHE_H
24 #define STORAGE_BCACHE_H
25 
26 
27 #include "storage/Devices/BlkDevice.h"
28 
29 
30 namespace storage
31 {
32 
33  class BcacheCset;
34 
35 
40  class Bcache : public BlkDevice
41  {
42  public:
43 
44  static Bcache* create(Devicegraph* devicegraph, const std::string& dm_name);
45  static Bcache* load(Devicegraph* devicegraph, const xmlNode* node);
46 
47  unsigned int get_number() const;
48 
52  const BlkDevice* get_blk_device() const;
53 
57  bool has_bcache_cset() const;
58 
62  const BcacheCset* get_bcache_cset() const;
63 
67  static std::vector<Bcache*> get_all(Devicegraph* devicegraph);
68 
72  static std::vector<const Bcache*> get_all(const Devicegraph* devicegraph);
73 
77  static bool compare_by_number(const Bcache* lhs, const Bcache* rhs);
78 
79  public:
80 
81  class Impl;
82 
83  Impl& get_impl();
84  const Impl& get_impl() const;
85 
86  virtual Bcache* clone() const override;
87 
88  protected:
89 
90  Bcache(Impl* impl);
91 
92  };
93 
94 
95  bool is_bcache(const Device* device);
96 
103  Bcache* to_bcache(Device* device);
104 
108  const Bcache* to_bcache(const Device* device);
109 
110 }
111 
112 #endif
const BlkDevice * get_blk_device() const
Get the BlkDevice used as backing device.
static std::vector< Bcache * > get_all(Devicegraph *devicegraph)
Get all Bcaches.
static bool compare_by_number(const Bcache *lhs, const Bcache *rhs)
Compare (less than) two Bcaches by number.
A bcache device.
Definition: Bcache.h:40
bool has_bcache_cset() const
Returns true if a cache is attached.
The master container of the libstorage.
Definition: Devicegraph.h:153
An abstract Block Device.
Definition: BlkDevice.h:41
const BcacheCset * get_bcache_cset() const
Get the BcacheCset used as cache.
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:75
A bcache cache set.
Definition: BcacheCset.h:41
Bcache * to_bcache(Device *device)
Converts pointer to Device to pointer to Bcache.
The storage namespace.
Definition: Actiongraph.h:37