From 213b45cd7d8b0367f85ee68b79941f6d548c1e9c Mon Sep 17 00:00:00 2001 From: Nick Bofferding Date: Tue, 16 Aug 2011 12:40:36 -0500 Subject: Add target iterator and predicate support Change-Id: I728bb312277591d81c0575e74878fba9f816b962 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/260 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III Reviewed-by: MIKE J. JONES --- .../usr/targeting/predicates/predicatectm.H | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/include/usr/targeting/predicates/predicatectm.H (limited to 'src/include/usr/targeting/predicates/predicatectm.H') diff --git a/src/include/usr/targeting/predicates/predicatectm.H b/src/include/usr/targeting/predicates/predicatectm.H new file mode 100644 index 000000000..760f0d02d --- /dev/null +++ b/src/include/usr/targeting/predicates/predicatectm.H @@ -0,0 +1,118 @@ + +#ifndef TARG_PREDICATECTM_H +#define TARG_PREDICATECTM_H + +/** + * @file predicatectm.H + * + * @brief Interface for a predicate which fiters a target based on its class, + * type, and model. + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD + +// Other Host Boot Components + +// Targeting Component +#include +#include +#include + +//****************************************************************************** +// Macros +//****************************************************************************** + +#undef TARG_NAMESPACE +#undef TARG_CLASS +#undef TARG_FN + +//****************************************************************************** +// Interface +//****************************************************************************** + +namespace TARGETING +{ + +#define TARG_NAMESPACE "TARGETING::" +#define TARG_CLASS "PredicateCTM::" + +class Target; + +/** + * @brief Predicate class which filters a target based on its class, type, + * and model + */ +class PredicateCTM : public PredicateBase +{ + public: + + /** + * @brief Create a target class, type, model predicate + * + * @param[in] i_class Class of matching target, default NA (any) + * @param[in] i_type Type of matching target, default NA (any) + * @param[in] i_model Model of matching target, default NA (any) + */ + PredicateCTM( + CLASS i_class = CLASS_NA, + TYPE i_type = TYPE_NA, + MODEL i_model = MODEL_NA); + + /** + * @brief Destroy a class, type, model predicate + */ + virtual ~PredicateCTM() + { + #define TARG_FUNC "~PredicateCTM()" + #undef TARG_FUNC + } + + /** + * @brief Returns whether target matches the specified class, type, + * model + * + * @par Detailed Description: + * Returns whether target matches the specified class, type, model. + * Note that all three fields are always compared, so wildcards + * (CLASS_NA, TYPE_NA, MODEL_NA) must be used for any fields that + * do not matter. See PredicateBase class for parameter/return + * description. + */ + virtual bool operator()( + const Target* i_pTarget) const; + + private: + + CLASS iv_class; ///< Class to compare with that of target + TYPE iv_type; ///< Type to compare with that of target + MODEL iv_model; ///< Model to compare with that of target + + TARG_DISABLE_COPY_AND_ASSIGNMENT_OPERATORS(PredicateCTM); +}; + +//****************************************************************************** +// PredicateCTM::PredicateCTM +//****************************************************************************** + +inline PredicateCTM::PredicateCTM( + const CLASS i_class, + const TYPE i_type, + const MODEL i_model) +: iv_class(i_class), + iv_type(i_type), + iv_model(i_model) +{ + #define TARG_FUNC "PredicateCTM(...)" + #undef TARG_FUNC +} + +#undef TARG_CLASS +#undef TARG_NAMESPACE + +} // End namespace TARGETING + +#endif // TARG_PREDICATECTM_H -- cgit v1.2.1