virthttp  0.0
libvirt http interface
NodeDevice.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <libvirt/libvirt.h>
3 #include "../NodeDevice.hpp"
4 
5 namespace virt {
6 constexpr inline NodeDevice::NodeDevice(virNodeDevicePtr ptr) noexcept : underlying(ptr) {}
7 
8 constexpr inline NodeDevice::NodeDevice(NodeDevice&& nd) noexcept : underlying(nd.underlying) { nd.underlying = nullptr; }
9 
11  this->~NodeDevice();
12  underlying = nd.underlying;
13  nd.underlying = nullptr;
14  return *this;
15 }
16 
17 inline NodeDevice::~NodeDevice() noexcept {
18  if (*this)
19  virNodeDeviceFree(underlying);
20 }
21 
22 constexpr inline NodeDevice::operator bool() const noexcept { return underlying != nullptr; }
23 
24 inline bool NodeDevice::destroy() noexcept { return virNodeDeviceDestroy(underlying) == 0; }
25 
26 inline bool NodeDevice::detach(gsl::czstring<> driver_name = nullptr) noexcept { return virNodeDeviceDetachFlags(underlying, driver_name, 0) == 0; }
27 
28 inline bool NodeDevice::detach() noexcept { return virNodeDeviceDettach(underlying) == 0; }
29 
30 inline passive<gsl::czstring<>> NodeDevice::getName() const noexcept { return virNodeDeviceGetName(underlying); }
31 
32 inline passive<gsl::czstring<>> NodeDevice::getParent() const noexcept { return virNodeDeviceGetParent(underlying); }
33 
34 inline passive<gsl::czstring<>> NodeDevice::getXMLDesc() const noexcept { return virNodeDeviceGetXMLDesc(underlying, 0); }
35 
36 inline std::string NodeDevice::extractXMLDesc() const noexcept { return {getXMLDesc()}; }
37 
38 inline auto NodeDevice::listCaps() const noexcept {
39  return meta::light::wrap_oparm_owning_fill_static_arr(underlying, virNodeDeviceNumOfCaps, virNodeDeviceListCaps);
40 }
41 
42 inline std::vector<std::string> NodeDevice::extractCaps() const {
43  return meta::heavy::wrap_oparm_owning_fill_static_arr<std::string>(underlying, virNodeDeviceNumOfCaps, virNodeDeviceListCaps);
44 }
45 
46 inline bool NodeDevice::reAttach() noexcept { return virNodeDeviceReAttach(underlying) == 0; }
47 
48 inline bool NodeDevice::reset() noexcept { return virNodeDeviceReset(underlying) == 0; }
49 
50 inline NodeDevice NodeDevice::createXML(Connection& conn, gsl::czstring<> xml) noexcept {
51  return NodeDevice{virNodeDeviceCreateXML(conn.underlying, xml, 0)};
52 }
53 }
passive< gsl::czstring<> > getXMLDesc() const noexcept
Definition: NodeDevice.hpp:34
~NodeDevice() noexcept
Definition: NodeDevice.hpp:17
constexpr NodeDevice(virNodeDevicePtr ptr=nullptr) noexcept
Definition: NodeDevice.hpp:6
Definition: Connection.hpp:47
T passive
Definition: utility.hpp:48
auto listCaps() const noexcept
Definition: NodeDevice.hpp:38
bool reset() noexcept
Definition: NodeDevice.hpp:48
Definition: NodeDevice.hpp:33
Definition: AdminConnection.hpp:11
bool reAttach() noexcept
Definition: NodeDevice.hpp:46
std::string extractXMLDesc() const noexcept
Definition: NodeDevice.hpp:36
NodeDevice & operator=(const NodeDevice &)=delete
passive< gsl::czstring<> > getName() const noexcept
Definition: NodeDevice.hpp:30
bool detach() noexcept
Definition: NodeDevice.hpp:28
auto wrap_oparm_owning_fill_static_arr(U underlying, CF &&count_fcn, DF &&data_fcn)
Definition: utility.hpp:252
bool destroy() noexcept
Definition: NodeDevice.hpp:24
static NodeDevice createXML(Connection &conn, gsl::czstring<> xml) noexcept
Definition: NodeDevice.hpp:50
passive< gsl::czstring<> > getParent() const noexcept
Definition: NodeDevice.hpp:32
std::vector< std::string > extractCaps() const
Definition: NodeDevice.hpp:42