Smallcase folders part 2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "Config/Server/Config.h"
|
||||
#include "Config/Common/IniParser.h"
|
||||
#include "config/server/Config.h"
|
||||
#include "config/common/IniParser.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace config::server
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "Config/Server/BarStyleConfig.h"
|
||||
#include "Config/Server/DisplayConfig.h"
|
||||
#include "Config/Server/NetworkConfig.h"
|
||||
#include "Config/Server/TextStyleConfig.h"
|
||||
#include "config/server/BarStyleConfig.h"
|
||||
#include "config/server/DisplayConfig.h"
|
||||
#include "config/server/NetworkConfig.h"
|
||||
#include "config/server/TextStyleConfig.h"
|
||||
|
||||
namespace config::server
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Framebuffer.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "Display/Graphics/FramebufferRotation.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include "display/graphics/FramebufferRotation.h"
|
||||
|
||||
namespace display::graphics
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Renderer.h"
|
||||
#include "display/graphics/Renderer.h"
|
||||
|
||||
namespace display::graphics
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include "Display/Graphics/Framebuffer.h"
|
||||
#include "Model/HostRegistry.h"
|
||||
#include "Display/UI/Text/Renderer.h"
|
||||
#include "Display/UI/Header/Header.h"
|
||||
#include "Display/UI/HostBlock/HostBlock.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include "model/HostRegistry.h"
|
||||
#include "display/ui/text/Renderer.h"
|
||||
#include "display/ui/header/Header.h"
|
||||
#include "display/ui/hostblock/HostBlock.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include <string>
|
||||
|
||||
namespace display::graphics
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Display/UI/Bar/Bar.h"
|
||||
#include "display/ui/bar/Bar.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace display::ui::bar
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include "Display/Graphics/Framebuffer.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "Display/UI/Bar/Orientation.h"
|
||||
#include "Display/UI/Bar/Style.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include "display/ui/bar/Orientation.h"
|
||||
#include "display/ui/bar/Style.h"
|
||||
|
||||
namespace display::ui::bar
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "Display/UI/Theme/Theme.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include "display/ui/theme/Theme.h"
|
||||
|
||||
namespace display::ui::bar
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Display/UI/Header/Header.h"
|
||||
#include "display/ui/header/Header.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -6,10 +6,10 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "Display/UI/Bar/Orientation.h"
|
||||
#include "Display/UI/Bar/Style.h"
|
||||
#include "Display/UI/Theme/Theme.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "display/ui/bar/Orientation.h"
|
||||
#include "display/ui/bar/Style.h"
|
||||
#include "display/ui/theme/Theme.h"
|
||||
#include "display/graphics/Color.h"
|
||||
|
||||
namespace display::ui::header
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Display/Graphics/Framebuffer.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "Display/UI/Text/Renderer.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include "display/ui/text/Renderer.h"
|
||||
|
||||
namespace display::ui::header
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "Display/UI/HostBlock/HostBlock.h"
|
||||
#include "display/ui/hostblock/HostBlock.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Display/UI/Bar/Orientation.h"
|
||||
#include "Display/UI/Bar/Style.h"
|
||||
#include "Display/UI/Theme/Theme.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "Display/UI/Text/Helpers.h"
|
||||
#include "display/ui/bar/Orientation.h"
|
||||
#include "display/ui/bar/Style.h"
|
||||
#include "display/ui/theme/Theme.h"
|
||||
#include "display/ui/text/Helpers.h"
|
||||
#include "display/graphics/Color.h"
|
||||
|
||||
namespace display::ui::hostblock
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Display/Graphics/Framebuffer.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "Display/UI/Text/Renderer.h"
|
||||
#include "Display/UI/Bar/Bar.h"
|
||||
#include "Metrics/Host.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include "display/ui/text/Renderer.h"
|
||||
#include "display/ui/bar/Bar.h"
|
||||
#include "metrics/Host.h"
|
||||
|
||||
namespace display::ui::hostblock
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Display/UI/Text/Fonts.h"
|
||||
#include "display/ui/text/Fonts.h"
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include "Helpers/Paths.h"
|
||||
#include "helpers/Paths.h"
|
||||
|
||||
namespace display::ui::text
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "Display/UI/Text/Font.h"
|
||||
#include "Display/UI/Text/Glyph.h"
|
||||
#include "Display/UI/Text/GlyphKey.h"
|
||||
#include "display/ui/text/Font.h"
|
||||
#include "display/ui/text/Glyph.h"
|
||||
#include "display/ui/text/GlyphKey.h"
|
||||
|
||||
namespace display::ui::text
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Display/UI/Text/Helpers.h"
|
||||
#include "display/ui/text/Helpers.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Display/UI/Text/Renderer.h"
|
||||
#include "Display/UI/Text/UTFDecoder.h"
|
||||
#include "display/ui/text/Renderer.h"
|
||||
#include "display/ui/text/UTFDecoder.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Display/Graphics/Framebuffer.h"
|
||||
#include "Display/UI/Text/Fonts.h"
|
||||
#include "Display/UI/Text/Font.h"
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include "display/graphics/Color.h"
|
||||
#include "display/ui/text/Fonts.h"
|
||||
#include "display/ui/text/Font.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Display/Graphics/Color.h"
|
||||
#include "display/graphics/Color.h"
|
||||
|
||||
namespace display::ui::theme
|
||||
{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "helpers/Paths.h"
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
std::filesystem::path getExecutablePath()
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
|
||||
if (len == -1)
|
||||
throw std::runtime_error("readlink(/proc/self/exe) failed");
|
||||
|
||||
buf[len] = '\0';
|
||||
return std::filesystem::path(buf);
|
||||
}
|
||||
|
||||
Paths initPaths()
|
||||
{
|
||||
Paths p;
|
||||
p.exe = getExecutablePath();
|
||||
p.exeDir = p.exe.parent_path();
|
||||
p.configDir = p.exeDir / "config";
|
||||
p.assetsDir = p.exeDir / "assets";
|
||||
return p;
|
||||
}
|
||||
} // namespace helpers
|
||||
|
||||
+2
-20
@@ -6,17 +6,6 @@
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
std::filesystem::path getExecutablePath()
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
|
||||
if (len == -1)
|
||||
throw std::runtime_error("readlink(/proc/self/exe) failed");
|
||||
|
||||
buf[len] = '\0';
|
||||
return std::filesystem::path(buf);
|
||||
}
|
||||
|
||||
struct Paths
|
||||
{
|
||||
std::filesystem::path exe;
|
||||
@@ -25,13 +14,6 @@ namespace helpers
|
||||
std::filesystem::path assetsDir;
|
||||
};
|
||||
|
||||
Paths initPaths()
|
||||
{
|
||||
Paths p;
|
||||
p.exe = getExecutablePath();
|
||||
p.exeDir = p.exe.parent_path();
|
||||
p.configDir = p.exeDir / "config";
|
||||
p.assetsDir = p.exeDir / "assets";
|
||||
return p;
|
||||
}
|
||||
std::filesystem::path getExecutablePath();
|
||||
Paths initPaths();
|
||||
} // namespace helpers
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
#include "Network/Client/Client.h"
|
||||
#include "Network/Client/Agent.h"
|
||||
#include "Metrics/Collector.h"
|
||||
#include "Config/Client/Config.h"
|
||||
#include "Config/Client/NetworkConfig.h"
|
||||
#include "network/client/Client.h"
|
||||
#include "network/client/Agent.h"
|
||||
#include "metrics/Collector.h"
|
||||
#include "config/client/Config.h"
|
||||
#include "config/client/NetworkConfig.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
#include "Display/Graphics/Framebuffer.h"
|
||||
#include "Model/HostRegistry.h"
|
||||
#include "Network/Server/Server.h"
|
||||
#include "Display/Graphics/Renderer.h"
|
||||
#include "Config/Server/Config.h"
|
||||
#include "Config/Server/DisplayConfig.h"
|
||||
#include "Config/Server/NetworkConfig.h"
|
||||
#include "display/graphics/Framebuffer.h"
|
||||
#include "model/HostRegistry.h"
|
||||
#include "network/server/Server.h"
|
||||
#include "display/graphics/Renderer.h"
|
||||
#include "config/server/Config.h"
|
||||
#include "config/server/DisplayConfig.h"
|
||||
#include "config/server/NetworkConfig.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Metrics/Collector.h"
|
||||
#include "metrics/Collector.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
Collector::Collector(const std::vector<std::string> &disks) : disks(disks)
|
||||
Collector::Collector(const std::vector<std::vector<std::string>> &disks) : disks(disks)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace metrics
|
||||
prevCpu = curCpu;
|
||||
|
||||
host.memory = readMemory();
|
||||
for (const std::string &disk : disks)
|
||||
host.disks.push_back(readDisk(disk.c_str()));
|
||||
for (const std::vector<std::string> &disk : disks)
|
||||
host.disks.push_back(readDisk(disk));
|
||||
readLoad(host.load1, host.load5, host.load15);
|
||||
host.uptime = readUptime();
|
||||
host.hostname = readHostname();
|
||||
@@ -126,13 +126,13 @@ namespace metrics
|
||||
return memory;
|
||||
}
|
||||
|
||||
Disk Collector::readDisk(const char *path)
|
||||
Disk Collector::readDisk(const std::vector<std::string> &disk)
|
||||
{
|
||||
struct statvfs vfs;
|
||||
if (statvfs(path, &vfs) != 0)
|
||||
if (statvfs(disk.at(1).c_str(), &vfs) != 0)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string("statvfs failed for ") + path + ": " +
|
||||
std::string("statvfs failed for ") + disk.at(1).c_str() + ": " +
|
||||
std::strerror(errno));
|
||||
}
|
||||
|
||||
@@ -141,7 +141,8 @@ namespace metrics
|
||||
uint64_t used = total - free;
|
||||
|
||||
Disk d;
|
||||
d.name = path;
|
||||
d.name = disk.at(0);
|
||||
d.path = disk.at(1);
|
||||
d.total = total;
|
||||
d.free = free;
|
||||
d.used = used;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
#include "Metrics/Host.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "metrics/Host.h"
|
||||
|
||||
namespace metrics
|
||||
{
|
||||
class Collector
|
||||
{
|
||||
public:
|
||||
Collector(const std::vector<std::string> &disks = {"/"});
|
||||
Collector(const std::vector<std::vector<std::string>> &disks = {{"R", "/"}});
|
||||
explicit Collector();
|
||||
|
||||
Host collect();
|
||||
@@ -24,10 +24,10 @@ namespace metrics
|
||||
std::pair<CpuTimes, std::vector<CpuTimes>> prevCpu;
|
||||
|
||||
std::pair<CpuTimes, std::vector<CpuTimes>> readCpuTimes();
|
||||
const std::vector<std::string> disks;
|
||||
const std::vector<std::vector<std::string>> disks;
|
||||
float cpuLoad(const CpuTimes &prev, const CpuTimes &cur);
|
||||
Memory readMemory();
|
||||
Disk readDisk(const char *path = "/");
|
||||
Disk readDisk(const std::vector<std::string> &disk = {"R", "/"});
|
||||
void readLoad(float &l1, float &l5, float &l15);
|
||||
uint64_t readUptime();
|
||||
std::string readHostname();
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace metrics
|
||||
struct Disk
|
||||
{
|
||||
std::string name;
|
||||
std::string path;
|
||||
float used;
|
||||
float free;
|
||||
float total;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Metrics/Host.h"
|
||||
#include "metrics/Host.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "Network/Common/Buffer.h"
|
||||
#include "network/common/Buffer.h"
|
||||
|
||||
namespace metrics
|
||||
{
|
||||
@@ -51,6 +51,7 @@ namespace metrics
|
||||
for (const auto &d : disks)
|
||||
{
|
||||
buf.writeString(d.name);
|
||||
buf.writeString(d.path);
|
||||
buf.writeFloat(d.used);
|
||||
buf.writeFloat(d.total);
|
||||
}
|
||||
@@ -91,9 +92,10 @@ namespace metrics
|
||||
for (uint8_t i = 0; i < numDisks; ++i)
|
||||
{
|
||||
std::string name = buf.readString();
|
||||
std::string path = buf.readString();
|
||||
float used = buf.readFloat();
|
||||
float total = buf.readFloat();
|
||||
h.disks.push_back({name, used, total});
|
||||
h.disks.push_back({name, path, used, total});
|
||||
}
|
||||
|
||||
return h;
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Metrics/Cpu.h"
|
||||
#include "Metrics/Memory.h"
|
||||
#include "Metrics/Disk.h"
|
||||
#include "metrics/Cpu.h"
|
||||
#include "metrics/Memory.h"
|
||||
#include "metrics/Disk.h"
|
||||
|
||||
namespace metrics
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Model/HostRegistry.h"
|
||||
#include "model/HostRegistry.h"
|
||||
|
||||
namespace model
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include "Metrics/Host.h"
|
||||
#include "metrics/Host.h"
|
||||
|
||||
namespace model
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Network/Client/Agent.h"
|
||||
#include "network/client/Agent.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace network
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Network/Client/Client.h"
|
||||
#include "Metrics/Collector.h"
|
||||
#include "network/client/Client.h"
|
||||
#include "metrics/Collector.h"
|
||||
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Network/Client/Client.h"
|
||||
#include "network/client/Client.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <netinet/in.h>
|
||||
#include "Metrics/Host.h"
|
||||
#include "metrics/Host.h"
|
||||
|
||||
namespace network
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Network/Common/Buffer.h"
|
||||
#include "network/common/Buffer.h"
|
||||
|
||||
namespace network
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "Network/Server/Server.h"
|
||||
#include "network/server/Server.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include "Metrics/Host.h"
|
||||
#include "metrics/Host.h"
|
||||
|
||||
namespace network
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "Model/HostRegistry.h"
|
||||
#include "model/HostRegistry.h"
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
Reference in New Issue
Block a user