1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <string>
#include <vector>
#include "cmJSONState.h"
namespace Json {
class Value;
}
class cmCTestResourceSpec
{
public:
class Resource
{
public:
std::string Id;
unsigned int Capacity;
bool operator==(const Resource& other) const;
bool operator!=(const Resource& other) const;
};
class Socket
{
public:
std::map<std::string, std::vector<Resource>> Resources;
bool operator==(const Socket& other) const;
bool operator!=(const Socket& other) const;
};
Socket LocalSocket;
cmJSONState parseState;
bool ReadFromJSONFile(const std::string& filename);
bool operator==(const cmCTestResourceSpec& other) const;
bool operator!=(const cmCTestResourceSpec& other) const;
};
namespace cmCTestResourceSpecErrors {
const auto FILE_NOT_FOUND = [](const Json::Value*, cmJSONState* state) {
state->AddError("File not found");
};
const auto JSON_PARSE_ERROR = [](const Json::Value* value,
cmJSONState* state) {
state->AddErrorAtValue("JSON parse error", value);
};
const auto INVALID_ROOT = [](const Json::Value* value, cmJSONState* state) {
state->AddErrorAtValue("Invalid root object", value);
};
const auto NO_VERSION = [](const Json::Value* value, cmJSONState* state) {
state->AddErrorAtValue("No version specified", value);
};
const auto INVALID_VERSION = [](const Json::Value* value, cmJSONState* state) {
state->AddErrorAtValue("Invalid version object", value);
};
const auto UNSUPPORTED_VERSION = [](const Json::Value* value,
cmJSONState* state) {
state->AddErrorAtValue("Unsupported version", value);
};
const auto INVALID_SOCKET_SPEC = [](const Json::Value* value,
cmJSONState* state) {
state->AddErrorAtValue("Invalid socket object", value);
};
const auto INVALID_RESOURCE_TYPE = [](const Json::Value* value,
cmJSONState* state) {
state->AddErrorAtValue("Invalid resource type object", value);
};
const auto INVALID_RESOURCE = [](const Json::Value* value,
cmJSONState* state) {
state->AddErrorAtValue("Invalid resource object", value);
};
}
|