Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITASimulationScheduler
Commits
49dc7f0d
Commit
49dc7f0d
authored
Aug 07, 2020
by
Pascal Palenda
Browse files
Start implementing a template factory
parent
2fdc7734
Changes
25
Hide whitespace changes
Inline
Side-by-side
include/ITA/SimulationScheduler/AudibilityFilter/audibility_filter_interface.h
View file @
49dc7f0d
...
...
@@ -6,6 +6,7 @@
// simulation scheduler includes
#include
<ITA/SimulationScheduler/config_interface.h>
#include
<ITA/SimulationScheduler/factory.h>
// std includes
#include
<memory>
...
...
@@ -50,7 +51,7 @@ namespace ITA
///
/// \brief Base configuration class for audibility filter.
///
/// \note ::s
Filter
Type is a read only property of the AudibilityFilterConfig.
/// \note ::sType is a read only property of the AudibilityFilterConfig.
/// Due to this the copy constructor and assignment operator are needed.
///
struct
ITA_SIMULATION_SCHEDULER_API
AudibilityFilterConfig
:
public
IConfig
...
...
@@ -65,7 +66,7 @@ namespace ITA
std
::
string
sFilterName
=
"Unknown"
;
const
std
::
string
&
s
Filter
Type
;
const
std
::
string
&
sType
;
std
::
vector
<
std
::
string
>
sNextFilter
;
...
...
@@ -100,6 +101,9 @@ namespace ITA
static
void
CheckUpdateTimestamp
(
const
CUpdateScene
&
previousState
,
const
CUpdateScene
&
newUpdate
);
};
typedef
CFactory
<
IAudibilityFilter
,
IAudibilityFilter
::
AudibilityFilterConfig
>
ITA_SIMULATION_SCHEDULER_API
CAudibilityFilterFactory
;
/*
///
/// \brief Factory class for filter.
///
...
...
@@ -154,7 +158,11 @@ namespace ITA
///
static std::map<std::string, std::pair<CreateCallback, ConfigCreateCallback>> m_mFilters;
};
*/
}
// namespace AudibilityFilter
ENABLE_FACTORY
(
AudibilityFilter
::
IAudibilityFilter
::
AudibilityFilterConfig
);
}
// namespace SimulationScheduler
}
// namespace ITA
...
...
include/ITA/SimulationScheduler/OutdoorAcoustics/outdoor_worker_thread.h
View file @
49dc7f0d
...
...
@@ -52,7 +52,7 @@ namespace ITA
//! \brief Constructor for CWorkerThread.
//! \param oConfig the WorkerConfig used to configure the CWorkerThread.
//! \param pParent the parent scheduler of the worker.
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
,
ISchedulerInterface
*
pParent
);
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
);
//! \brief Destructor of CWorkerThread.
/**
...
...
@@ -83,7 +83,7 @@ namespace ITA
//! \brief Factory function for CWorkerThread.
//! \param pConfig the WorkerConfig used to configure the CWorkerThread.
//! \param pParent the parent scheduler of the worker.
static
std
::
unique_ptr
<
IWorkerInterface
>
CreateWorker
(
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
,
ISchedulerInterface
*
pParent
);
static
std
::
unique_ptr
<
IWorkerInterface
>
CreateWorker
(
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
);
//! \brief Return a unique type identifying string.
//! \return a unique type identifying string.
...
...
include/ITA/SimulationScheduler/RoomAcoustics/Raven/raven_worker_interface.h
View file @
49dc7f0d
...
...
@@ -45,9 +45,8 @@ namespace ITA
///
/// \brief Constructor for a IRavenWorkerInterface.
/// \param oConfig the WorkerConfig used to configure the IWorkerInterface.
/// \param pParent the parent scheduler of the worker.
///
explicit
IRavenWorkerInterface
(
const
RavenWorkerConfig
&
oConfig
,
ISchedulerInterface
*
pParent
);
explicit
IRavenWorkerInterface
(
const
RavenWorkerConfig
&
oConfig
);
///
/// \brief Pure virtual destructor.
...
...
include/ITA/SimulationScheduler/RoomAcoustics/Raven/worker_thread.h
View file @
49dc7f0d
...
...
@@ -52,9 +52,8 @@ namespace ITA
///
/// \brief Constructor for CWorkerThread.
/// \param oConfig the WorkerConfig used to configure the CWorkerThread.
/// \param pParent the parent scheduler of the worker.
///
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
,
ISchedulerInterface
*
pParent
);
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
);
///
/// \brief Destructor of CWorkerThread.
...
...
@@ -87,9 +86,8 @@ namespace ITA
///
/// \brief Factory function for CWorkerThread.
/// \param pConfig the WorkerConfig used to configure the CWorkerThread.
/// \param pParent the parent scheduler of the worker.
///
static
std
::
unique_ptr
<
IWorkerInterface
>
CreateWorker
(
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
,
ISchedulerInterface
*
pParent
);
static
std
::
unique_ptr
<
IWorkerInterface
>
CreateWorker
(
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
);
///
/// \brief Return a unique type identifying string.
...
...
include/ITA/SimulationScheduler/RoomAcoustics/room_acoustics_worker_interface.h
View file @
49dc7f0d
...
...
@@ -36,9 +36,8 @@ namespace ITA
///
/// \brief Constructor for IRoomAcousticsWorkerInterface.
/// \param oConfig the config for the IRoomAcousticsWorkerInterface.
/// \param pParent the parent scheduler of the worker.
///
IRoomAcousticsWorkerInterface
(
const
RoomAcousticsWorkerInterfaceConfig
&
oConfig
,
ISchedulerInterface
*
pParent
);
IRoomAcousticsWorkerInterface
(
const
RoomAcousticsWorkerInterfaceConfig
&
oConfig
);
virtual
~
IRoomAcousticsWorkerInterface
(
)
=
0
;
...
...
include/ITA/SimulationScheduler/_SourceFiles.cmake
View file @
49dc7f0d
...
...
@@ -23,6 +23,7 @@ set( DirFiles
scheduler.h
worker_interface.h
config_interface.h
factory.h
#_SourceFiles.cmake
)
...
...
include/ITA/SimulationScheduler/factory.h
0 → 100644
View file @
49dc7f0d
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_FACTORY
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_FACTORY
// std includes
#include
<memory>
#include
<functional>
// API includes
#include
<ITA/SimulationScheduler/definitions.h>
// simulation scheduler includes
#include
<ITA/SimulationScheduler/update_scene.h>
#include
<ITA/SimulationScheduler/config_interface.h>
namespace
ITA
{
namespace
SimulationScheduler
{
template
<
class
Enum
>
struct
EnableFactory
:
public
std
::
false_type
{
};
#define ENABLE_FACTORY(x) template<> struct ITA_SIMULATION_SCHEDULER_API EnableFactory<x> : public std::true_type {};
///
/// \brief Factory class for Worker.
///
/// This class implements an extensible factory for objects.
/// After a type of object is registered with its create function and config, it can be created using this factory.
///
template
<
class
objectT
,
class
objectConfigT
>
class
CFactory
{
public:
static_assert
(
EnableFactory
<
objectConfigT
>::
value
,
"Factory creation is not allowed for this config type; "
"use ENABLE_FACTORY macro."
);
///
/// \brief The function signature for a create function.
///
typedef
std
::
function
<
std
::
unique_ptr
<
objectT
>
(
const
std
::
shared_ptr
<
objectConfigT
>&
)
>
CreateCallback
;
///
/// \brief The function signature for a config create function.
///
typedef
std
::
function
<
std
::
shared_ptr
<
objectConfigT
>
(
)
>
ConfigCreateCallback
;
typedef
std
::
map
<
std
::
string
,
std
::
pair
<
CreateCallback
,
ConfigCreateCallback
>
>
FactoryFunctionMap_t
;
///
/// \brief Register a type of object to the factory.
/// \param type name of the object type to be registered.
/// \param createFunction the corresponding create function.
/// \param configCreateFunction the corresponding config create function.
///
static
void
RegisterObject
(
const
std
::
string
&
type
,
CreateCallback
createFunction
,
ConfigCreateCallback
configCreateFunction
)
{
m_mFactoryFunctions
[
type
]
=
{
createFunction
,
configCreateFunction
};
}
///
/// \brief Unregister a type of object from the factory.
/// \param type name of the worker type to be removed.
///
static
void
UnregisterObject
(
const
std
::
string
&
type
)
{
m_mFactoryFunctions
.
erase
(
type
);
}
///
/// \brief Factory method.
/// \param pConfig the configuration for the object.
/// \return a pointer to the created object.
///
static
std
::
unique_ptr
<
objectT
>
CreateObject
(
const
std
::
shared_ptr
<
objectConfigT
>&
pConfig
)
{
auto
it
=
m_mFactoryFunctions
.
find
(
pConfig
->
sType
);
if
(
it
!=
m_mFactoryFunctions
.
end
(
)
)
{
// call the creation callback to construct this derived type
return
it
->
second
.
first
(
pConfig
);
}
return
nullptr
;
}
///
/// \brief Factory method for configs.
/// \param sType the configuration for the object.
/// \return a pointer to the created config.
///
static
std
::
shared_ptr
<
objectConfigT
>
CreateConfig
(
const
std
::
string
&
sType
)
{
auto
it
=
m_mFactoryFunctions
.
find
(
sType
);
if
(
it
!=
m_mFactoryFunctions
.
end
(
)
)
{
// call the creation callback to construct this derived type
return
it
->
second
.
second
(
);
}
return
nullptr
;
}
private:
///
/// \brief Map containing all creation functions and config creation functions.
///
static
FactoryFunctionMap_t
m_mFactoryFunctions
;
};
}
// namespace SimulationScheduler
}
// namespace ITA
#endif // INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_FACTORY
\ No newline at end of file
include/ITA/SimulationScheduler/worker_interface.h
View file @
49dc7f0d
...
...
@@ -11,6 +11,7 @@
// simulation scheduler includes
#include
<ITA/SimulationScheduler/update_scene.h>
#include
<ITA/SimulationScheduler/config_interface.h>
#include
<ITA/SimulationScheduler/factory.h>
namespace
ITA
...
...
@@ -43,7 +44,7 @@ namespace ITA
///
/// \brief Base configuration class for worker.
///
/// \note ::s
Worker
Type is a read only property of the WorkerConfig.
/// \note ::sType is a read only property of the WorkerConfig.
/// Due to this the copy constructor and assignment operator are needed.
///
struct
ITA_SIMULATION_SCHEDULER_API
WorkerConfig
:
public
IConfig
...
...
@@ -56,7 +57,9 @@ namespace ITA
WorkerConfig
&
operator
=
(
const
WorkerConfig
&
other
);
const
std
::
string
&
sWorkerType
;
const
std
::
string
&
sType
;
ISchedulerInterface
*
pParent
;
VistaPropertyList
Store
(
)
const
override
=
0
;
...
...
@@ -67,9 +70,9 @@ namespace ITA
///
/// \brief Constructor for IWorkerInterface.
/// \param
pParent the parent scheduler
of the worker.
/// \param
oConfig the config
of the worker.
///
IWorkerInterface
(
ISchedulerInterface
*
pParent
);
IWorkerInterface
(
const
WorkerConfig
&
oConfig
);
virtual
~
IWorkerInterface
(
)
=
default
;
...
...
@@ -108,7 +111,11 @@ namespace ITA
ISchedulerInterface
*
m_pParentScheduler
=
nullptr
;
};
ENABLE_FACTORY
(
IWorkerInterface
::
WorkerConfig
);
typedef
CFactory
<
IWorkerInterface
,
IWorkerInterface
::
WorkerConfig
>
ITA_SIMULATION_SCHEDULER_API
CWorkerFactory
;
/*
///
/// \brief Factory class for Worker.
///
...
...
@@ -163,7 +170,7 @@ namespace ITA
/// \brief Map containing all creation functions.
///
static std::map < std::string, std::pair<CreateCallback, ConfigCreateCallback> > m_mWorkers;
};
};
*/
}
// namespace SimulationScheduler
}
// namespace ITA
...
...
src/ITA/SimulationScheduler/AudibilityFilter/audibility_filter_interface.cpp
View file @
49dc7f0d
...
...
@@ -21,29 +21,12 @@ namespace ITA
{
namespace
AudibilityFilter
{
std
::
map
<
std
::
string
,
std
::
pair
<
CAudibilityFilterFactory
::
CreateCallback
,
CAudibilityFilterFactory
::
ConfigCreateCallback
>>
CAudibilityFilterFactory
::
m_mFilters
=
{
{
CRateFilter
::
GetType
(
),
{
CRateFilter
::
CreateFilter
,
std
::
make_shared
<
CRateFilter
::
RateFilterConfig
>
}
},
{
CReverberationRadiusFilter
::
GetType
(
),
{
CReverberationRadiusFilter
::
CreateFilter
,
std
::
make_shared
<
CReverberationRadiusFilter
::
ReverberationRadiusFilterConfig
>
}
},
{
CRotationFilter
::
GetType
(
),
{
CRotationFilter
::
CreateFilter
,
std
::
make_shared
<
CRotationFilter
::
RotationFilterConfig
>
}
},
{
CTranslationFilter
::
GetType
(
),
{
CTranslationFilter
::
CreateFilter
,
std
::
make_shared
<
CTranslationFilter
::
TranslationFilterConfig
>
}
},
{
CZoneFilter
::
GetType
(
),
{
CZoneFilter
::
CreateFilter
,
std
::
make_shared
<
CZoneFilter
::
ZoneFilterConfig
>
}
},
{
CPerceptiveRotationFilter
::
GetType
(
),
{
CPerceptiveRotationFilter
::
CreateFilter
,
std
::
make_shared
<
CPerceptiveRotationFilter
::
PerceptiveRotationFilterConfig
>
}
}
};
IAudibilityFilter
::
AudibilityFilterConfig
::
AudibilityFilterConfig
(
)
:
sFilterType
(
m_sFilterType
)
IAudibilityFilter
::
AudibilityFilterConfig
::
AudibilityFilterConfig
(
)
:
sType
(
m_sFilterType
)
{
m_sFilterType
=
"Unknown"
;
}
IAudibilityFilter
::
AudibilityFilterConfig
::
AudibilityFilterConfig
(
std
::
string
sType
)
:
s
Filter
Type
(
m_sFilterType
)
IAudibilityFilter
::
AudibilityFilterConfig
::
AudibilityFilterConfig
(
std
::
string
sType
)
:
sType
(
m_sFilterType
)
{
m_sFilterType
=
sType
;
}
...
...
@@ -51,7 +34,7 @@ namespace ITA
IAudibilityFilter
::
AudibilityFilterConfig
::
AudibilityFilterConfig
(
const
AudibilityFilterConfig
&
other
)
:
IConfig
(
other
),
sFilterName
(
other
.
sFilterName
),
s
Filter
Type
(
m_sFilterType
),
sType
(
m_sFilterType
),
sNextFilter
(
other
.
sNextFilter
),
eUsageMode
(
other
.
eUsageMode
),
bInvertCondition
(
other
.
bInvertCondition
),
...
...
@@ -97,7 +80,7 @@ namespace ITA
if
(
previousState
.
GetTimeStamp
(
)
>
newUpdate
.
GetTimeStamp
(
)
)
ITA_EXCEPT_INVALID_PARAMETER
(
"The previous state happend before the new update"
);
}
/*
void CAudibilityFilterFactory::RegisterFilter ( const std::string& type, CreateCallback createFunction, ConfigCreateCallback configCreateFunction )
{
m_mFilters [type] = { createFunction, configCreateFunction };
...
...
@@ -110,7 +93,7 @@ namespace ITA
std::unique_ptr<IAudibilityFilter> CAudibilityFilterFactory::CreateFilter ( const std::shared_ptr<IAudibilityFilter::AudibilityFilterConfig>& pConfig )
{
auto
it
=
m_mFilters
.
find
(
pConfig
->
s
Filter
Type
);
auto it = m_mFilters.find ( pConfig->sType );
if ( it != m_mFilters.end ( ) )
{
// call the creation callback to construct this derived type
...
...
@@ -129,7 +112,24 @@ namespace ITA
return it->second.second ( );
}
return nullptr;
}
}
*/
}
// namespace AudibilityFilter
CFactory
<
AudibilityFilter
::
IAudibilityFilter
,
AudibilityFilter
::
IAudibilityFilter
::
AudibilityFilterConfig
>::
FactoryFunctionMap_t
CFactory
<
AudibilityFilter
::
IAudibilityFilter
,
AudibilityFilter
::
IAudibilityFilter
::
AudibilityFilterConfig
>::
m_mFactoryFunctions
=
{
{
AudibilityFilter
::
CRateFilter
::
GetType
(
),
{
AudibilityFilter
::
CRateFilter
::
CreateFilter
,
std
::
make_shared
<
AudibilityFilter
::
CRateFilter
::
RateFilterConfig
>
}
},
{
AudibilityFilter
::
CReverberationRadiusFilter
::
GetType
(
),
{
AudibilityFilter
::
CReverberationRadiusFilter
::
CreateFilter
,
std
::
make_shared
<
AudibilityFilter
::
CReverberationRadiusFilter
::
ReverberationRadiusFilterConfig
>
}
},
{
AudibilityFilter
::
CRotationFilter
::
GetType
(
),
{
AudibilityFilter
::
CRotationFilter
::
CreateFilter
,
std
::
make_shared
<
AudibilityFilter
::
CRotationFilter
::
RotationFilterConfig
>
}
},
{
AudibilityFilter
::
CTranslationFilter
::
GetType
(
),
{
AudibilityFilter
::
CTranslationFilter
::
CreateFilter
,
std
::
make_shared
<
AudibilityFilter
::
CTranslationFilter
::
TranslationFilterConfig
>
}
},
{
AudibilityFilter
::
CZoneFilter
::
GetType
(
),
{
AudibilityFilter
::
CZoneFilter
::
CreateFilter
,
std
::
make_shared
<
AudibilityFilter
::
CZoneFilter
::
ZoneFilterConfig
>
}
},
{
AudibilityFilter
::
CPerceptiveRotationFilter
::
GetType
(
),
{
AudibilityFilter
::
CPerceptiveRotationFilter
::
CreateFilter
,
std
::
make_shared
<
AudibilityFilter
::
CPerceptiveRotationFilter
::
PerceptiveRotationFilterConfig
>
}
}
};
}
// namespace SimulationScheduler
}
// namespace ITA
src/ITA/SimulationScheduler/AudibilityFilter/filter_network.cpp
View file @
49dc7f0d
...
...
@@ -129,7 +129,7 @@ namespace ITA
if
(
m_mAudibilityFilters
.
find
(
filterConfig
->
sFilterName
)
!=
m_mAudibilityFilters
.
end
(
)
)
ITA_EXCEPT_INVALID_PARAMETER
(
"Filter name already exist in network"
);
m_mAudibilityFilters
.
insert
(
{
filterConfig
->
sFilterName
,
CAudibilityFilterFactory
::
Create
Filter
(
filterConfig
)
}
);
m_mAudibilityFilters
.
insert
(
{
filterConfig
->
sFilterName
,
CAudibilityFilterFactory
::
Create
Object
(
filterConfig
)
}
);
}
}
...
...
src/ITA/SimulationScheduler/OutdoorAcoustics/outdoor_worker_thread.cpp
View file @
49dc7f0d
...
...
@@ -52,8 +52,8 @@ namespace ITA
oProperties
.
GetValue
(
SIMULATOR_TYPE_KEY
,
m_sSimulatorType
);
}
CWorkerThread
::
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
,
ISchedulerInterface
*
pParent
)
:
IWorkerInterface
(
pParent
),
m_evTriggerLoop
(
VistaThreadEvent
::
NON_WAITABLE_EVENT
)
CWorkerThread
::
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
)
:
IWorkerInterface
(
oConfig
),
m_evTriggerLoop
(
VistaThreadEvent
::
NON_WAITABLE_EVENT
)
{
//oConfig;
//m_oSimulator = std::make_unique<CSimulator> ( m_eFieldOfDuty, oConfig.sRavenProjectFilePath );
...
...
@@ -123,9 +123,9 @@ namespace ITA
}
std
::
unique_ptr
<
IWorkerInterface
>
CWorkerThread
::
CreateWorker
(
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
,
ISchedulerInterface
*
pParent
)
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
)
{
return
std
::
make_unique
<
CWorkerThread
>
(
dynamic_cast
<
const
WorkerThreadConfig
&>
(
*
pConfig
)
,
pParent
);
return
std
::
make_unique
<
CWorkerThread
>
(
dynamic_cast
<
const
WorkerThreadConfig
&>
(
*
pConfig
));
}
//void CWorkerThread::SetSimulator ( std::unique_ptr<ISimulatorInterface> pSimulator )
...
...
src/ITA/SimulationScheduler/RoomAcoustics/Raven/raven_worker_interface.cpp
View file @
49dc7f0d
...
...
@@ -36,9 +36,8 @@ namespace ITA
RoomAcousticsWorkerInterfaceConfig
::
Load
(
oProperties
);
}
IRavenWorkerInterface
::
IRavenWorkerInterface
(
const
RavenWorkerConfig
&
oConfig
,
ISchedulerInterface
*
pParent
)
:
IRoomAcousticsWorkerInterface
(
oConfig
,
pParent
)
IRavenWorkerInterface
::
IRavenWorkerInterface
(
const
RavenWorkerConfig
&
oConfig
)
:
IRoomAcousticsWorkerInterface
(
oConfig
)
{
}
IRavenWorkerInterface
::~
IRavenWorkerInterface
(
)
...
...
src/ITA/SimulationScheduler/RoomAcoustics/Raven/worker_thread.cpp
View file @
49dc7f0d
...
...
@@ -46,8 +46,8 @@ namespace ITA
oProperties
.
GetValue
(
ravenProjectFilePathKey
,
sRavenProjectFilePath
);
}
CWorkerThread
::
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
,
ISchedulerInterface
*
pParent
)
:
IRavenWorkerInterface
(
oConfig
,
pParent
),
m_evTriggerLoop
(
VistaThreadEvent
::
NON_WAITABLE_EVENT
)
CWorkerThread
::
CWorkerThread
(
const
WorkerThreadConfig
&
oConfig
)
:
IRavenWorkerInterface
(
oConfig
),
m_evTriggerLoop
(
VistaThreadEvent
::
NON_WAITABLE_EVENT
)
{
m_pSimulator
=
std
::
make_unique
<
CSimulator
>
(
m_eFieldOfDuty
,
oConfig
.
sRavenProjectFilePath
);
...
...
@@ -128,9 +128,9 @@ namespace ITA
}
std
::
unique_ptr
<
IWorkerInterface
>
CWorkerThread
::
CreateWorker
(
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
,
ISchedulerInterface
*
pParent
)
const
std
::
shared_ptr
<
IWorkerInterface
::
WorkerConfig
>&
pConfig
)
{
return
std
::
make_unique
<
CWorkerThread
>
(
dynamic_cast
<
const
WorkerThreadConfig
&
>
(
*
pConfig
)
,
pParent
);
return
std
::
make_unique
<
CWorkerThread
>
(
dynamic_cast
<
const
WorkerThreadConfig
&
>
(
*
pConfig
)
);
}
std
::
string
CWorkerThread
::
GetType
(
)
...
...
src/ITA/SimulationScheduler/RoomAcoustics/room_acoustics_worker_interface.cpp
View file @
49dc7f0d
...
...
@@ -32,7 +32,7 @@ namespace ITA
}
IRoomAcousticsWorkerInterface
::
IRoomAcousticsWorkerInterface
(
const
RoomAcousticsWorkerInterfaceConfig
&
oConfig
,
ISchedulerInterface
*
pParent
)
:
IWorkerInterface
(
pParent
)
const
RoomAcousticsWorkerInterfaceConfig
&
oConfig
)
:
IWorkerInterface
(
oConfig
)
{
m_eFieldOfDuty
=
oConfig
.
eFOD
;
}
...
...
src/ITA/SimulationScheduler/scheduler.cpp
View file @
49dc7f0d
...
...
@@ -76,7 +76,8 @@ namespace ITA
for
(
const
auto
&
workerConfig
:
pConfig
.
vpWorkerConfigs
)
{
m_vWorker
.
push_back
(
std
::
move
(
CWorkerFactory
::
CreateWorker
(
workerConfig
,
this
)
)
);
workerConfig
->
pParent
=
this
;
m_vWorker
.
push_back
(
std
::
move
(
CWorkerFactory
::
CreateObject
(
workerConfig
)
)
);
}
m_pFilterNetwork
=
std
::
make_unique
<
AudibilityFilter
::
CFilterNetwork
>
(
pConfig
.
oFilterNetworkConfig
);
...
...
src/ITA/SimulationScheduler/worker_interface.cpp
View file @
49dc7f0d
...
...
@@ -15,7 +15,7 @@ namespace ITA
namespace
SimulationScheduler
{
// todo This can fail if the name changes .. Fix this/make it bullet proof
std
::
map
<
std
::
string
,
std
::
pair
<
CWorkerFactory
::
CreateCallback
,
CWorkerFactory
::
ConfigCreateCallback
>>
CWorkerFactory
::
m_mWorker
s
=
CFactory
<
IWorkerInterface
,
IWorkerInterface
::
WorkerConfig
>::
FactoryFunctionMap_t
CFactory
<
IWorkerInterface
,
IWorkerInterface
::
WorkerConfig
>::
m_mFactoryFunction
s
=
{
#ifdef WITH_RAVEN
{
RoomAcoustics
::
Raven
::
CWorkerThread
::
GetType
(),
{
RoomAcoustics
::
Raven
::
CWorkerThread
::
CreateWorker
,
std
::
make_shared
<
RoomAcoustics
::
Raven
::
CWorkerThread
::
WorkerThreadConfig
>
}
},
...
...
@@ -23,19 +23,19 @@ namespace ITA
{
OutdoorAcoustics
::
CWorkerThread
::
GetType
(),
{
OutdoorAcoustics
::
CWorkerThread
::
CreateWorker
,
std
::
make_shared
<
OutdoorAcoustics
::
CWorkerThread
::
WorkerThreadConfig
>
}
},
};
IWorkerInterface
::
WorkerConfig
::
WorkerConfig
(
)
:
s
Worker
Type
(
m_sWorkerType
)
IWorkerInterface
::
WorkerConfig
::
WorkerConfig
(
)
:
sType
(
m_sWorkerType
)
{
m_sWorkerType
=
"Unknown"
;
}
IWorkerInterface
::
WorkerConfig
::
WorkerConfig
(
std
::
string
sType
)
:
s
Worker
Type
(
m_sWorkerType
)
IWorkerInterface
::
WorkerConfig
::
WorkerConfig
(
std
::
string
sType
)
:
sType
(
m_sWorkerType
)
{
m_sWorkerType
=
sType
;
}
IWorkerInterface
::
WorkerConfig
::
WorkerConfig
(
const
WorkerConfig
&
other
)
:
IConfig
(
other
),
s
Worker
Type
(
m_sWorkerType
),
sType
(
m_sWorkerType
),
m_sWorkerType
(
other
.
m_sWorkerType
)
{
}
...
...
@@ -60,11 +60,11 @@ namespace ITA
oProperties
.
GetValue
<
std
::
string
>
(
workerTypeKey
,
m_sWorkerType
);
}
IWorkerInterface
::
IWorkerInterface
(
ISchedulerInterface
*
pParent
)
:
m_pParentScheduler
(
pParent
)
IWorkerInterface
::
IWorkerInterface
(
const
WorkerConfig
&
oConfig
)
:
m_pParentScheduler
(
oConfig
.
pParent
)
{
}
void
CWorkerFactory
::
RegisterWorker
(
const
std
::
string
&
type
,
CreateCallback
createFunction
,
ConfigCreateCallback
configCreateFunction
)
/*
void CWorkerFactory::RegisterWorker ( const std::string& type, CreateCallback createFunction, ConfigCreateCallback configCreateFunction )
{
m_mWorkers [type] = { createFunction, configCreateFunction };
}
...
...
@@ -76,7 +76,7 @@ namespace ITA
std::unique_ptr<IWorkerInterface> CWorkerFactory::CreateWorker ( const std::shared_ptr<IWorkerInterface::WorkerConfig>& pConfig, ISchedulerInterface* pParent )
{
auto
it
=
m_mWorkers
.
find
(
pConfig
->
s
Worker
Type
);
auto it = m_mWorkers.find ( pConfig->sType );
if ( it != m_mWorkers.end ( ) )
{
// call the creation callback to construct this derived type
...
...
@@ -94,6 +94,6 @@ namespace ITA
return it->second.second ( );
}
return nullptr;
}
}
*/
}
// namespace SimulationScheduler
}
// namespace ITA
tests/all_tests/audibility_filter_interface_test.cpp
View file @
49dc7f0d
...
...
@@ -10,23 +10,25 @@
using
namespace
ITA
::
SimulationScheduler
;
using
namespace
AudibilityFilter
;
//template class CFactory<IAudibilityFilter, IAudibilityFilter::AudibilityFilterConfig>;
TEST
(
FilterFactoryTest
,
addNewFilterType
)
{
CAudibilityFilterFactory
::
Register
Filter
(
"MockFilter"
,
CAudibilityFilterFactory
::
Register
Object
(
"MockFilter"
,
MockAudibilityFilter
::
createFilter
,
std
::
make_shared
<
MockAudibilityFilter
::
MockFilterConfig
>
);
auto
filterConfig
=
std
::
make_shared
<
MockAudibilityFilter
::
MockFilterConfig
>
(
);
filterConfig
->
behaviour
=
MockAudibilityFilter
::
Behaviour
::
nothingAudible
;
const
auto
filter
=
CAudibilityFilterFactory
::
Create
Filter
(
filterConfig
);
const
auto
filter
=
CAudibilityFilterFactory
::
Create
Object
(
filterConfig
);
ASSERT_NE
(
filter
,
nullptr
);
}
TEST
(
FilterFactoryTest
,
configFactoryTest
)
{
CAudibilityFilterFactory
::
Register
Filter
(
"MockFilter"
,
CAudibilityFilterFactory
::
Register
Object
(
"MockFilter"
,
MockAudibilityFilter
::
createFilter
,
std
::
make_shared
<
MockAudibilityFilter
::
MockFilterConfig
>
);
...
...
tests/all_tests/complete_test.cpp
View file @
49dc7f0d
...
...
@@ -52,7 +52,7 @@ struct CompleteTest : public testing::Test, public ITATimerEventHandler
schedulerConfig
->
vpWorkerConfigs
.
push_back
(
workerConfig
);
CAudibilityFilterFactory
::
Register
Filter
(
"MockFilter"
,
CAudibilityFilterFactory
::
Register
Object
(
"MockFilter"
,
MockAudibilityFilter
::
createFilter
,
std
::
make_shared
<
MockAudibilityFilter
::
MockFilterConfig
>
);
...
...
tests/all_tests/filter_network_test.cpp
View file @
49dc7f0d
...
...
@@ -51,7 +51,7 @@ struct FilterNetworkTest : public testing::TestWithParam<FilterNetworkTestParam>
{
const
auto
param
=
GetParam
(
);
CAudibilityFilterFactory
::
Register
Filter
(
"MockFilter"
,
CAudibilityFilterFactory
::
Register
Object
(
"MockFilter"
,
MockAudibilityFilter
::
createFilter
,
std
::
make_shared
<
MockAudibilityFilter
::
MockFilterConfig
>
);
...
...
tests/all_tests/local_scheduler_test.cpp
View file @
49dc7f0d
...
...
@@ -41,10 +41,10 @@ struct LocalSchedulerTest : public testing::Test
LocalSchedulerTest
(
)
{