From 0a1ac480034193a0b6fac9cb1120f9b4101cc7fc Mon Sep 17 00:00:00 2001 From: "Matt K. Light" Date: Wed, 27 Apr 2016 11:37:56 -0500 Subject: alternate multicast implementation Change-Id: I62116a2102dbb31f8ec538211c767c3bbcfd26dd Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/23733 Tested-by: Hostboot CI Tested-by: Jenkins Server Tested-by: PPE CI Reviewed-by: Joachim Fenkes Reviewed-by: Santosh S. Puranik Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/26141 --- import/hwpf/fapi2/include/fapi2_multicast.H | 165 ++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 import/hwpf/fapi2/include/fapi2_multicast.H (limited to 'import/hwpf/fapi2/include/fapi2_multicast.H') diff --git a/import/hwpf/fapi2/include/fapi2_multicast.H b/import/hwpf/fapi2/include/fapi2_multicast.H new file mode 100644 index 00000000..721ecffd --- /dev/null +++ b/import/hwpf/fapi2/include/fapi2_multicast.H @@ -0,0 +1,165 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/fapi2_multicast.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/// +/// @file fapi2_multicast.H +/// @brief Common definitions for fapi2 multicast target value wrapper class +/// + +#ifndef __FAPI2_COMMON_MULTICAST__ +#define __FAPI2_COMMON_MULTICAST__ + +#include +#include + +namespace fapi2 +{ + +/// +/// @brief Class representing a FAPI2 Multicast target value wrapper +/// @tparam M the type of multicast operation +/// @tparam G the type of multicast group +/// @tparam V the type of the target's Value this class is wrapping +/// @remark This wrapper class defines how a handle will behave by +/// type and group if internal to the handle mulitcast operation +/// is enabled. If the handle used is not multicast enabled most +/// function of this class will be ignored. +/// +template +class Multicast +{ + public: + /// + /// @brief Delagate default constructor to constructor + /// that takes in a value as a param + /// + Multicast() : Multicast(V()) {} + + /// + /// @brief Create a Multicast value with a target value + /// @param[in] Value the value (i.e., specific element this + /// target represents, or pointer) + /// @note Platforms can will update the handle value with + /// information on the multicast type and group + /// + Multicast(const V& value) : iv_handle(value) + { + updateHandle(iv_handle); + } + + /// + /// @brief Create a Multicast value from another Multicast value + /// @param[in] other the value + /// @note Platforms can will update the handle value with + /// information on the multicast type and group + /// + template + Multicast(const Multicast other) : + iv_handle(static_cast(other)) + { + updateHandle(iv_handle); + } + + /// + /// @brief Get the handle as a V + /// @return V The Multicast wrapper's internal handle, or value + /// + inline operator V() const + { + return iv_handle; + } + + /// + /// @brief Get the handle as a V + /// @return V The Multicast wrapper's internal handle, or value + /// + inline V& operator()() const + { + return iv_handle; + } + + /// + /// @brief Has the handle been enabled for multicast operation + /// @return Return true if multicast, false otherwise + /// + inline bool isMulticast() const; + + private: + /// + /// @brief update the handle with group and type given + /// @tparam O the type of multicast operation + /// @tparam N the type of multicast group + /// @param[in] Value the value/handle + /// + template + inline void updateHandle(V& value); + + V iv_handle; +}; + +// multicast from unicast +template +inline Target> make_multicast(const Target& t) +{ + return Target>(t.get()); +} + +// multicast from multicast -- changing type +template +inline Target> make_multicast(const Target>& t) +{ + return Target>(t.get()); +} + +// multicast from multicast -- changing type and group +template +inline Target> make_multicast(const Target>& t) +{ + return Target>(t.get()); +} + +// unicast from multicast +template +inline Target make_unicast(const Target>& t) +{ + return Target(t.get()); +} + +// test if a multicast target +template +inline bool is_multicast(const Target>& t) +{ + const Multicast& l_mref = t; + return l_mref.isMulticast(); +} + +// return false if testing a non-multicast target +template +inline bool is_multicast(const Target& t) +{ + return false; +} + +template +constexpr bool is_same() +{ + return (M1 == M2); +} +} + +#endif -- cgit v1.2.1