/** * @file include/ActivMiddleware/Misc/SerializableUnorderedMapHelper.h * * @brief Unordered map serialization helpers. */ #if (!defined ACTIV_MISC_SERIALIZABLE_UNORDERED_MAP_HELPER_H) #define ACTIV_MISC_SERIALIZABLE_UNORDERED_MAP_HELPER_H #include "ActivMiddleware/Misc/SerializableContainerHelper.h" #include ACTIV_BOOST_INCLUDE(unordered_map.hpp) //! Activ namespace. namespace Activ { /** * @brief SerializableContainerHelper specialization for Boost::unordered_map containers. */ template class SerializableContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH, OBJECT_HELPER> { public: typedef Boost::unordered_map Container; typedef COUNT_TYPE Count; typedef OBJECT_HELPER ObjectHelper; /** * @brief Serialize a map. * * @param messageBuilder * @param map container to serialize. * * @retval STATUS_CODE_SUCCESS * @retval ... */ static StatusCode Serialize(MessageBuilder &messageBuilder, const Container &map) { return SerializeAssociativeContainer(messageBuilder, map); } /** * @brief Deserialize a map. * * @param messageValidator * @param map container to deserialize into. * @param shouldClearContainer whether to empty the container first, or just add new entries. * * @retval STATUS_CODE_SUCCESS * @retval ... */ static StatusCode Deserialize(MessageValidator &messageValidator, Container &map, const bool shouldClearContainer) { return DeserializeAssociativeContainer(messageValidator, map, shouldClearContainer); } }; // --------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------- /** * @brief Partial specialization of SerializableObjectContainerHelper to serialize Boost::unordered_maps of objects. */ template class SerializableObjectContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH> : public SerializableContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH, SerializableObjectHelper > { }; // --------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------- /** * @brief Partial specialization of SerializableRawPointerContainerHelper to serialize Boost::unordered_maps of raw pointers to objects. * * Note that currently the key type must not be a pointer, the mapped type should be a raw pointer. */ template class SerializableRawPointerContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH> : public SerializableContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH, SerializableRawPointerHelper > { }; // --------------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------------- /** * @brief Partial specialization of helper class to serialize Boost::unordered_maps of smart pointers to objects. * * Note that currently the key type must not be a pointer, the mapped type should be a smart pointer. */ template class SerializableSmartPointerContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH> : public SerializableContainerHelper, COUNT_TYPE, MIN_LENGTH, MAX_LENGTH, SerializableSmartPointerHelper > { }; } // namespace Activ #endif // (!defined ACTIV_MISC_SERIALIZABLE_UNORDERED_MAP_HELPER_H)