Review typing for MEC 010-2 V3.1.1; Rebuild all test suites before starting...

Review typing for MEC 010-2 V3.1.1; Rebuild all test suites before starting reviewing and implementations

Merge request reports

Loading
+0 −28
Changes for ccsrc/EncDec/LibHttp/LibItsHttp_Encdec.cc: 0 added lines, 28 removed lines.
Original line number Diff line number Diff line

#include "LibItsHttp_MessageBodyTypes.hh"

#include "http_codec.hh"

#include "loggers.hh"

namespace LibItsHttp__EncdecDeclarations {

  BITSTRING fx__enc__http__message(const LibItsHttp__TypesAndValues::HttpMessage& p) {
    loggers::get_instance().log_msg(">>> fx__enc__http__message: ", (const Base_Type&)p);

    OCTETSTRING os;
    http_codec codec;
    codec.encode(p, os);

    return oct2bit(os);
  }
  INTEGER fx__dec__http__message(BITSTRING& pdu, LibItsHttp__TypesAndValues::HttpMessage& p) {
    loggers::get_instance().log_msg(">>> fx__dec__http__message: ", pdu);

    OCTETSTRING os = bit2oct(pdu);
    http_codec codec;
    codec.decode(os, p);

    return 0;
  }
} // End of namespace LibItsHttp__EncdecDeclarations

ccsrc/EncDec/LibHttp/module.mk

deleted100644 → 0
+0 −1
Changes for ccsrc/EncDec/LibHttp/module.mk: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
sources := LibItsHttp_Encdec.cc
+0 −62
Changes for ccsrc/Framework/include/base_time.hh: 0 added lines, 62 removed lines.
Original line number Diff line number Diff line
/*!
 * \file      base_time.hh
 * \brief     Header file for the control port base_time functionality.
 * \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 <chrono>

/**
 * \class base_time
 * \brief This class provides time tools such as getting current time
 */
class base_time {
  const unsigned long long its_base_time_ms = 1072915200000L; //! Base time 01/01/2004 12:00am in millseconds
  
  static base_time* _instance;
private:
  base_time() { }; //! Can not be created manually
public:
  static inline base_time& get_instance();

  virtual ~base_time() { if (_instance != nullptr) delete _instance; };
  
public:
  inline const unsigned long long get_current_time_ms() const;
  inline const unsigned long long get_its_base_time_ms() const;
  inline const unsigned long long get_its_current_time_ms() const;
  inline const unsigned long long get_its_current_time_us() const;
  inline const unsigned long long get_its_current_time_mod_ms() const;
}; // End of class base_time

// static functions
base_time& base_time::get_instance() {
  return (_instance != nullptr) ? *_instance : *(_instance = new base_time());
}

const unsigned long long base_time::get_current_time_ms() const {
  return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}

const unsigned long long base_time::get_its_base_time_ms() const {
  return base_time::its_base_time_ms;
}

const unsigned long long base_time::get_its_current_time_ms() const {
  return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time_ms;
}

const unsigned long long base_time::get_its_current_time_us() const {
  return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time_ms * 1000;
}

const unsigned long long base_time::get_its_current_time_mod_ms() const {
  return (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() - base_time::its_base_time_ms) % 65536;
}

ccsrc/Framework/include/codec.hh

deleted100644 → 0
+0 −63
Changes for ccsrc/Framework/include/codec.hh: 0 added lines, 63 removed lines.
Original line number Diff line number Diff line
/*!
 * \file      codec.hh
 * \brief     Header file for ITS abstract codec definition.
 * \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 "params.hh"

class OCTETSTRING; //! Declare TITAN class
class CHARSTRING;  //! Declare TITAN class
class BITSTRING;   //! Declare TITAN class

/*!
 * \class codec
 * \brief  This class provides the interface for all ITS codecs, include UT and AC codecs
 * \abstract
 */
template<typename TPDUEnc, typename TPDUDec>
class codec {
protected:
  params* _params; //! Reference to params stack
                   // \todo Use smart pointer std::unique_ptr<params>
  
public: //! \publicsection
  /*!
   * \fn codec();
   * \brief  Default constructor
   * \todo Remove logs
   */
  explicit codec() : _params(nullptr) { };
  /*!
   * \fn ~codec();
   * \brief  Default destructor
   * \virtual
   * \todo Remove logs
   */
  virtual ~codec() { };
  /*!
   * \fn int encode(const TPDUEnc& msg, OCTETSTRING& data);
   * \brief  Encode typed message into an octet string
   * \param[in] p_message The typed message to be encoded
   * \param[out] p_data The encoding result
   * \return 0 on success, -1 otherwise
   * \pure
   */
  virtual int encode(const TPDUEnc& p_message, OCTETSTRING& p_data) = 0;
  /*!
   * \fn int decode(const OCTETSTRING& p_, TPDUDec& p_message, params* p_params = NULL);
   * \brief  Encode typed message into an octet string format
   * \param[in] p_data The message in its octet string
   * \param[out] p_message The decoded typed message
   * \return 0 on success, -1 otherwise
   * \pure
   */
  virtual int decode(const OCTETSTRING& p_, TPDUDec& p_message, params* p_params = NULL) = 0;
}; // End of class codec
+0 −74
Changes for ccsrc/Framework/include/codec_stack_builder.hh: 0 added lines, 74 removed lines.
Original line number Diff line number Diff line
/*!
 * \file      codec_stack_builder.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 "codec_factory.hh"

class Record_Type; //! TITAN forward declaration

/*!
 * \class codec_stack_builder
 * \brief  This class provides a factory class to create Codec class instances
 */
class codec_stack_builder {
private: //! \privatesection
  static codec_stack_builder* _instance;         //! Smart pointer to the unique instance of the logger framework
  std::map<std::string, codec_factory*> _codecs; //! The list of the registered \see t_codec factories

  /*!
   * \brief Default constructor
   *        Create a new instance of the codec_stack_builder class
   * \private
   */
  codec_stack_builder() { }; // can not be created manually
public: //! \publicsection
  /*!
   * \fn codec_stack_builder* get_instance();
   * \brief Accessor for the unique instance of the logger framework
   * \static
   */
  static codec_stack_builder* get_instance() { return _instance ? _instance : _instance = new codec_stack_builder(); };

  /*!
   * \fn void register_codec_factory(const std::string & p_type, codec_factory<TPDUEnc, TPDUDec>* p_codec_factory);
   * \brief Add a new codec factory
   * \param[in] p_type          The codec identifier (e.g. GN for the GeoNetworking codec...)
   * \param[in] p_codec_factory A reference to the \see codec_factory
   * \static
   */
  static void register_codec_factory(const std::string & p_type, codec_factory* p_codec_factory) { codec_stack_builder::get_instance()->_register_codec_factory(p_type, p_codec_factory); };

private: //! \privatesection
  /*!
   * \fn void _register_codec_factory(const std::string & p_type, codec_factory<TPDUEnc, TPDUDec>* p_codec_factory);
   * \brief Add a new codec factory
   * \param[in] p_type          The codec identifier (e.g. GN for the GeoNetworking codec...)
   * \param[in] p_codec_factory A reference to the \see codec_factory
   */
  void _register_codec_factory(const std::string & p_type, codec_factory* p_codec_factory) { _codecs[p_type] = p_codec_factory; };

public: //! \publicsection
  /*!
   * \fn codec* get_codec(const char* p_codec_name);
   * \brief Retrieve the specified codec name from the list of the registered codecs
   * \param[in] p_codec_name The codec indentifier
   * \return The pointer to the codec object on success, nullptr otherwise
   */
  inline codec<Record_Type, Record_Type>* get_codec(const char* p_codec_name) { // NOTE A virtual method cannot not be a template ==> polymorphism required here
    typename std::map<std::string, codec_factory*>::const_iterator it = _codecs.find(p_codec_name);
    if (it != _codecs.cend()) {
      return it->second->create_codec();
    }

    return nullptr;
  }
}; // End of class codec_stack_builder
Loading
Loading