static createEngine() added to work around virtual constructor problems
parent
f46fd11416
commit
a7ccec254d
|
@ -18,10 +18,18 @@
|
|||
#include "engine.h"
|
||||
#include "tools/array_ops.h"
|
||||
|
||||
//! \brief construct an Engine instance
|
||||
//! it's the responsibility of the caller to free the returned pointer
|
||||
Engine* Engine::createEngine(Operator* op)
|
||||
{
|
||||
Engine* e = new Engine(op);
|
||||
e->Init();
|
||||
return e;
|
||||
}
|
||||
|
||||
Engine::Engine(Operator* op)
|
||||
{
|
||||
Op = op;
|
||||
Init();
|
||||
}
|
||||
|
||||
Engine::~Engine()
|
||||
|
|
|
@ -28,7 +28,7 @@ class Engine
|
|||
friend class ProcessFields;
|
||||
friend class ProcessFieldsTD;
|
||||
public:
|
||||
Engine(Operator* op);
|
||||
static Engine* createEngine(Operator* op);
|
||||
virtual ~Engine();
|
||||
|
||||
virtual void Init();
|
||||
|
@ -40,6 +40,7 @@ public:
|
|||
unsigned int GetNumberOfTimesteps() {return numTS;};
|
||||
|
||||
protected:
|
||||
Engine(Operator* op);
|
||||
Operator* Op;
|
||||
|
||||
FDTD_FLOAT**** volt;
|
||||
|
|
|
@ -18,6 +18,15 @@
|
|||
#include "engine_multithread.h"
|
||||
#include "tools/array_ops.h"
|
||||
|
||||
//! \brief construct an Engine_Multithread instance
|
||||
//! it's the responsibility of the caller to free the returned pointer
|
||||
Engine_Multithread* Engine_Multithread::createEngine(Operator* op)
|
||||
{
|
||||
Engine_Multithread* e = new Engine_Multithread(op);
|
||||
e->Init();
|
||||
return e;
|
||||
}
|
||||
|
||||
Engine_Multithread::Engine_Multithread(Operator* op) : Engine(op)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ class Engine_Multithread : public Engine
|
|||
friend class ProcessFields;
|
||||
friend class ProcessFieldsTD;
|
||||
public:
|
||||
Engine_Multithread(Operator* op);
|
||||
virtual ~Engine_Multithread();
|
||||
static Engine_Multithread* createEngine(Operator* op);
|
||||
virtual ~Engine_Multithread();
|
||||
|
||||
virtual void Init();
|
||||
virtual void Reset();
|
||||
|
@ -40,6 +40,7 @@ public:
|
|||
|
||||
|
||||
protected:
|
||||
Engine_Multithread(Operator* op);
|
||||
};
|
||||
|
||||
#endif // ENGINE_MULTITHREAD_H
|
||||
|
|
|
@ -226,10 +226,10 @@ int openEMS::SetupFDTD(const char* file)
|
|||
//create FDTD engine
|
||||
switch (m_engine) {
|
||||
case EngineType_Multithreaded:
|
||||
FDTD_Eng = new Engine_Multithread(FDTD_Op);
|
||||
FDTD_Eng = Engine_Multithread::createEngine(FDTD_Op);
|
||||
break;
|
||||
default:
|
||||
FDTD_Eng = new Engine(FDTD_Op);
|
||||
FDTD_Eng = Engine::createEngine(FDTD_Op);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue