1 /* Copyright (c) 2008-2023. 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 #include "src/mc/explo/udpor/Unfolding.hpp"
10 namespace simgrid::mc::udpor {
12 void Unfolding::remove(UnfoldingEvent* e)
15 throw std::invalid_argument("Expected a non-null pointer to an event, but received NULL");
17 this->global_events_.erase(e);
20 void Unfolding::insert(std::unique_ptr<UnfoldingEvent> e)
22 UnfoldingEvent* handle = e.get();
23 auto loc = this->global_events_.find(handle);
24 if (loc != this->global_events_.end()) {
25 // This is bad: someone wrapped the raw event address twice
26 // in two different unique ptrs and attempted to
27 // insert it into the unfolding...
28 throw std::invalid_argument("Attempted to insert an unfolding event owned twice."
29 "This will result in a double free error and must be fixed.");
32 // Map the handle to its owner
33 this->global_events_[handle] = std::move(e);
36 } // namespace simgrid::mc::udpor