|
@@ -30,9 +30,11 @@
|
|
|
|
|
|
#include <boost/core/demangle.hpp>
|
|
|
|
|
|
+#include <artis/kernel/AbstractModel.hpp>
|
|
|
+
|
|
|
namespace artis { namespace builder {
|
|
|
|
|
|
-template < typename M >
|
|
|
+template < typename M, typename U, typename V >
|
|
|
class ObjectCreator
|
|
|
{
|
|
|
public:
|
|
@@ -43,13 +45,14 @@ public:
|
|
|
|
|
|
virtual std::string get() const = 0;
|
|
|
|
|
|
- virtual M* operator()() const = 0;
|
|
|
+ virtual M* operator()(artis::kernel::AbstractModels < U,
|
|
|
+ V > submodels) const = 0;
|
|
|
};
|
|
|
|
|
|
-template < typename M, typename I, typename O >
|
|
|
+template < typename M, typename I, typename O, typename U, typename V >
|
|
|
class ModelFactory
|
|
|
{
|
|
|
- typedef ModelFactory < M, I, O > type;
|
|
|
+ typedef ModelFactory < M, I, O, U, V > type;
|
|
|
|
|
|
public:
|
|
|
virtual ~ModelFactory()
|
|
@@ -63,13 +66,14 @@ public:
|
|
|
std::make_pair(id, creator))).second;
|
|
|
}
|
|
|
|
|
|
- M* create(const std::string& id)
|
|
|
+ M* create(const std::string& id, artis::kernel::AbstractModels < U,
|
|
|
+ V > submodels)
|
|
|
{
|
|
|
std::lock_guard < std::mutex > lock(_mutex);
|
|
|
typename Creators::const_iterator it = creators.find(id);
|
|
|
|
|
|
if (it != creators.end()) {
|
|
|
- return (*it->second.second)();
|
|
|
+ return (*it->second.second)(submodels);
|
|
|
} else {
|
|
|
return nullptr;
|
|
|
}
|
|
@@ -118,15 +122,15 @@ private:
|
|
|
|
|
|
} }
|
|
|
|
|
|
-template < typename M, typename I, typename O >
|
|
|
-std::shared_ptr < artis::builder::ModelFactory < M, I, O > >
|
|
|
-artis::builder::ModelFactory < M, I, O >::_instance;
|
|
|
+template < typename M, typename I, typename O, typename U, typename V >
|
|
|
+std::shared_ptr < artis::builder::ModelFactory < M, I, O, U, V > >
|
|
|
+artis::builder::ModelFactory < M, I, O, U, V >::_instance;
|
|
|
|
|
|
-template < typename M, typename I, typename O >
|
|
|
-std::once_flag artis::builder::ModelFactory < M, I, O >::_flag;
|
|
|
+template < typename M, typename I, typename O, typename U, typename V >
|
|
|
+std::once_flag artis::builder::ModelFactory < M, I, O, U, V >::_flag;
|
|
|
|
|
|
-#define DECLARE_MODEL(mdl, type, fct) \
|
|
|
- class creator_##mdl : public artis::builder::ObjectCreator < type > { \
|
|
|
+#define DECLARE_MODEL(mdl, type, fct, U, V ) \
|
|
|
+ class creator_##mdl : public artis::builder::ObjectCreator < type, U, V > { \
|
|
|
public: \
|
|
|
creator_##mdl() \
|
|
|
{ \
|
|
@@ -134,8 +138,8 @@ std::once_flag artis::builder::ModelFactory < M, I, O >::_flag;
|
|
|
} \
|
|
|
std::string get() const \
|
|
|
{ return boost::core::demangle(typeid(mdl).name()); } \
|
|
|
- type* operator()() const \
|
|
|
- { return new mdl(); } \
|
|
|
+ type* operator()(artis::kernel::AbstractModels < U, V > submodels) const \
|
|
|
+ { return new mdl(submodels); } \
|
|
|
static creator_##mdl an_##mdl; \
|
|
|
}; \
|
|
|
creator_##mdl an_##mdl;
|