Program Listing for File io_spec.hpp

Clara Holoscan v0.4.0

Return to documentation for file (include/holoscan/core/io_spec.hpp)


/* * SPDX-FileCopyrightText: Copyright (c) 2022 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. */ #ifndef HOLOSCAN_CORE_IO_SPEC_HPP #define HOLOSCAN_CORE_IO_SPEC_HPP #include <iostream> #include <memory> #include <string> #include <typeinfo> #include <utility> #include <vector> #include "./conditions/gxf/boolean.hpp" #include "./conditions/gxf/count.hpp" #include "./conditions/gxf/downstream_affordable.hpp" #include "./conditions/gxf/message_available.hpp" #include "./gxf/entity.hpp" #include "./common.hpp" namespace holoscan { class IOSpec { public: enum class IOType { kInput, kOutput }; IOSpec(OperatorSpec* op_spec, const std::string& name, IOType io_type) : op_spec_(op_spec), name_(name), io_type_(io_type), typeinfo_(&typeid(holoscan::gxf::Entity)) {} IOSpec(OperatorSpec* op_spec, const std::string& name, IOType io_type, const std::type_info* typeinfo) : op_spec_(op_spec), name_(name), io_type_(io_type), typeinfo_(typeinfo) {} OperatorSpec* op_spec() const { return op_spec_; } const std::string& name() const { return name_; } IOType io_type() const { return io_type_; } const std::type_info* typeinfo() const { return typeinfo_; } std::shared_ptr<Resource> resource() const { return resource_; } void resource(std::shared_ptr<Resource> resource) { resource_ = resource; } std::vector<std::pair<ConditionType, std::shared_ptr<Condition>>>& conditions() { return conditions_; } template <typename... ArgsT> IOSpec& condition(ConditionType type, ArgsT&&... args) { switch (type) { case ConditionType::kMessageAvailable: conditions_.emplace_back( type, std::make_shared<MessageAvailableCondition>(std::forward<ArgsT>(args)...)); break; case ConditionType::kDownstreamMessageAffordable: conditions_.emplace_back( type, std::make_shared<DownstreamMessageAffordableCondition>(std::forward<ArgsT>(args)...)); break; case ConditionType::kCount: conditions_.emplace_back(type, std::make_shared<CountCondition>(std::forward<ArgsT>(args)...)); break; case ConditionType::kBoolean: conditions_.emplace_back(type, std::make_shared<BooleanCondition>(std::forward<ArgsT>(args)...)); break; case ConditionType::kNone: conditions_.emplace_back(type, nullptr); break; } return *this; } private: OperatorSpec* op_spec_ = nullptr; std::string name_; IOType io_type_; const std::type_info* typeinfo_ = nullptr; std::shared_ptr<Resource> resource_; std::vector<std::pair<ConditionType, std::shared_ptr<Condition>>> conditions_; }; } // namespace holoscan #endif/* HOLOSCAN_CORE_IO_SPEC_HPP */

© Copyright 2022, NVIDIA. Last updated on Jun 28, 2023.