From ff9b8bb838ecdfbfc1dc81038fcf3b2a87636982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Zrounba?= <6691770+clement-z@users.noreply.github.com> Date: Sat, 30 Sep 2023 23:06:01 +0200 Subject: Initial release --- src/utils/sysc_utils.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/utils/sysc_utils.h (limited to 'src/utils/sysc_utils.h') diff --git a/src/utils/sysc_utils.h b/src/utils/sysc_utils.h new file mode 100644 index 0000000..be275a0 --- /dev/null +++ b/src/utils/sysc_utils.h @@ -0,0 +1,67 @@ +#pragma once + +#include + +#include +#include + +using std::vector; +using std::set; + +bool sc_object_is_module(const sc_object &obj); + +// Return vector containing all children objects (expanded) of obj +set sc_collect_children_object(sc_object* obj); + +// Return vector containing all children objects (expanded) of obj +set sc_collect_children_module(sc_module* obj); + +// Return vector containing all sc_module registered with engine +set sc_get_all_module(); + +// Return vector containing all sc_object registered with engine +set sc_get_all_object(); + +// Return vector containing all sc_module of a certain type +template +set sc_get_all_module_by_type(); + +// Return vector containing all sc_object of a certain type +template +set sc_get_all_object_by_type(); + +//////////////////////////////////////// +// Definition of template functions +//////////////////////////////////////// + + +template +set sc_get_all_module_by_type() { + set all_modules = sc_get_all_module(); + set all_requested; + for (auto mod : all_modules) + { + // cout << mod->name() << endl; + auto requested = dynamic_cast(mod); + if (requested) + all_requested.insert(requested); + } + return all_requested; +} + +template +set sc_get_all_object_by_type() { + set all_objects = sc_get_all_object(); + set all_requested; + + for (auto obj : all_objects) + { + //cout << obj->name() << endl; + auto requested = dynamic_cast(obj); + if (requested) { + //cout << "\\__( WE WANT IT )" << endl; + all_requested.insert(requested); + } + } + return all_requested; +} \ No newline at end of file -- cgit v1.2.3