Program Listing for File data_loader.hpp

(Latest Version)

Return to documentation for file (morpheus/_lib/include/morpheus/io/data_loader.hpp)


/* * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "morpheus/export.h" #include "morpheus/messages/control.hpp" #include "morpheus/messages/meta.hpp" #include <nlohmann/json.hpp> #include <map> #include <memory> #include <string> namespace morpheus { class MORPHEUS_EXPORT Loader { public: ~Loader() = default; Loader() = default; Loader(nlohmann::json config); virtual std::shared_ptr<MessageMeta> payload(std::shared_ptr<ControlMessage> message); virtual std::shared_ptr<ControlMessage> load(std::shared_ptr<ControlMessage> message, nlohmann::json task); protected: nlohmann::json config() const; private: nlohmann::json m_config{}; // Configuration information for the loader. }; class MORPHEUS_EXPORT DataLoader { public: DataLoader() = default; DataLoader(nlohmann::json config); ~DataLoader() = default; std::shared_ptr<ControlMessage> load(std::shared_ptr<ControlMessage> control_message); void add_loader(const std::string& loader_id, std::shared_ptr<Loader> loader, bool overwrite = true); void remove_loader(const std::string& loader_id, bool throw_if_not_found = true); private: std::map<std::string, std::shared_ptr<Loader>> m_loaders{}; // Map of registered loader instances. nlohmann::json m_config; }; } // namespace morpheus

© Copyright 2024, NVIDIA. Last updated on Jul 8, 2024.