1 /* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_S4U_ENGINE_HPP
7 #define SIMGRID_S4U_ENGINE_HPP
11 #include <simgrid/s4u/forward.hpp>
15 /** @brief Simulation engine
17 * This class is an interface to the simulation engine.
19 XBT_PUBLIC_CLASS Engine {
21 /** Constructor, taking the command line parameters of your main function */
22 Engine(int *argc, char **argv);
24 /** Finalize the default engine and all its dependencies */
25 static void shutdown();
27 /** @brief Load a platform file describing the environment
29 * The environment is either a XML file following the simgrid.dtd formalism, or a lua file.
30 * Some examples can be found in the directory examples/platforms.
32 void loadPlatform(const char *platf);
34 /** Registers the main function of an actor that will be launched from the deployment file */
35 void registerFunction(const char*name, int (*code)(int,char**));
37 /** Registers a function as the default main function of actors
39 * It will be used as fallback when the function requested from the deployment file was not registered.
40 * It is used for trace-based simulations (see examples/msg/actions).
42 void registerDefault(int (*code)(int,char**));
44 /** @brief Load a deployment file and launch the actors that it contains */
45 void loadDeployment(const char *deploy);
47 /** @brief Run the simulation */
50 /** @brief Retrieve the simulation time */
51 static double getClock();
53 /** @brief Retrieve the engine singleton */
54 static s4u::Engine *instance();
56 /** @brief Retrieve the root AS, containing all others */
57 simgrid::s4u::As *rootAs();
58 /** @brief Retrieve the AS of the given name (or nullptr if not found) */
59 simgrid::s4u::As *asByNameOrNull(const char *name);
62 static s4u::Engine *instance_;
64 }} // namespace simgrid::s4u
66 #endif /* SIMGRID_S4U_ENGINE_HPP */