Skip to content

Commit

Permalink
BRAYNS-593 Add loaders to the doc. (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien4193 committed Nov 14, 2023
1 parent e082d23 commit 182c4a4
Show file tree
Hide file tree
Showing 58 changed files with 1,802 additions and 1,158 deletions.
4 changes: 2 additions & 2 deletions brayns/Brayns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Brayns::Brayns(int argc, const char **argv):
LoggingStartup::run(_parametersManager);

Log::info("Registering core loaders.");
_loaderRegistry = LoaderRegistry::createWithCoreLoaders();
_loaderRegistry = CoreLoaderRegistry::create();

if (NetworkStartup::isEnabled(*this))
{
Expand All @@ -144,7 +144,7 @@ Brayns::~Brayns()
{
_network->stop();
}
_loaderRegistry.clear();
_loaderRegistry = {};
// make sure that plugin objects are removed first, as plugins are
// destroyed before the engine, but plugin destruction still should have
// a valid engine and _api (aka this object).
Expand Down
54 changes: 54 additions & 0 deletions brayns/io/EmptyLoaderParams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* Copyright (c) 2015-2023, EPFL/Blue Brain Project
*
* 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/json/Json.h>

namespace brayns
{
struct EmptyLoaderParams
{
};

template<>
struct JsonAdapter<EmptyLoaderParams>
{
static JsonSchema getSchema()
{
auto schema = JsonSchema();
schema.title = "EmptyLoaderParams";
schema.type = JsonType::Undefined;
return schema;
}

static void serialize(const EmptyLoaderParams &value, JsonValue &json)
{
(void)value;
JsonFactory::emplaceObject(json);
}

static void deserialize(const JsonValue &json, EmptyLoaderParams &value)
{
(void)json;
(void)value;
}
};
} // namespace brayns
66 changes: 66 additions & 0 deletions brayns/io/ILoader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* Copyright (c) 2015-2023, EPFL/Blue Brain Project
*
* Responsible Author: Daniel.Nachbaur@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 <functional>
#include <memory>
#include <string>
#include <string_view>
#include <vector>

#include <brayns/engine/model/Model.h>

#include <brayns/json/Json.h>

#include <brayns/utils/string/StringCase.h>

namespace brayns
{
using LoaderProgress = std::function<void(const std::string &, float)>;

struct RawBinaryLoaderRequest
{
std::string_view format;
std::string_view data;
LoaderProgress progress = [](const auto &, auto) {};
JsonValue params;
};

struct RawFileLoaderRequest
{
std::string_view path;
LoaderProgress progress = [](const auto &, auto) {};
JsonValue params;
};

class ILoader
{
public:
virtual ~ILoader() = default;

virtual std::string getName() const = 0;
virtual std::vector<std::string> getExtensions() const = 0;
virtual JsonSchema getSchema() const = 0;
virtual bool canLoadBinary() const = 0;
virtual std::vector<std::shared_ptr<Model>> loadBinary(const RawBinaryLoaderRequest &request) = 0;
virtual std::vector<std::shared_ptr<Model>> loadFile(const RawFileLoaderRequest &request) = 0;
};
} // namespace brayns
86 changes: 0 additions & 86 deletions brayns/io/Loader.cpp

This file was deleted.

0 comments on commit 182c4a4

Please sign in to comment.