/** * @file include/ActivMiddleware/ActivBase/GenericMessages/Detail/OptionalFieldsHelper.h * * @brief Header for dealing with optional fields. */ #if (!defined ACTIV_BASE_GENERIC_MESSAGES_DETAIL_OPTIONAL_FIELDS_HELPER_H) #define ACTIV_BASE_GENERIC_MESSAGES_DETAIL_OPTIONAL_FIELDS_HELPER_H namespace Activ { namespace GenericMessages { namespace Detail { template class ForNotPresentOptionalFieldsHelper { public: ForNotPresentOptionalFieldsHelper(const FieldIdBitmap &presentFieldIdBitmap, T &function) : m_presentFieldIdBitmap(presentFieldIdBitmap), m_function(function) { } template void operator()(Identity) const { if (!m_presentFieldIdBitmap[FIELD::id]) m_function(FIELD::id); } private: const FieldIdBitmap & m_presentFieldIdBitmap; T & m_function; }; // --------------------------------------------------------------------------------------------------------------------------------- /** * @brief Invoke a call for each optional field id not present in a FieldIdBitmap. * * @tparam OPTIONAL_FIELD_LIST mpl sequence of the optional field ids. * @tparam T the function type. * * @param presentFieldIdBitmap * @param function the callable entity; expects single Identity parameter of the optional field not present in * @a presentFieldIdBitmap. */ template static void ForNotPresentOptionalFields(const FieldIdBitmap &presentFieldIdBitmap, T &function) { ForNotPresentOptionalFieldsHelper forNotPresentOptionalFieldsHelper(presentFieldIdBitmap, function); Boost::mpl::for_each >(forNotPresentOptionalFieldsHelper); } } // namespace Detail } // namespace GenericMessages } // namespace Activ #endif // (!defined ACTIV_BASE_GENERIC_MESSAGES_DETAIL_OPTIONAL_FIELDS_HELPER_H)