MythTV master
filesysteminfo.h
Go to the documentation of this file.
1#ifndef DISKINFO_H_
2#define DISKINFO_H_
3
4#include <cstdint>
5#include <utility>
6
7#include <QVector>
8#include <QString>
9#include <QStringList>
10
11#include "mythbaseexp.h"
12#include "mythsocket.h"
13
15{
16 public:
17 static constexpr int kLines = 8;
18
19 FileSystemInfo() = default;
21 QString path,
22 int groupid = -1)
23 :
24 m_hostname (std::move(hostname)),
25 m_path (std::move(path)),
26 m_grpid (groupid)
27 {
28 refresh();
29 }
31 QString path,
32 bool local,
33 int fsid,
34 int groupid,
35 int blksize,
36 int64_t total,
37 int64_t used)
38 :
39 m_hostname (std::move(hostname)),
40 m_path (std::move(path)),
41 m_local (local),
42 m_fsid (fsid),
43 m_grpid (groupid),
44 m_blksize (blksize),
45 m_total (total),
46 m_used (used)
47 {
48 }
49 FileSystemInfo(QStringList::const_iterator &it, const QStringList::const_iterator& end)
50 {
51 FromStringList(it, end);
52 }
53 explicit FileSystemInfo(const QStringList &slist) { FromStringList(slist); }
54
55 void clear() { *this = FileSystemInfo(); }
56
57 // information gets
58 QString getHostname() const { return m_hostname; }
59 QString getPath() const { return m_path; }
60 bool isLocal() const { return m_local; }
61 int getFSysID() const { return m_fsid; }
62 int getGroupID() const { return m_grpid; }
63 int getBlockSize() const { return m_blksize; }
64 int64_t getTotalSpace() const { return m_total; }
65 int64_t getUsedSpace() const { return m_used; }
66 int getWeight() const { return m_weight; }
67
68 // not cached because of use in mythbackend/autoexpire
69 int64_t getFreeSpace() const { return m_total - m_used; }
70
71 // information puts
72 void setHostname(QString hostname) { m_hostname = std::move(hostname); }
73 void setPath(QString path) { m_path = std::move(path); }
74 void setFSysID(int id) { m_fsid = id; } // TODO add regenerate option to Consolidate
75 void setUsedSpace(int64_t size) { m_used = size; } // TODO call refresh in autoexpire after deleting? autoexpire's log message uses the wrong units, should be KiB
76 void setWeight(int weight) { m_weight = weight; } // scheduler, use std::pair<int, FileSystemInfo>?
77
78 bool ToStringList(QStringList &slist) const;
79 QStringList ToStringList() const;
80
83 bool refresh();
84
85 private:
86 bool FromStringList(const QStringList &slist);
87 bool FromStringList(QStringList::const_iterator &it,
88 const QStringList::const_iterator& listend);
89
90 QString m_hostname;
91 QString m_path;
92 bool m_local {false};
93 int m_fsid {-1};
94 int m_grpid {-1};
95 int m_blksize {4096};
96 int64_t m_total {0};
97 int64_t m_used {0};
98
99 // not serialized
100 int m_weight {0};
101};
102
103using FileSystemInfoList = QVector<FileSystemInfo>;
105{
106MBASE_PUBLIC FileSystemInfoList FromStringList(const QStringList& list);
107
108MBASE_PUBLIC QStringList ToStringList(const FileSystemInfoList& fsInfos);
109
111
113void Consolidate(FileSystemInfoList &disks, bool merge, int64_t fuzz, const QString& total_name = {});
114} // namespace FileSystemInfoManager
115
116#endif
int getBlockSize() const
void setFSysID(int id)
void setWeight(int weight)
QString getHostname() const
void setHostname(QString hostname)
QString getPath() const
int getGroupID() const
bool isLocal() const
int64_t getTotalSpace() const
void setPath(QString path)
void setUsedSpace(int64_t size)
FileSystemInfo()=default
int getWeight() const
FileSystemInfo(const QStringList &slist)
QString m_hostname
FileSystemInfo(QString hostname, QString path, int groupid=-1)
FileSystemInfo(QString hostname, QString path, bool local, int fsid, int groupid, int blksize, int64_t total, int64_t used)
int64_t getUsedSpace() const
int getFSysID() const
FileSystemInfo(QStringList::const_iterator &it, const QStringList::const_iterator &end)
int64_t getFreeSpace() const
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
QVector< FileSystemInfo > FileSystemInfoList
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MBASE_PUBLIC FileSystemInfoList GetInfoList(MythSocket *sock=nullptr)
MBASE_PUBLIC QStringList ToStringList(const FileSystemInfoList &fsInfos)
MBASE_PUBLIC FileSystemInfoList FromStringList(const QStringList &list)
MBASE_PUBLIC void Consolidate(FileSystemInfoList &disks, bool merge, int64_t fuzz, const QString &total_name={})
string hostname
Definition: caa.py:17
STL namespace.