1 // Copyright (C) 2017-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_Update.h
4 // Created: 17 Feb 2017
5 // Author: Artem ZHIDKOV
7 #ifndef PlaneGCSSolver_Update_H_
8 #define PlaneGCSSolver_Update_H_
10 #include <ModelAPI_Feature.h>
16 class SketchSolver_Constraint;
17 class PlaneGCSSolver_Update;
18 typedef std::shared_ptr<PlaneGCSSolver_Update> UpdaterPtr;
20 /** \class PlaneGCSSolver_Update
22 * \brief Send events to listeners about changing a feature
24 class PlaneGCSSolver_Update
27 PlaneGCSSolver_Update(UpdaterPtr theNext = UpdaterPtr())
31 virtual ~PlaneGCSSolver_Update() {}
33 /// \brief Attach listener
34 /// \param theObserver [in] object which want to receive notifications
35 /// \param theType [in] receive notifications about changing objects
36 /// of theType and their derivatives
37 virtual void attach(SketchSolver_Constraint* theObserver, const std::string& theType) = 0;
39 /// \brief Detach listener
40 void detach(SketchSolver_Constraint* theObserver) {
41 std::list<SketchSolver_Constraint*>::iterator anIt = myObservers.begin();
42 for (; anIt != myObservers.end(); ++anIt)
43 if (*anIt == theObserver) {
44 myObservers.erase(anIt);
47 // detach listener from all senders
49 myNext->detach(theObserver);
52 /// \brief Send notification about update of the feature to all interested
53 virtual void update(const FeaturePtr& theFeature) = 0;
56 UpdaterPtr myNext; ///< next updater, access if current one unable to process request
57 std::list<SketchSolver_Constraint*> myObservers; ///< list of observers