File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ project(LinSpire VERSION 0.2.0 LANGUAGES CXX)
44include (CTest )
55enable_testing ()
66
7- option (LINSPIRE_BUILD_LISTENERS "Enable listener functionality in LinSpire" OFF )
7+ option (LINSPIRE_ENABLE_LISTENERS "Enable listener functionality in LinSpire" OFF )
88
99add_library (LinSpire src/linspire.cpp src/var.cpp )
1010target_compile_features (LinSpire PUBLIC cxx_std_17 )
@@ -16,9 +16,9 @@ add_dependencies(LinSpire json)
1616target_link_libraries (LinSpire PUBLIC json )
1717setup_sanitizers (LinSpire )
1818
19- message (STATUS "Enable listener functionality in LinSpire: ${LINSPIRE_BUILD_LISTENERS } " )
20- if (LINSPIRE_BUILD_LISTENERS )
21- target_compile_definitions (LinSpire PUBLIC LINSPIRE_BUILD_LISTENERS )
19+ message (STATUS "Enable listener functionality in LinSpire: ${LINSPIRE_ENABLE_LISTENERS } " )
20+ if (LINSPIRE_ENABLE_LISTENERS )
21+ target_compile_definitions (LinSpire PUBLIC LINSPIRE_ENABLE_LISTENERS )
2222endif ()
2323
2424if (BUILD_TESTING)
Original file line number Diff line number Diff line change 66
77namespace linspire
88{
9- #ifdef LINSPIRE_BUILD_LISTENERS
9+ #ifdef LINSPIRE_ENABLE_LISTENERS
1010 class listener ;
1111#endif
1212
@@ -188,7 +188,7 @@ namespace linspire
188188 */
189189 [[nodiscard]] const std::vector<std::shared_ptr<const constraint>> &get_conflict () const noexcept { return cnfl; }
190190
191- #ifdef LINSPIRE_BUILD_LISTENERS
191+ #ifdef LINSPIRE_ENABLE_LISTENERS
192192 /* *
193193 * @brief Adds a listener to the solver.
194194 *
@@ -231,7 +231,7 @@ namespace linspire
231231 std::map<utils::var, utils::lin> tableau; // basic variable -> expression
232232 std::vector<std::set<utils::var>> t_watches; // for each variable `v`, a set of tableau rows watching `v`..
233233 std::vector<std::shared_ptr<const constraint>> cnfl; // the last conflict explanation..
234- #ifdef LINSPIRE_BUILD_LISTENERS
234+ #ifdef LINSPIRE_ENABLE_LISTENERS
235235 std::unordered_map<utils::var, std::set<listener *>> listening; // for each variable, the listeners listening to it..
236236 std::set<std::shared_ptr<listener>> listeners; // the collection of listeners..
237237#endif
@@ -245,7 +245,7 @@ namespace linspire
245245 std::map<utils::var, utils::inf_rational> lbs, ubs;
246246 };
247247
248- #ifdef LINSPIRE_BUILD_LISTENERS
248+ #ifdef LINSPIRE_ENABLE_LISTENERS
249249 class listener
250250 {
251251 public:
Original file line number Diff line number Diff line change 33#include < algorithm>
44#include < cassert>
55
6- #ifdef LINSPIRE_BUILD_LISTENERS
6+ #ifdef LINSPIRE_ENABLE_LISTENERS
77#define FIRE_ON_VALUE_CHANGED (var ) \
88 if (const auto &at_v = listening.find(var); at_v != listening.end()) \
99 for (auto &l : at_v->second) \
@@ -364,7 +364,7 @@ namespace linspire
364364 tableau.emplace (x, std::move (l));
365365 }
366366
367- #ifdef LINSPIRE_BUILD_LISTENERS
367+ #ifdef LINSPIRE_ENABLE_LISTENERS
368368 void solver::add_listener (std::shared_ptr<listener> l) noexcept { listeners.insert (l); }
369369 void solver::remove_listener (std::shared_ptr<listener> l) noexcept { listeners.erase (l); }
370370#endif
You can’t perform that action at this time.
0 commit comments