Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add preliminary tests for Configuration
[simgrid.git] / src / mc / explo / udpor / Configuration.cpp
1 /* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "src/mc/explo/udpor/Configuration.hpp"
7 #include "src/mc/explo/udpor/History.hpp"
8
9 #include <algorithm>
10 #include <stdexcept>
11
12 namespace simgrid::mc::udpor {
13
14 Configuration::Configuration(std::initializer_list<UnfoldingEvent*> events) : Configuration(EventSet(std::move(events)))
15 {
16 }
17
18 Configuration::Configuration(EventSet events) : events_(events)
19 {
20   if (!events_.is_valid_configuration()) {
21     throw std::invalid_argument("The events do not form a valid configuration");
22   }
23 }
24
25 void Configuration::add_event(UnfoldingEvent* e)
26 {
27   this->events_.insert(e);
28   this->newest_event = e;
29
30   // Preserves the property that the configuration is valid
31   History history(e);
32   if (!this->events_.contains(history)) {
33     throw std::invalid_argument("The newly added event has dependencies "
34                                 "which are missing from this configuration");
35   }
36 }
37
38 } // namespace simgrid::mc::udpor