Skip to content
Snippets Groups Projects
message.hpp 1.68 KiB
Newer Older
LetoGdT's avatar
LetoGdT committed
#pragma once
#include <boost/serialization/list.hpp>

/**
* @namespace message
* @brief Handle different representation of an agent
* @see agent
LetoGdT's avatar
LetoGdT committed
namespace message
{
  template <typename T>
	/**
	* @struct request
	* @brief Represent a serialized agent extracted from an archive
	*
	*/
LetoGdT's avatar
LetoGdT committed
  struct request
  {
    int id; /**< Identifier of this agent */
    int nb_eval; /**< Total number of evaluation on this agent */
    uint64_t seed; /**< Random seed used by the ALE to test this agent */
    T params; /**< Unserialized agent */
LetoGdT's avatar
LetoGdT committed
    template <typename Archive>
    /**
    * @fn serialize
    * @brief Save/Load agent with archive 
    *
    * @param[in,out] ar Archived agent
    * @remark The second parameter is unused, as we don't ensure retrocompatibility.
    * @warning Don't use it. This function is automatically called when (un)serializing with boost.
LetoGdT's avatar
LetoGdT committed
    void serialize(Archive& ar, const unsigned int)
    {
      ar & id
         & nb_eval
         & seed
         & params;
    }
  };

  template <typename T>
  /**
  * @struct result
  * @brief Represent a serialized agent freshly tested
  *
  */
LetoGdT's avatar
LetoGdT committed
  struct result
  {
    int id; /**< Identifier of this agent */
    std::list<T> results; /**< List of score performed by this agent during testing */
LetoGdT's avatar
LetoGdT committed
    template <typename Archive>
    /**
    * @fn serialize
    * @brief Save/Load agent with archive
    *
    * @param[in,out] ar Archived agent
    * @remark The second parameter is unused, as we don't ensure retrocompatibility.
    * @waringn Don't use it. This function is automatically called when (un)serializing with boost.
LetoGdT's avatar
LetoGdT committed
    void serialize(Archive& ar, const unsigned int)
    {
      ar & id
         & results;
    }
  };
}