1 /* Copyright (c) 2016-2020. 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. */
7 #include <simgrid/s4u/Engine.hpp>
8 #include <simgrid/s4u/NetZone.hpp>
9 #include <simgrid/simix.hpp>
11 #include <unordered_map>
17 std::map<std::string, s4u::Host*> hosts_;
18 std::map<std::string, resource::LinkImpl*> links_;
19 std::map<std::string, resource::StorageImpl*> storages_;
20 std::unordered_map<std::string, routing::NetPoint*> netpoints_;
21 std::unordered_map<std::string, actor::ActorCodeFactory> registered_functions; // Maps function names to actor code
22 actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing
27 EngineImpl() = default;
29 EngineImpl(const EngineImpl&) = delete;
30 EngineImpl& operator=(const EngineImpl&) = delete;
31 virtual ~EngineImpl();
33 void load_deployment(const std::string& file);
34 void register_function(const std::string& name, const actor::ActorCodeFactory& code);
35 void register_default(const actor::ActorCodeFactory& code);
37 routing::NetZoneImpl* netzone_root_ = nullptr;
38 static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
39 actor::ActorCodeFactory get_function(const std::string& name)
41 auto res = registered_functions.find(name);
42 if (res == registered_functions.end())
43 return default_function;
50 } // namespace simgrid