Commit e3b44c94 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Change to shared ptr for create function param - WIP

parent 81d91f11
......@@ -32,7 +32,7 @@ namespace ITA
/// /// \brief Factory function for an audibility filter.
/// /// \remark This function should to be static.
/// ///
/// static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& );
/// static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
/// \endcode
///
class ITA_SIMULATION_SCHEDULER_API IAudibilityFilter
......@@ -103,7 +103,7 @@ namespace ITA
///
/// \brief The function signature for a create function.
///
typedef std::function<std::unique_ptr<IAudibilityFilter> ( const IAudibilityFilter::AudibilityFilterConfig& )> CreateCallback;
typedef std::function<std::unique_ptr<IAudibilityFilter> ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )> CreateCallback;
///
/// \brief Register a type of filter to the factory.
......@@ -123,7 +123,7 @@ namespace ITA
/// \param pConfig the configuration for the filter.
/// \return a pointer to the created filter.
///
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& pConfig );
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
private:
///
......
......@@ -76,7 +76,7 @@ namespace ITA
/// \brief Factory function for a filter.
/// \remark This function should to be static.
///
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& oConfig );
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
private:
///
......
......@@ -73,7 +73,7 @@ namespace ITA
/// \brief Factory function for a filter.
/// \remark This function should to be static.
///
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& oConfig );
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
private:
///
......
......@@ -91,7 +91,7 @@ namespace ITA
/// \brief Factory function for a filter.
/// \remark This function should to be static.
///
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& oConfig );
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
private:
///
......
......@@ -70,7 +70,7 @@ namespace ITA
/// \brief Factory function for a filter.
/// \remark This function should to be static.
///
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& oConfig );
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
private:
///
......
......@@ -76,7 +76,7 @@ namespace ITA
/// \brief Factory function for CZoneFilter.
/// \remark This function should to be static.
///
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& oConfig );
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig );
private:
///
......
......@@ -62,9 +62,9 @@ namespace ITA
m_mFilters.erase ( type );
}
std::unique_ptr<IAudibilityFilter> CAudibilityFilterFactory::createFilter ( const IAudibilityFilter::AudibilityFilterConfig& pConfig )
std::unique_ptr<IAudibilityFilter> CAudibilityFilterFactory::createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
auto it = m_mFilters.find ( pConfig.sFilterType );
auto it = m_mFilters.find ( pConfig->sFilterType );
if ( it != m_mFilters.end ( ) )
{
// call the creation callback to construct this derived type
......
......@@ -53,9 +53,9 @@ namespace ITA
}
std::unique_ptr<IAudibilityFilter> CRateFilter::createFilter (
const IAudibilityFilter::AudibilityFilterConfig& oConfig )
const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
return std::make_unique<CRateFilter> ( reinterpret_cast< const RateFilterConfig& >( oConfig ) );
return std::make_unique<CRateFilter> ( dynamic_cast< const RateFilterConfig& >( *pConfig ) );
}
} // namespace audibility_filter
} // namespace simulation_scheduler
......
......@@ -55,9 +55,9 @@ namespace ITA
}
std::unique_ptr<IAudibilityFilter> CReverberationRadiusFilter::createFilter (
const IAudibilityFilter::AudibilityFilterConfig& oConfig )
const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
return std::make_unique<CReverberationRadiusFilter> ( reinterpret_cast< const ReverberationRadiusFilterConfig& >( oConfig ) );
return std::make_unique<CReverberationRadiusFilter> ( dynamic_cast< const ReverberationRadiusFilterConfig& >( *pConfig ) );
}
} // namespace audibility_filter
} // namespace simulation_scheduler
......
......@@ -64,9 +64,9 @@ namespace ITA
}
std::unique_ptr<IAudibilityFilter> CRotationFilter::createFilter (
const IAudibilityFilter::AudibilityFilterConfig& oConfig )
const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
return std::make_unique<CRotationFilter> ( reinterpret_cast< const RotationFilterConfig& >( oConfig ) );
return std::make_unique<CRotationFilter> ( dynamic_cast< const RotationFilterConfig& >( *pConfig ) );
}
bool CRotationFilter::checkRelativeRotation ( const CUpdateScene& previousState, const CUpdateScene& newUpdate ) const
......
......@@ -55,9 +55,9 @@ namespace ITA
}
std::unique_ptr<IAudibilityFilter> CTranslationFilter::createFilter (
const IAudibilityFilter::AudibilityFilterConfig& oConfig )
const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
return std::make_unique<CTranslationFilter> ( reinterpret_cast< const TranslationFilterConfig& >( oConfig ) );
return std::make_unique<CTranslationFilter> ( dynamic_cast< const TranslationFilterConfig& >( *pConfig ) );
}
} // namespace audibility_filter
} // namespace simulation_scheduler
......
......@@ -84,9 +84,9 @@ namespace ITA
}
std::unique_ptr<IAudibilityFilter> CZoneFilter::createFilter (
const IAudibilityFilter::AudibilityFilterConfig& oConfig )
const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
return std::make_unique<CZoneFilter> ( reinterpret_cast< const CZoneFilter::ZoneFilterConfig& >( oConfig ) );
return std::make_unique<CZoneFilter> (dynamic_cast< const CZoneFilter::ZoneFilterConfig& >( *pConfig ) );
}
} // namespace audibility_filter
} // namespace simulation_scheduler
......
......@@ -110,9 +110,9 @@ struct MockAudibilityFilter : public audibility_filter::IAudibilityFilter
bAudible = pConfig.GetValueInSubListOrDefault ( "Audible", "Mock", false );
}
static std::unique_ptr<IAudibilityFilter> createFilter ( const IAudibilityFilter::AudibilityFilterConfig& pConfig )
static std::unique_ptr<IAudibilityFilter> createFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
return std::make_unique<MockAudibilityFilter> ( pConfig );
return std::make_unique<MockAudibilityFilter> ( dynamic_cast<const MockFilterConfig&>(*pConfig) );
}
bool changeIsAudible ( const CUpdateScene& previousState, const CUpdateScene& newUpdate ) const override
......
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