Commit 41581e45 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Remove reference ID - WIP

parent 0207b44f
......@@ -24,14 +24,7 @@ namespace ITA
///
/// \brief Unique identifier for this task
///
unsigned long int uiID;
///
/// \brief Reference identifier for the user.
///
/// Used to identify a source-receiver-pair.
///
unsigned long int uiReferenceID;
unsigned long int uiID;
///
......
......@@ -446,4 +446,14 @@ auto IsSet ( const Enum& enumToTest, const Enum& enumForTest ) -> typename std::
#define ENABLE_BITMASK_OPERATORS(x) template<> struct EnableBitMaskOperators<x> : std::true_type {};
struct pair_hash
{
template <class T1, class T2>
std::size_t operator() ( const std::pair<T1, T2>& pair ) const
{
return std::hash<T1> ( )( pair.first ) ^ std::hash<T2> ( )( pair.second );
}
};
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_UTILS_DATA_TYPE_UTILS
\ No newline at end of file
......@@ -239,9 +239,10 @@ namespace ITA
/// \brief Map containing all latest simulated updates.
///
/// This is map is used for the filters to be able to reference the latest simulated update for its decision.
/// The key is comprised of the receiver ID as first and source ID as second.
/// \remark Note the use of unordered_map. This type of map has on average constant complexity for \p find.
///
std::unordered_map<int, CUpdateScene*> m_mPreviousStates;
std::unordered_map<std::pair<int, int>, CUpdateScene*, pair_hash> m_mPreviousStates;
///
/// \brief True if the controller should filter its received updates using filterReplace().
......
......@@ -30,11 +30,6 @@ namespace ITA
///
SourceReceiverPair sourceReceiverPair = SourceReceiverPair ( );
///
/// \brief Identifier for the source-receiver-pair.
///
int iReferenceID = -1;
///
/// \brief Serialize the object.
/// \param pSerializer the IVistaSerializer to use.
......
......@@ -39,14 +39,6 @@ namespace ITA
///
CUpdateScene ( ) = default;
///
/// \brief Constructor for a CUpdateScene.
///
/// This constructor initializes the ID to the next free ID and source and receiver to nullptrs.
/// \param referenceID the reference ID for the update.
///
explicit CUpdateScene ( unsigned int referenceID );
///
/// \brief Copy constructor.
/// \note This also copies the timestamp to keep the creation time of the original update.
......@@ -78,12 +70,6 @@ namespace ITA
///
void SetSourceReceiverPair ( std::unique_ptr<C3DObject> pSource, std::unique_ptr<C3DObject> pReceiver );
///
/// \brief Get the reference ID of update.
/// \return the reference ID of update.
///
unsigned int GetReferenceID ( ) const;
///
/// \brief Get the timestamp of update.
/// \return the timestamp of update.
......@@ -134,13 +120,6 @@ namespace ITA
///
std::unique_ptr<C3DObject> m_pReceiver;
///
/// \brief The reference ID of the update (For the user).
///
/// It encodes the source receiver path.
///
int m_iReferenceID = -1;
///
/// \brief Time stamp of the update.
/// \todo Is this necessary?
......@@ -169,7 +148,6 @@ namespace ITA
rhsSourceReceiverPair.source && rhsSourceReceiverPair.receiver)
{
return lhs.GetID ( ) == rhs.GetID ( ) &&
lhs.GetReferenceID ( ) == rhs.GetReferenceID ( ) &&
lhs.GetTimeStamp ( ) == rhs.GetTimeStamp ( ) &&
*lhsSourceReceiverPair.source == *rhsSourceReceiverPair.source &&
*lhsSourceReceiverPair.receiver == *rhsSourceReceiverPair.receiver;
......@@ -177,7 +155,6 @@ namespace ITA
else
{
return lhs.GetID ( ) == rhs.GetID ( ) &&
lhs.GetReferenceID ( ) == rhs.GetReferenceID ( ) &&
lhs.GetTimeStamp ( ) == rhs.GetTimeStamp ( );
}
......
......@@ -52,7 +52,6 @@ namespace ITA
auto pTask = std::make_unique<CSimulationTask> ( );
pTask->eSimulationType = m_eFieldOfDuty;
pTask->uiID = pUpdate->GetID ( );
pTask->uiReferenceID = pUpdate->GetReferenceID ( );
// This is the previous implementation of this. Was is faster to only set certain members?
/*auto eFlags = pTask->oConfig.compare ( *m_pRavenConfig );
......@@ -169,7 +168,6 @@ namespace ITA
auto returnResult = std::make_unique<CRIRSimulationResult> ( );
returnResult->eResultType = pTask->eSimulationType;
returnResult->iReferenceID = pTask->uiReferenceID;
returnResult->bZerosStripped = soundPath->bZerosStripped;
returnResult->iLeadingZeros = soundPath->iLeadingZeros;
returnResult->iTrailingZeros = soundPath->iTailingZeros;
......
......@@ -15,7 +15,8 @@ void ITA::SimulationScheduler::CReplacementFilter::FilterReplace ( std::list<std
{
if ( const auto updateSceneLambda = dynamic_cast< CUpdateScene* >( update.get ( ) ) )
{
if ( updateScene->GetReferenceID ( ) == updateSceneLambda->GetReferenceID ( ) &&
if ( updateScene->GetSourceReceiverPair ( ).receiver->GetId ( ) == updateSceneLambda->GetSourceReceiverPair ( ).receiver->GetId ( ) &&
updateScene->GetSourceReceiverPair ( ).source->GetId ( ) == updateSceneLambda->GetSourceReceiverPair ( ).source->GetId ( ) &&
updateScene->GetTimeStamp ( ) > updateSceneLambda->GetTimeStamp ( ) )
{
PROFILER_VALUE ( "Removed Updates", updateSceneLambda->GetID ( ) );
......@@ -40,7 +41,8 @@ void ITA::SimulationScheduler::CReplacementFilter::FilterReplace ( std::list<std
{
updateList.remove_if ( [&] ( const std::unique_ptr<CUpdateScene>& update )->bool
{
if ( ( *updateIter )->GetReferenceID ( ) == update->GetReferenceID ( ) &&
if ( ( *updateIter )->GetSourceReceiverPair ( ).receiver->GetId ( ) == update->GetSourceReceiverPair ( ).receiver->GetId ( ) &&
( *updateIter )->GetSourceReceiverPair ( ).source->GetId ( ) == update->GetSourceReceiverPair ( ).source->GetId ( ) &&
( *updateIter )->GetTimeStamp ( ) > update->GetTimeStamp ( ) )
{
PROFILER_VALUE ( "Removed Updates", update->GetID ( ) );
......
......@@ -147,10 +147,13 @@ namespace ITA
auto bAudible = true;
// Check if a previous update exists.
if ( m_mPreviousStates.find ( pUpdate->GetReferenceID ( ) ) != m_mPreviousStates.end ( ) )
auto mapKey = std::make_pair ( pUpdate->GetSourceReceiverPair ( ).receiver->GetId ( ),
pUpdate->GetSourceReceiverPair ( ).receiver->GetId ( ) );
if ( m_mPreviousStates.find ( mapKey ) != m_mPreviousStates.end ( ) )
{
// Test if the update is audible.
bAudible = m_pFilterNetwork->EvaluateNetwork ( *m_mPreviousStates.at ( pUpdate->GetReferenceID ( ) ), *pUpdate );
bAudible = m_pFilterNetwork->EvaluateNetwork ( *m_mPreviousStates.at ( mapKey ), *pUpdate );
}
if ( bAudible )
......@@ -289,7 +292,9 @@ namespace ITA
PROFILER_VALUE ( "Update Scence To Simulator", update->GetID ( ) );
// save a copy for the filters.
m_mPreviousStates [update->GetReferenceID ( )] = new CUpdateScene ( *update );
auto mapKey = std::make_pair ( update->GetSourceReceiverPair ( ).receiver->GetId ( ),
update->GetSourceReceiverPair ( ).receiver->GetId ( ) );
m_mPreviousStates [mapKey] = new CUpdateScene ( *update );
// post the update to the worker.
worker->PushUpdate ( std::move ( update ) );
......
......@@ -18,7 +18,6 @@ namespace ITA
returnVal += pSerializer.WriteSerializable ( *sourceReceiverPair.source );
returnVal += pSerializer.WriteSerializable ( *sourceReceiverPair.receiver );
returnVal += pSerializer.WriteInt32(iReferenceID);
return returnVal;
}
......@@ -34,8 +33,6 @@ namespace ITA
returnVal += pDeserializer.ReadSerializable ( *receiver );
sourceReceiverPair.receiver = receiver;
returnVal += pDeserializer.ReadInt32 ( iReferenceID );
return returnVal;
}
......
......@@ -12,14 +12,9 @@ namespace ITA
{
namespace SimulationScheduler
{
CUpdateScene::CUpdateScene ( unsigned int referenceID ) :
m_iReferenceID ( referenceID )
{ }
CUpdateScene::CUpdateScene ( const CUpdateScene& other )
: IUpdateMessage ( other ),
m_iReferenceID ( other.m_iReferenceID ),
m_dTimeStamp ( other.m_dTimeStamp )
{
if ( other.m_pSource )
......@@ -36,12 +31,14 @@ namespace ITA
m_pSource = std::make_unique<C3DObject> ( *other.m_pSource );
if ( other.m_pReceiver )
m_pReceiver = std::make_unique<C3DObject> ( *other.m_pReceiver );
m_iReferenceID = other.m_iReferenceID;
m_dTimeStamp = other.m_dTimeStamp;
return *this;
}
SourceReceiverPair CUpdateScene::GetSourceReceiverPair ( ) const
{
if ( m_pReceiver == nullptr, m_pSource == nullptr )
ITA_EXCEPT_INVALID_PARAMETER("Source and receiver is not set.")
SourceReceiverPair pair;
pair.source = m_pSource.get ( );
......@@ -61,10 +58,6 @@ namespace ITA
else
ITA_EXCEPT_INVALID_PARAMETER ( "Wrong type given" );
}
unsigned int CUpdateScene::GetReferenceID ( ) const
{
return m_iReferenceID;
}
double ITA::SimulationScheduler::CUpdateScene::GetTimeStamp ( ) const
{
return m_dTimeStamp;
......@@ -72,15 +65,13 @@ namespace ITA
bool CUpdateScene::IsEqualTolerance ( const CUpdateScene& obj, double dTolerance ) const
{
return m_pSource->IsEqualTolerance ( *obj.m_pSource, dTolerance ) &&
m_pReceiver->IsEqualTolerance ( *obj.m_pReceiver, dTolerance ) &&
m_iReferenceID == obj.m_iReferenceID;
m_pReceiver->IsEqualTolerance ( *obj.m_pReceiver, dTolerance );
}
int CUpdateScene::Serialize ( IVistaSerializer& pSerializer ) const
{
int returnVal = 0;
returnVal += pSerializer.WriteInt32 ( m_iID );
returnVal += pSerializer.WriteInt32 ( m_iReferenceID );
returnVal += pSerializer.WriteFloat64 ( m_dTimeStamp );
returnVal += pSerializer.WriteSerializable ( *m_pReceiver );
returnVal += pSerializer.WriteSerializable ( *m_pSource );
......@@ -92,7 +83,6 @@ namespace ITA
int returnVal = 0;
returnVal += pDeserializer.ReadInt32 ( m_iID );
returnVal += pDeserializer.ReadInt32 ( m_iReferenceID );
returnVal += pDeserializer.ReadFloat64 ( m_dTimeStamp );
if ( m_pReceiver == nullptr && m_pSource == nullptr )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment