Skip to content

Commit 2110059

Browse files
Fix listener option naming: change LINSPIRE_BUILD_LISTENERS to LINSPIRE_ENABLE_LISTENERS for consistency in CMake and header files.
1 parent 85f6071 commit 2110059

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project(LinSpire VERSION 0.2.0 LANGUAGES CXX)
44
include(CTest)
55
enable_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

99
add_library(LinSpire src/linspire.cpp src/var.cpp)
1010
target_compile_features(LinSpire PUBLIC cxx_std_17)
@@ -16,9 +16,9 @@ add_dependencies(LinSpire json)
1616
target_link_libraries(LinSpire PUBLIC json)
1717
setup_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)
2222
endif()
2323

2424
if(BUILD_TESTING)

include/linspire.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace 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:

src/linspire.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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

0 commit comments

Comments
 (0)