summaryrefslogtreecommitdiffstats
path: root/src/include/usr/targeting/common/predicates
diff options
context:
space:
mode:
authorNick Bofferding <bofferdn@us.ibm.com>2013-03-29 00:01:56 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-03-29 13:41:30 -0500
commit467ae10a804451a843409e6b94a3c0108c083939 (patch)
treee9ccf6beda47303d5df79553bb5c402365431557 /src/include/usr/targeting/common/predicates
parent192f986571b47f2f3d34556eebd089d9ad55b456 (diff)
downloadtalos-hostboot-467ae10a804451a843409e6b94a3c0108c083939.tar.gz
talos-hostboot-467ae10a804451a843409e6b94a3c0108c083939.zip
Support generic PEER_TARGET navigation
- Updated attribute compiler to lay down FSP specific PEER_TARGETS - Added common predicate to filter targets with specific value for attribute - Added generic PEER_TARGET navigation facility to filter utilities - Added support for platform specific attribute accessor specialization - Added target function to return target based on HUID Change-Id: I190087ee7fb24e80185bc955bd994ee14512a704 RTC: 41735 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3796 Reviewed-by: Brian H. Horton <brianh@linux.ibm.com> Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/usr/targeting/common/predicates')
-rw-r--r--src/include/usr/targeting/common/predicates/predicateattrval.H165
-rw-r--r--src/include/usr/targeting/common/predicates/predicates.H46
2 files changed, 188 insertions, 23 deletions
diff --git a/src/include/usr/targeting/common/predicates/predicateattrval.H b/src/include/usr/targeting/common/predicates/predicateattrval.H
new file mode 100644
index 000000000..7d62ea5ea
--- /dev/null
+++ b/src/include/usr/targeting/common/predicates/predicateattrval.H
@@ -0,0 +1,165 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/usr/targeting/common/predicates/predicateattrval.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* 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. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+#ifndef __TARGETING_COMMON_PREDICATEATTRVAL_H
+#define __TARGETING_COMMON_PREDICATEATTRVAL_H
+
+/**
+ * @file targeting/common/predicates/predicateattrval.H
+ *
+ * @brief Interface and implementation for a predicate which filters a target
+ * based on whether it possesses a given attribute, and if so, the
+ * attribute's value
+ */
+
+//******************************************************************************
+// Includes
+//******************************************************************************
+
+// STD
+
+// Other Host Boot Components
+
+// Targeting Component
+#include <targeting/common/target.H>
+#include <targeting/common/attributes.H>
+#include <targeting/common/predicates/predicatebase.H>
+
+//******************************************************************************
+// Interface and implementation
+//******************************************************************************
+
+namespace TARGETING
+{
+
+#define TARG_NAMESPACE "TARGETING::"
+#define TARG_CLASS "PredicateAttrVal::"
+
+class Target;
+
+/**
+ * @brief Templated predicate class which filters a target based on whether it
+ * possesses a given attribute, and if so, the attribute's value
+ */
+template<const ATTRIBUTE_ID A>
+class PredicateAttrVal : public PredicateBase
+{
+ public:
+
+ /**
+ * @brief Constructor which configures the predicate to filter targets
+ * based on the existence of the attribute type given by the "A"
+ * template parameter, and the input criteria
+ *
+ * @param[in] i_value
+ * Assuming the target being filtered has the attribute given by
+ * the "A" template parameter, the value of that attribute
+ * that will cause the predicate to register a match. If the
+ * i_invertSearch parameter is the non-default value of true,
+ * the predicate registers a match when the value of the
+ * attribute != i_value
+ * @param[in] i_invertSearch
+ * Assuming the attribute is present, this determines what check
+ * needs to be performed on i_value.
+ * If false (default), the predicate registers a match when the
+ * attribute's value is i_value; If false, the predicate registers
+ * a match when the attribute's value is != i_value
+ */
+ PredicateAttrVal(
+ const typename AttributeTraits<A>::Type& i_value,
+ const bool i_invertSearch = false)
+ : iv_value(i_value), iv_invertSearch(i_invertSearch)
+ {
+ }
+
+ /**
+ * @brief Destroys the attribute value predicate
+ */
+ virtual ~PredicateAttrVal()
+ {
+ }
+
+ /**
+ * @brief Returns whether target has an attribute, given by template
+ * parameter "A", whose value matches the filter's configured
+ * criteria
+ *
+ * @par Detailed Description:
+ * Returns whether target has an attribute, given by template
+ * parameter "A", whose value matches the filter's configured
+ * value. Note that the target must have the "A" attribute,
+ * otherwise the predicate will always return false.
+ * Assuming the target has the "A" attribute, if the attribute's
+ * value matches and the search is not inverted, the predicate
+ * returns true. If the attribute's value does not match but the
+ * search is inverted, the predicate also returns true.
+ * Otherwise, the predicate returns false. See
+ * PredicateBase class for parameter/return description.
+ *
+ * @param[in] i_pTarget
+ * Target handle pointing to the target to compare to. Must
+ * not be NULL.
+ *
+ * @return bool indicating whether the target matches or not
+ */
+ virtual bool operator()(
+ const Target* i_pTarget) const
+ {
+ typename AttributeTraits<A>::Type actual; // not set intentionally
+ bool l_match = i_pTarget->tryGetAttr<A>(actual);
+ if(iv_invertSearch == true)
+ {
+ l_match = (l_match && !(iv_value == actual));
+ }
+ else
+ {
+ l_match = (l_match && (iv_value == actual));
+ }
+ return l_match;
+ }
+
+ private:
+
+ /**
+ * @brief Value of attribute to compare for each target filter is
+ * applied to
+ */
+ typename AttributeTraits<A>::Type iv_value;
+
+ // Whether to look for attribute whose value matches iv_value (false) or
+ // an attribute whose value does not match iv_value (true) for target
+ // being filtered
+ bool iv_invertSearch;
+
+ /**
+ * @brief Disable copy/assignment operators
+ */
+ TARG_DISABLE_COPY_AND_ASSIGNMENT_OPERATORS(PredicateAttrVal);
+};
+
+#undef TARG_CLASS
+#undef TARG_NAMESPACE
+
+} // End namespace TARGETING
+
+#endif // __TARGETING_COMMON_PREDICATEATTRVAL_H
diff --git a/src/include/usr/targeting/common/predicates/predicates.H b/src/include/usr/targeting/common/predicates/predicates.H
index e0dbdf248..85b75d1f9 100644
--- a/src/include/usr/targeting/common/predicates/predicates.H
+++ b/src/include/usr/targeting/common/predicates/predicates.H
@@ -1,26 +1,25 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/include/usr/targeting/common/predicates/predicates.H $
- *
- * IBM CONFIDENTIAL
- *
- * COPYRIGHT International Business Machines Corp. 2012
- *
- * p1
- *
- * Object Code Only (OCO) source materials
- * Licensed Internal Code Source Materials
- * IBM HostBoot Licensed Internal Code
- *
- * The source code for this program is not published or other-
- * wise divested of its trade secrets, irrespective of what has
- * been deposited with the U.S. Copyright Office.
- *
- * Origin: 30
- *
- * IBM_PROLOG_END_TAG
- */
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/usr/targeting/common/predicates/predicates.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012,2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* 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. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
#ifndef __TARGETING_COMMON_PREDICATES_H
#define __TARGETING_COMMON_PREDICATES_H
@@ -35,6 +34,7 @@
#include <targeting/common/predicates/predicateisfunctional.H>
#include <targeting/common/predicates/predicatehwas.H>
#include <targeting/common/predicates/predicatepostfixexpr.H>
+#include <targeting/common/predicates/predicateattrval.H>
// please keep up to date...
OpenPOWER on IntegriCloud