friend simgrid::kernel::EngineImpl;
public:
+ /** Constructor, taking only the name of your main function */
+ explicit Engine(std::string name);
/** Constructor, taking the command line parameters of your main function */
explicit Engine(int* argc, char** argv);
/* Currently, only one instance is allowed to exist. This is why you can't copy or move it */
private:
kernel::EngineImpl* const pimpl;
static Engine* instance_;
+ void initialize(int* argc, char** argv);
};
#ifndef DOXYGEN /* Internal use only, no need to expose it */
Engine* Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
-Engine::Engine(int* argc, char** argv) : pimpl(new kernel::EngineImpl())
+void Engine::initialize(int* argc, char** argv)
{
xbt_assert(Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
instr::init();
SIMIX_global_init(argc, argv);
-
Engine::instance_ = this;
}
+Engine::Engine(std::string name) : pimpl(new kernel::EngineImpl())
+{
+ int argc = 1;
+ char* argv = &name[0];
+ initialize(&argc, &argv);
+}
+
+Engine::Engine(int* argc, char** argv) : pimpl(new kernel::EngineImpl())
+{
+ initialize(argc, argv);
+}
+
Engine::~Engine()
{
delete pimpl;