1 /* Copyright (c) 2016-2021. 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_KERNEL_ENGINEIMPL_HPP
7 #define SIMGRID_KERNEL_ENGINEIMPL_HPP
9 #include <simgrid/s4u/Engine.hpp>
10 #include <simgrid/s4u/NetZone.hpp>
11 #include <simgrid/simix.hpp>
15 #include <unordered_map>
21 std::map<std::string, s4u::Host*, std::less<>> hosts_;
22 std::map<std::string, resource::LinkImpl*, std::less<>> links_;
23 std::unordered_map<std::string, routing::NetPoint*> netpoints_;
24 std::unordered_map<std::string, actor::ActorCodeFactory> registered_functions; // Maps function names to actor code
25 actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing
30 EngineImpl() = default;
32 EngineImpl(const EngineImpl&) = delete;
33 EngineImpl& operator=(const EngineImpl&) = delete;
34 virtual ~EngineImpl();
36 void load_deployment(const std::string& file) const;
37 void register_function(const std::string& name, const actor::ActorCodeFactory& code);
38 void register_default(const actor::ActorCodeFactory& code);
40 routing::NetZoneImpl* netzone_root_ = nullptr;
41 static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
42 actor::ActorCodeFactory get_function(const std::string& name)
44 auto res = registered_functions.find(name);
45 if (res == registered_functions.end())
46 return default_function;
53 } // namespace simgrid