#include "src/surf/network_interface.hpp"
#include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
#include "src/surf/network_interface.hpp"
#include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
- return pimpl->hosts_.at(name); // Will raise a std::out_of_range if the host does not exist
+ if (pimpl->hosts_.find(name) == pimpl->hosts_.end())
+ throw std::invalid_argument(std::string("Host not found: '") + name + std::string("'"));
+ return pimpl->hosts_.at(name);
simgrid::s4u::Host* Engine::host_by_name_or_null(std::string name)
{
auto host = pimpl->hosts_.find(name);
return host == pimpl->hosts_.end() ? nullptr : host->second;
}
simgrid::s4u::Host* Engine::host_by_name_or_null(std::string name)
{
auto host = pimpl->hosts_.find(name);
return host == pimpl->hosts_.end() ? nullptr : host->second;
}
- return pimpl->links_.at(name); // Will raise a std::out_of_range if the host does not exist
+ if (pimpl->links_.find(name) == pimpl->links_.end())
+ throw std::invalid_argument(std::string("Link not found: ") + name);
+
+ return pimpl->links_.at(name);
simgrid::s4u::Link* Engine::link_by_name_or_null(std::string name)
{
auto link = pimpl->links_.find(name);
simgrid::s4u::Link* Engine::link_by_name_or_null(std::string name)
{
auto link = pimpl->links_.find(name);
- return pimpl->storages_.at(name); // Will raise a std::out_of_range if the host does not exist
+ if (pimpl->storages_.find(name) == pimpl->storages_.end())
+ throw std::invalid_argument(std::string("Storage not found: ") + name);
+
+ return pimpl->storages_.at(name);
simgrid::s4u::Storage* Engine::storage_by_name_or_null(std::string name)
{
auto storage = pimpl->storages_.find(name);
simgrid::s4u::Storage* Engine::storage_by_name_or_null(std::string name)
{
auto storage = pimpl->storages_.find(name);
/** @brief Retrieve the root netzone, containing all others */
s4u::NetZone* Engine::get_netzone_root()
{
/** @brief Retrieve the root netzone, containing all others */
s4u::NetZone* Engine::get_netzone_root()
{
}
/** @brief Set the root netzone, containing all others. Once set, it cannot be changed. */
void Engine::set_netzone_root(s4u::NetZone* netzone)
{
xbt_assert(pimpl->netzone_root_ == nullptr, "The root NetZone cannot be changed once set");
}
/** @brief Set the root netzone, containing all others. Once set, it cannot be changed. */
void Engine::set_netzone_root(s4u::NetZone* netzone)
{
xbt_assert(pimpl->netzone_root_ == nullptr, "The root NetZone cannot be changed once set");
-void sg_engine_load_platform(const char* file)
+void simgrid_init(int* argc, char** argv)
+{
+ simgrid::s4u::Engine e(argc, argv);
+}
+void simgrid_load_platform(const char* file)
-
-void sg_engine_register_function(const char* name, int (*code)(int, char**))
+void simgrid_run()
+{
+ simgrid::s4u::Engine::get_instance()->run();
+}
+void simgrid_register_function(const char* name, int (*code)(int, char**))