summaryrefslogtreecommitdiff
path: root/python/openvino/runtime/common/format_reader/register.h
diff options
context:
space:
mode:
authorEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
committerEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
commitab224e2e6ba65f5a369ec392f99cd8845ad06c98 (patch)
treea1e757e9341863ed52b8ad4c5a1c45933aab9da4 /python/openvino/runtime/common/format_reader/register.h
parent40da1752f2c8639186b72f6838aa415e854d0b1d (diff)
downloadthesis-master.tar.gz
thesis-master.tar.bz2
thesis-master.zip
completed thesisHEADmaster
Diffstat (limited to 'python/openvino/runtime/common/format_reader/register.h')
-rw-r--r--python/openvino/runtime/common/format_reader/register.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/python/openvino/runtime/common/format_reader/register.h b/python/openvino/runtime/common/format_reader/register.h
new file mode 100644
index 0000000..781eca3
--- /dev/null
+++ b/python/openvino/runtime/common/format_reader/register.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2018-2022 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+/**
+ * \brief Register for readers
+ * \file register.h
+ */
+#pragma once
+
+#include <functional>
+#include <string>
+#include <vector>
+
+#include "format_reader.h"
+
+namespace FormatReader {
+/**
+ * \class Registry
+ * \brief Create reader from fabric
+ */
+class Registry {
+private:
+ typedef std::function<Reader*(const std::string& filename)> CreatorFunction;
+ static std::vector<CreatorFunction> _data;
+
+public:
+ /**
+ * \brief Create reader
+ * @param filename - path to input data
+ * @return Reader for input data or nullptr
+ */
+ static Reader* CreateReader(const char* filename);
+
+ /**
+ * \brief Registers reader in fabric
+ * @param f - a creation function
+ */
+ static void RegisterReader(CreatorFunction f);
+};
+
+/**
+ * \class Register
+ * \brief Registers reader in fabric
+ */
+template <typename To>
+class Register {
+public:
+ /**
+ * \brief Constructor creates creation function for fabric
+ * @return Register object
+ */
+ Register() {
+ Registry::RegisterReader([](const std::string& filename) -> Reader* {
+ return new To(filename);
+ });
+ }
+};
+} // namespace FormatReader