diff --git a/include/aidge/recipies/GraphViewHelper.hpp b/include/aidge/recipies/GraphViewHelper.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d7bcec713087054640c87c6fd229fee53d1ed4a6 --- /dev/null +++ b/include/aidge/recipies/GraphViewHelper.hpp @@ -0,0 +1,40 @@ +/******************************************************************************** + * Copyright (c) 2023 CEA-List + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +#ifndef AIDGE_CORE_UTILS_RECIPIES_H_ +#define AIDGE_CORE_UTILS_RECIPIES_H_ + +#include <memory> +#include <set> + +#include "aidge/graph/Node.hpp" +#include "aidge/graph/GraphView.hpp" + + +namespace Aidge { + +/** + * @brief Getter for every Producer operator in a GraphView. + * @param graphview GraphView instance where Producers should be searched. + * @return std::set<std::shared_ptr<Node>> + */ +std::set<std::shared_ptr<Aidge::Node>> producers(std::shared_ptr<Aidge::GraphView> graphview) { + std::set<std::shared_ptr<Node>> res; + const std::set<std::shared_ptr<Node>> nodes = graphview->getNodes(); + + std::copy_if(nodes.cbegin(), + nodes.cend(), + std::inserter(res, res.begin()), + [](std::shared_ptr<Node> n){ return n->type() == "Producer"; }); + + return res; +} +} // namespace Aidge \ No newline at end of file