1 /* s4u::Engine Simulation Engine and global functions. */
3 /* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "simgrid/simix.h"
10 #include "simgrid/s4u/engine.hpp"
12 XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
13 using namespace simgrid;
15 s4u::Engine *s4u::Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
18 s4u::Engine::Engine(int *argc, char **argv) {
19 xbt_assert(s4u::Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
20 s4u::Engine::instance_ = this;
22 SIMIX_global_init(argc, argv);
25 s4u::Engine *s4u::Engine::instance() {
26 if (s4u::Engine::instance_ == nullptr)
27 new Engine(0,nullptr);
28 return s4u::Engine::instance_;
31 double s4u::Engine::getClock() {
32 return SIMIX_get_clock();
35 void s4u::Engine::loadPlatform(const char *platf) {
36 SIMIX_create_environment(platf);
39 void s4u::Engine::registerFunction(const char*name, int (*code)(int,char**)) {
40 SIMIX_function_register(name,code);
42 void s4u::Engine::registerDefault(int (*code)(int,char**)) {
43 SIMIX_function_register_default(code);
45 void s4u::Engine::loadDeployment(const char *deploy) {
46 SIMIX_launch_application(deploy);
49 void s4u::Engine::run() {