Files
ViewDesignEngine/include/vde/brep/update_notifier.h
T
茂之钳 b96b6defd6
CI / Build & Test (push) Failing after 33s
CI / Release Build (push) Failing after 37s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
feat(v3.9): parallel OpenMP boolean + assembly instancing + update notifier
2026-07-24 15:36:42 +00:00

42 lines
1.1 KiB
C++

#pragma once
#include "vde/brep/feature_tree.h"
#include <functional>
#include <string>
#include <vector>
namespace vde::brep {
/// Callback type for model changes.
/// Receives the feature name and the new model after rebuild.
using UpdateCallback = std::function<void(const std::string& feature_name, const BrepModel& new_model)>;
/**
* @brief Notifies listeners when features change.
*
* Integrates with FeatureHistory: after each apply/undo/redo,
* call notify() to push the updated model to all registered callbacks.
*
* @ingroup brep
*/
class UpdateNotifier {
public:
/// Register a callback. Called on every notify().
void on_update(UpdateCallback cb) { callbacks_.push_back(std::move(cb)); }
/// Notify all registered listeners.
void notify(const std::string& feature, const BrepModel& model) {
for (auto& cb : callbacks_) cb(feature, model);
}
/// Remove all callbacks.
void clear() { callbacks_.clear(); }
/// Number of registered callbacks.
[[nodiscard]] size_t listener_count() const { return callbacks_.size(); }
private:
std::vector<UpdateCallback> callbacks_;
};
} // namespace vde::brep