layer_stack_builder.hh 2.53 KB
Newer Older
garciay's avatar
garciay committed
/*!
garciay's avatar
garciay committed
 * \file      layer_stack_builder.hh
garciay's avatar
garciay committed
 * \brief     Header file for ITS protocol stack builder.
 * \author    ETSI STF525
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */
#pragma once

garciay's avatar
garciay committed
#include "layer_factory.hh"
garciay's avatar
garciay committed

/*!
garciay's avatar
garciay committed
 * \class layer_stack_builder
garciay's avatar
garciay committed
 * \brief  This class provides a factory class to create Layer class instances
 */
garciay's avatar
garciay committed
class layer_stack_builder {
private: //! \privatesection
garciay's avatar
garciay committed
  typedef std::map<std::string, layer_factory*> LayerFactoryMap;
garciay's avatar
garciay committed

garciay's avatar
garciay committed
  static layer_stack_builder * _instance;                        //! Smart pointer to the unique instance of the logger framework
  std::map<std::string, layer_factory*> _layer_factories; //! The list of the registered \see TLayer factories

  /*!
   * \brief Default constructor
garciay's avatar
garciay committed
   *        Create a new instance of the layer_stack_builder class
garciay's avatar
garciay committed
  layer_stack_builder(); // can not be created manually
public: //! \publicsection
  /*!
garciay's avatar
garciay committed
   * \fn layer_stack_builder* get_instance();
   * \brief Accessor for the unique instance of the logger framework
   * \static
   */
garciay's avatar
garciay committed
  static layer_stack_builder* get_instance();
garciay's avatar
garciay committed
   * \fn void register_layer_factory(const std::string & p_type, layer_factory* p_layer_factory);
   * \brief Add a new layer factory
   * \param[in] p_type          The layer identifier (e.g. GN for the GeoNetworking layer...)
garciay's avatar
garciay committed
   * \param[in] p_layer_factory A reference to the \see layer_factory
garciay's avatar
garciay committed
  static void register_layer_factory(const std::string & p_type, layer_factory* p_layer_factory);

private: //! \privatesection
  /*!
garciay's avatar
garciay committed
   * \fn void _register_layer_factory(const std::string & p_type, layer_factory* p_layer_factory);
   * \brief Add a new layer factory
   * \param[in] p_type          The layer identifier (e.g. GN for the GeoNetworking layer...)
garciay's avatar
garciay committed
   * \param[in] p_layer_factory A reference to the \see layer_factory
garciay's avatar
garciay committed
  void _register_layer_factory(const std::string & p_type, layer_factory* p_layer_factory);
garciay's avatar
garciay committed

public: //! \publicsection
  /*!
   * \fn Layer* create_layer_stack(const char* p_layer_stack_description);
   * \brief Add a new layer factory
   * \param[in] p_layer_stack_description A textual description of the layer to create
   * \return The created layer object on success, nullptr otherwise
   */
  Layer* create_layer_stack(const char* p_layer_stack_description);
garciay's avatar
garciay committed
}; // End of class layer_stack_builder
garciay's avatar
garciay committed