LCOV - code coverage report
Current view: top level - include/ad/rss/structured - RssConstellationIdProvider.hpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 2 2 100.0 %
Date: 2025-07-22 06:53:46 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2018-2021 Intel Corporation
       4                 :            : //
       5                 :            : // SPDX-License-Identifier: LGPL-2.1-only
       6                 :            : //
       7                 :            : // ----------------- END LICENSE BLOCK -----------------------------------
       8                 :            : /**
       9                 :            :  * @file
      10                 :            :  */
      11                 :            : 
      12                 :            : #pragma once
      13                 :            : 
      14                 :            : #include <map>
      15                 :            : #include <set>
      16                 :            : #include "ad/rss/core/RelativeConstellationId.hpp"
      17                 :            : #include "ad/rss/world/Constellation.hpp"
      18                 :            : #include "ad/rss/world/TimeIndex.hpp"
      19                 :            : 
      20                 :            : /*!
      21                 :            :  * @brief namespace ad
      22                 :            :  */
      23                 :            : namespace ad {
      24                 :            : /*!
      25                 :            :  * @brief namespace rss
      26                 :            :  */
      27                 :            : namespace rss {
      28                 :            : /*!
      29                 :            :  * @brief namespace structured
      30                 :            :  */
      31                 :            : namespace structured {
      32                 :            : 
      33                 :            : /*!
      34                 :            :  * @brief class supporting to keep track of unique constellation ids
      35                 :            :  *
      36                 :            :  * Constellation id's have to be constant over time.
      37                 :            :  */
      38                 :            : class RssConstellationIdProvider
      39                 :            : {
      40                 :            : public:
      41                 :            :   /*!
      42                 :            :    * @brief default constructor
      43                 :            :    */
      44                 :        775 :   RssConstellationIdProvider() = default;
      45                 :            : 
      46                 :            :   /*!
      47                 :            :    * @brief default destructor
      48                 :            :    */
      49                 :        775 :   ~RssConstellationIdProvider() = default;
      50                 :            : 
      51                 :            :   /*!
      52                 :            :    * @brief get the constellation id of the given constellation
      53                 :            :    *
      54                 :            :    * @param[in] time_index the time index the constellation refers to
      55                 :            :    * @param[in] constellation the relevant constellation
      56                 :            :    *
      57                 :            :    * @return the constellation id assigned to the given constellation
      58                 :            :    */
      59                 :            :   core::RelativeConstellationId getConstellationId(world::TimeIndex const &time_index,
      60                 :            :                                                    world::Constellation const &constellation);
      61                 :            : 
      62                 :            :   /*!
      63                 :            :    * @brief drop all constallation ids associated with a given object_id
      64                 :            :    *
      65                 :            :    * This function might be used to drop previous states referred to a certain object id in case the object id is reused
      66                 :            :    *
      67                 :            :    * @param[in] object_id the object_id all previous constallations should be dropped
      68                 :            :    */
      69                 :            :   void dropConstellationIds(world::ObjectId const &object_id);
      70                 :            : 
      71                 :            : private:
      72                 :            :   struct ConstellationData
      73                 :            :   {
      74                 :            :     ConstellationData(world::TimeIndex time_index,
      75                 :            :                       core::RelativeConstellationId const constellation_id,
      76                 :            :                       world::Constellation const &constellation);
      77                 :            :     /*!
      78                 :            :      * @brief update the current constellation data in case the constellation matches the constellation data
      79                 :            :      *
      80                 :            :      * @return \c true if the update succeeded, \c false if the constellation doesn't match the constellation
      81                 :            :      */
      82                 :            :     bool updateConstellation(world::TimeIndex time_index, world::Constellation const &constellation);
      83                 :            : 
      84                 :            :     typedef std::set<world::LaneSegmentId> IntersectionArea;
      85                 :            : 
      86                 :            :     /*!
      87                 :            :      * Most of the time the intersection areas are identical
      88                 :            :      * If a vehicle has already entered the intersection, the areas are shrinking,
      89                 :            :      * but still have to be identical from end on
      90                 :            :      * As a consequence the whole new areas have to be within the old ones.
      91                 :            :      *
      92                 :            :      * @return \c true if the left intersection area is fully contained in the right one.
      93                 :            :      */
      94                 :            :     bool isSmallerOrEqual(IntersectionArea const &left, IntersectionArea const &right) const;
      95                 :            : 
      96                 :            :     /*!
      97                 :            :      * @brief extract the intersection area from the RoadArea
      98                 :            :      */
      99                 :            :     IntersectionArea getIntersectionArea(world::RoadArea const &roadArea);
     100                 :            : 
     101                 :            :     world::TimeIndex mTimeIndex;
     102                 :            :     world::ConstellationType mConstellationType;
     103                 :            :     core::RelativeConstellationId mConstellationId;
     104                 :            :     IntersectionArea mEgoVehicleIntersectionArea;
     105                 :            :     IntersectionArea mObjectIntersectionArea;
     106                 :            :   };
     107                 :            : 
     108                 :            :   /*!
     109                 :            :    * Update the time and free outdated data.
     110                 :            :    *
     111                 :            :    * @param[in] time_index the current time index
     112                 :            :    */
     113                 :            :   void updateTime(world::TimeIndex const &time_index);
     114                 :            : 
     115                 :            :   /*!
     116                 :            :    * @brief get the next free constellation id
     117                 :            :    */
     118                 :            :   core::RelativeConstellationId getFreeConstellationId();
     119                 :            : 
     120                 :            :   typedef std::multimap<world::ObjectId, ConstellationData> ConstellationDataMap;
     121                 :            : 
     122                 :            :   world::TimeIndex mCurrentTime{0};
     123                 :            :   world::TimeIndex mLastTime{0};
     124                 :            :   core::RelativeConstellationId mNextConstellationId{0};
     125                 :            :   ConstellationDataMap mConstellationData;
     126                 :            : };
     127                 :            : 
     128                 :            : } // namespace structured
     129                 :            : } // namespace rss
     130                 :            : } // namespace ad

Generated by: LCOV version 1.14