From 48212a3b481c60d6b6f97fc86f05afa0f549eab9 Mon Sep 17 00:00:00 2001
From: NAUD Maxence <maxence.naud@cea.fr>
Date: Wed, 10 Jan 2024 14:05:46 +0000
Subject: [PATCH] [Add] GraphView helper for manipulation functions, add
 'producers()'

---
 include/aidge/recipies/GraphViewHelper.hpp | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 include/aidge/recipies/GraphViewHelper.hpp

diff --git a/include/aidge/recipies/GraphViewHelper.hpp b/include/aidge/recipies/GraphViewHelper.hpp
new file mode 100644
index 000000000..d7bcec713
--- /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
-- 
GitLab