68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
/**
|
|
* @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<typename T>
|
|
class ForNotPresentOptionalFieldsHelper
|
|
{
|
|
public:
|
|
ForNotPresentOptionalFieldsHelper(const FieldIdBitmap &presentFieldIdBitmap, T &function) :
|
|
m_presentFieldIdBitmap(presentFieldIdBitmap),
|
|
m_function(function)
|
|
{
|
|
}
|
|
|
|
template<typename FIELD>
|
|
void operator()(Identity<FIELD>) 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<FIELD> parameter of the optional field not present in
|
|
* @a presentFieldIdBitmap.
|
|
*/
|
|
template<typename OPTIONAL_FIELD_LIST, typename T>
|
|
static void ForNotPresentOptionalFields(const FieldIdBitmap &presentFieldIdBitmap, T &function)
|
|
{
|
|
ForNotPresentOptionalFieldsHelper<T> forNotPresentOptionalFieldsHelper(presentFieldIdBitmap, function);
|
|
|
|
Boost::mpl::for_each<OPTIONAL_FIELD_LIST, MakeIdentity<Boost::mpl::_1> >(forNotPresentOptionalFieldsHelper);
|
|
}
|
|
|
|
} // namespace Detail
|
|
|
|
} // namespace GenericMessages
|
|
|
|
} // namespace Activ
|
|
|
|
#endif // (!defined ACTIV_BASE_GENERIC_MESSAGES_DETAIL_OPTIONAL_FIELDS_HELPER_H)
|