Program Listing for File gxf_executor.hpp
↰ Return to documentation for file (include/holoscan/core/executors/gxf/gxf_executor.hpp
)
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
#ifndef HOLOSCAN_CORE_EXECUTORS_GXF_GXF_EXECUTOR_HPP
#define HOLOSCAN_CORE_EXECUTORS_GXF_GXF_EXECUTOR_HPP
#include <gxf/core/gxf.h>
#include <cstdint>
#include <functional>
#include <future>
#include <list>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "../../app_driver.hpp"
#include "../../executor.hpp"
#include "../../graph.hpp"
#include "../../gxf/gxf_extension_manager.hpp"
namespace holoscan::gxf {
class GXFExecutor : public holoscan::Executor {
public:
GXFExecutor() = delete;
explicit GXFExecutor(holoscan::Fragment* app, bool create_gxf_context = true);
~GXFExecutor() override;
void run(OperatorGraph& graph) override;
std::future<void> run_async(OperatorGraph& graph) override;
void interrupt() override;
void context(void* context) override;
// Inherit Executor::context().
using Executor::context;
std::shared_ptr<ExtensionManager> extension_manager() override;
static void create_input_port(Fragment* fragment, gxf_context_t gxf_context, gxf_uid_t eid,
IOSpec* io_spec, bool bind_port = false, Operator* op = nullptr);
static void create_output_port(Fragment* fragment, gxf_context_t gxf_context, gxf_uid_t eid,
IOSpec* io_spec, bool bind_port = false, Operator* op = nullptr);
void op_eid(gxf_uid_t eid) { op_eid_ = eid; }
void op_cid(gxf_uid_t cid) { op_cid_ = cid; }
bool own_gxf_context() { return own_gxf_context_; }
const std::string& entity_prefix() { return entity_prefix_; }
protected:
bool initialize_fragment() override;
bool initialize_operator(Operator* op) override;
bool initialize_scheduler(Scheduler* sch) override;
bool initialize_network_context(NetworkContext* network_context) override;
bool add_receivers(const std::shared_ptr<Operator>& op, const std::string& receivers_name,
std::vector<std::string>& new_input_labels,
std::vector<holoscan::IOSpec*>& iospec_vector) override;
friend class holoscan::AppDriver;
friend class holoscan::AppWorker;
bool initialize_gxf_graph(OperatorGraph& graph);
void activate_gxf_graph();
bool run_gxf_graph();
bool connection_items(std::vector<std::shared_ptr<holoscan::ConnectionItem>>& connection_items);
void add_operator_to_entity_group(gxf_context_t context, gxf_uid_t entity_group_gid,
std::shared_ptr<Operator> op);
void register_extensions();
bool own_gxf_context_ = false;
gxf_uid_t op_eid_ = 0;
gxf_uid_t op_cid_ = 0;
std::shared_ptr<GXFExtensionManager> gxf_extension_manager_;
nvidia::gxf::Extension* gxf_holoscan_extension_ = nullptr;
bool is_extensions_loaded_ = false;
bool is_gxf_graph_initialized_ = false;
bool is_gxf_graph_activated_ = false;
std::string entity_prefix_;
std::vector<std::shared_ptr<holoscan::ConnectionItem>> connection_items_;
std::list<gxf_uid_t> implicit_broadcast_entities_;
};
} // namespace holoscan::gxf
#endif/* HOLOSCAN_CORE_EXECUTORS_GXF_GXF_EXECUTOR_HPP */