mctp: add I3CMCTPDDevice Assignment
This commit adds the assignment of I3CMCTPDDevice to MCTPEndpoint.
Tested on yosemite4, which is a multihost platform with 8 server blades,
mctpreactor may associate these endpoint with EM configs properly.
Change-Id: I4f8038f539245b43ba3c9ac923ccad9670aed87f
Signed-off-by: Unive Tien <unive.tien.wiwynn@gmail.com>
diff --git a/src/VariantVisitors.hpp b/src/VariantVisitors.hpp
index 80d07da..d0ebeff 100644
--- a/src/VariantVisitors.hpp
+++ b/src/VariantVisitors.hpp
@@ -17,8 +17,10 @@
#pragma once
#include <boost/type_index.hpp>
+#include <concepts>
#include <stdexcept>
#include <string>
+#include <vector>
namespace details
{
@@ -66,3 +68,27 @@
boost::typeindex::type_id<T>().pretty_name() + " to string");
}
};
+
+template <std::integral V, std::integral U>
+struct VariantToNumArrayVisitor
+{
+ template <typename T>
+ std::vector<V> operator()(const T& t) const
+ {
+ if constexpr (std::is_same_v<T, std::vector<U>>)
+ {
+ std::vector<V> output;
+ output.reserve(t.size());
+
+ for (const auto& value : t)
+ {
+ output.push_back(static_cast<V>(value));
+ }
+
+ return output;
+ }
+ throw std::invalid_argument(
+ "Cannot handle type " +
+ boost::typeindex::type_id<T>().pretty_name() + " to vector<U>");
+ }
+};