载入中...
搜索中...
未找到
ServiceInterfaces.h
浏览该文件的文档.
1#pragma once
2
3// Small, capability-registered service interfaces for the engine's platform
4// services (filesystem / network / timer).
5//
6// Providers register a live implementation with eve::cap::provide<I>(impl) at
7// module construction; consumers query with eve::cap::query<I>() and cope with
8// nullptr. Tests provide deterministic mock implementations so error paths can
9// be exercised offline (see test/service_mocks.cpp).
10
11#include <cstddef>
12#include <cstdint>
13#include <string>
14#include <vector>
15
16namespace eve::service {
17
24public:
25 static constexpr const char *capabilityName = "IFileSystem";
27 virtual ~IFileSystem() = default;
28
30 virtual bool readFile(const std::string &path, std::vector<uint8_t> &out) = 0;
32 virtual bool writeFile(const std::string &path, const void *data, size_t size) = 0;
34 virtual bool fileExists(const std::string &path) = 0;
35};
36
42class INetwork {
43public:
44 static constexpr const char *capabilityName = "INetwork";
46 virtual ~INetwork() = default;
47
58 virtual bool httpRequest(const std::string &method, const std::string &url,
59 const std::string &body, int timeoutMs, int &status,
60 std::string &responseBody) = 0;
61};
62
68class ITimer {
69public:
70 static constexpr const char *capabilityName = "ITimer";
72 virtual ~ITimer() = default;
73
75 virtual double elapsedSeconds() = 0;
76};
77
78} // namespace eve::service
std::uint16_t method
wgpu::PopErrorScopeStatus status
std::string path
Definition PlayHost.cpp:110
float size
Definition TreeMesh.cpp:156
std::string body
Minimal file read / write / existence surface. Providers: eve::filesystem::Filesystem....
virtual ~IFileSystem()=default
Releases IFileSystem resources.
virtual bool readFile(const std::string &path, std::vector< uint8_t > &out)=0
Reads an entire file.
virtual bool fileExists(const std::string &path)=0
True when the path exists (file or directory).
virtual bool writeFile(const std::string &path, const void *data, size_t size)=0
Writes bytes to a file.
static constexpr const char * capabilityName
Minimal synchronous HTTP request surface. Providers: eve::network::Network. Mocks return canned statu...
static constexpr const char * capabilityName
virtual ~INetwork()=default
Releases INetwork resources.
virtual bool httpRequest(const std::string &method, const std::string &url, const std::string &body, int timeoutMs, int &status, std::string &responseBody)=0
Performs one HTTP request synchronously.
Monotonic elapsed-seconds clock. Providers: eve::timer::Timer. Mocks return scripted values so time-d...
static constexpr const char * capabilityName
virtual ~ITimer()=default
Releases ITimer resources.
virtual double elapsedSeconds()=0
Seconds since the provider was created (monotonic, non-decreasing).