LayerStackBuilder.hh 2.5 KB
Newer Older
garciay's avatar
garciay committed
/*!
 * \file      LayerStackBuilder.hh
 * \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

#include "LayerFactory.hh"

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

  static LayerStackBuilder * _instance;                        //! Smart pointer to the unique instance of the logger framework
  std::map<std::string, LayerFactory*> _layer_factories; //! The list of the registered \see TLayer factories

  /*!
   * \brief Default constructor
   *        Create a new instance of the LayerStackBuilder class
   * \private
   */
garciay's avatar
garciay committed
  LayerStackBuilder(); // can not be created manually
public: //! \publicsection
  /*!
   * \fn LayerStackBuilder* get_instance();
   * \brief Accessor for the unique instance of the logger framework
   * \static
   */
  static LayerStackBuilder* get_instance();

  /*!
   * \fn void register_layer_factory(const std::string & p_type, LayerFactory* p_layer_factory);
   * \brief Add a new layer factory
   * \param[in] p_type          The layer identifier (e.g. GN for the GeoNetworking layer...)
   * \param[in] p_layer_factory A reference to the \see LayerFactory
   * \static
   */
  static void register_layer_factory(const std::string & p_type, LayerFactory* p_layer_factory);

private: //! \privatesection
  /*!
   * \fn void _register_layer_factory(const std::string & p_type, LayerFactory* p_layer_factory);
   * \brief Add a new layer factory
   * \param[in] p_type          The layer identifier (e.g. GN for the GeoNetworking layer...)
   * \param[in] p_layer_factory A reference to the \see LayerFactory
   */
  void _register_layer_factory(const std::string & p_type, LayerFactory* 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 LayerStackBuilder