#pragma once #include "vde/brep/feature_tree.h" #include #include #include namespace vde::brep { /// Callback type for model changes. /// Receives the feature name and the new model after rebuild. using UpdateCallback = std::function; /** * @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 callbacks_; }; } // namespace vde::brep