LCOV - code coverage report
Current view: top level - src/world - RssSituationIdProvider.hpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 2 2 100.0 %
Date: 2024-04-16 14:13:10 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/situation/SituationId.hpp"
      17                 :            : #include "ad/rss/world/Scene.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 world
      30                 :            :  */
      31                 :            : namespace world {
      32                 :            : 
      33                 :            : /*!
      34                 :            :  * @brief class supporting to keep track of unique situation ids
      35                 :            :  *
      36                 :            :  * Situation id's have to be constant over time.
      37                 :            :  */
      38                 :            : class RssSituationIdProvider
      39                 :            : {
      40                 :            : public:
      41                 :            :   /*!
      42                 :            :    * @brief default constructor
      43                 :            :    */
      44                 :        725 :   RssSituationIdProvider() = default;
      45                 :            : 
      46                 :            :   /*!
      47                 :            :    * @brief default destructor
      48                 :            :    */
      49                 :        725 :   ~RssSituationIdProvider() = default;
      50                 :            : 
      51                 :            :   /*!
      52                 :            :    * @brief get the situation id of the given scene
      53                 :            :    *
      54                 :            :    * @param[in] timeIndex the time index the scene refers to
      55                 :            :    * @param[in] scene the relevant scene
      56                 :            :    *
      57                 :            :    * @return the situation id assigned to the given scene
      58                 :            :    */
      59                 :            :   situation::SituationId getSituationId(TimeIndex const &timeIndex, Scene const &scene);
      60                 :            : 
      61                 :            : private:
      62                 :            :   struct SituationData
      63                 :            :   {
      64                 :            :     SituationData(TimeIndex timeIndex, situation::SituationId const situationId, Scene const &scene);
      65                 :            :     /*!
      66                 :            :      * @brief update the current situation data in case the scene matches the situation data
      67                 :            :      *
      68                 :            :      * @return \c true if the update succeeded, \c false if the scene doesn't match the situation
      69                 :            :      */
      70                 :            :     bool updateSituation(TimeIndex timeIndex, Scene const &scene);
      71                 :            : 
      72                 :            :     typedef std::set<LaneSegmentId> IntersectionArea;
      73                 :            : 
      74                 :            :     /*!
      75                 :            :      * Most of the time the intersection areas are identical
      76                 :            :      * If a vehicle has already entered the intersection, the areas are shrinking,
      77                 :            :      * but still have to be identical from end on
      78                 :            :      * As a consequence the whole new areas have to be within the old ones.
      79                 :            :      *
      80                 :            :      * @return \c true if the left intersection area is fully contained in the right one.
      81                 :            :      */
      82                 :            :     bool isSmallerOrEqual(IntersectionArea const &left, IntersectionArea const &right) const;
      83                 :            : 
      84                 :            :     /*!
      85                 :            :      * @brief extract the intersection area from the RoadArea
      86                 :            :      */
      87                 :            :     IntersectionArea getIntersectionArea(RoadArea roadArea);
      88                 :            : 
      89                 :            :     TimeIndex mTimeIndex;
      90                 :            :     situation::SituationType mSituationType;
      91                 :            :     situation::SituationId mSituationId;
      92                 :            :     IntersectionArea mEgoVehicleIntersectionArea;
      93                 :            :     IntersectionArea mObjectIntersectionArea;
      94                 :            :   };
      95                 :            : 
      96                 :            :   /*!
      97                 :            :    * Update the time and free outdated data.
      98                 :            :    *
      99                 :            :    * @param[in] timeIndex the current time index
     100                 :            :    */
     101                 :            :   void updateTime(TimeIndex const &timeIndex);
     102                 :            : 
     103                 :            :   /*!
     104                 :            :    * @brief get the next free situation id
     105                 :            :    */
     106                 :            :   situation::SituationId getFreeSituationId();
     107                 :            : 
     108                 :            :   typedef std::multimap<ObjectId, SituationData> SituationDataMap;
     109                 :            : 
     110                 :            :   TimeIndex mCurrentTime{0};
     111                 :            :   TimeIndex mLastTime{0};
     112                 :            :   situation::SituationId mNextSituationId{0};
     113                 :            :   SituationDataMap mSituationData;
     114                 :            : };
     115                 :            : 
     116                 :            : } // namespace world
     117                 :            : } // namespace rss
     118                 :            : } // namespace ad

Generated by: LCOV version 1.14