-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7da285d
commit 14aee1c
Showing
16 changed files
with
202 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Copyright (c) 2015-2024 EPFL/Blue Brain Project | ||
* All rights reserved. Do not distribute without permission. | ||
* | ||
* Responsible Author: adrien.fleury@epfl.ch | ||
* | ||
* This file is part of Brayns <https://github.com/BlueBrain/Brayns> | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License version 3.0 as published | ||
* by the Free Software Foundation. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <brayns/core/json/JsonReflector.h> | ||
|
||
namespace brayns | ||
{ | ||
template<ReflectedJson T> | ||
class JsonBuffer | ||
{ | ||
public: | ||
const JsonValue &get() const | ||
{ | ||
return _json; | ||
} | ||
|
||
void store(const JsonValue &json) | ||
{ | ||
_json = json; | ||
} | ||
|
||
void extract(T &value) const | ||
{ | ||
deserializeJson(_json, value); | ||
} | ||
|
||
private: | ||
JsonValue _json; | ||
}; | ||
|
||
template<ReflectedJson T> | ||
struct JsonReflector<JsonBuffer<T>> | ||
{ | ||
static JsonSchema getSchema() | ||
{ | ||
return getJsonSchema<T>(); | ||
} | ||
|
||
static void serialize(const JsonBuffer<T> &value, JsonValue &json) | ||
{ | ||
json = value.get(); | ||
} | ||
|
||
static void deserialize(const JsonValue &json, JsonBuffer<T> &value) | ||
{ | ||
value.store(json); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Copyright (c) 2015-2024 EPFL/Blue Brain Project | ||
* All rights reserved. Do not distribute without permission. | ||
* | ||
* Responsible Author: adrien.fleury@epfl.ch | ||
* | ||
* This file is part of Brayns <https://github.com/BlueBrain/Brayns> | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License version 3.0 as published | ||
* by the Free Software Foundation. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Objects.h" | ||
|
||
namespace brayns | ||
{ | ||
template<ReflectedJsonObject T> | ||
struct JsonUpdate | ||
{ | ||
T value; | ||
}; | ||
|
||
template<ReflectedJsonObject T> | ||
struct JsonObjectReflector<JsonUpdate<T>> | ||
{ | ||
static auto reflect() | ||
{ | ||
auto builder = JsonBuilder<JsonUpdate<T>>(); | ||
builder.extend([](auto &object) { return &object.value; }); | ||
|
||
auto info = builder.build(); | ||
|
||
for (auto &field : info.fields) | ||
{ | ||
field.schema.required = false; | ||
field.schema.defaultValue.reset(); | ||
} | ||
|
||
return info; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.