1.1 --- a/src/lemon/bits/alteration_notifier.h Wed May 11 17:36:25 2005 +0000
1.2 +++ b/src/lemon/bits/alteration_notifier.h Sat May 14 17:20:40 2005 +0000
1.3 @@ -29,8 +29,9 @@
1.4 /// \addtogroup graphmaps
1.5 /// @{
1.6
1.7 - /// Registry class to register objects observes alterations in the graph.
1.8 -
1.9 + /// \brief Registry class to register objects observes alterations in
1.10 + /// the graph.
1.11 + ///
1.12 /// This class is a registry for the objects which observe the
1.13 /// alterations in a container. The alteration observers can be attached
1.14 /// to and detached from the registry. The observers have to inherit
1.15 @@ -38,8 +39,7 @@
1.16 /// the virtual functions in that.
1.17 ///
1.18 /// The most important application of the alteration observing is the
1.19 - /// dynamic map implementation when the observers are observing the
1.20 - /// alterations in the graph.
1.21 + /// dynamic map implementation.
1.22 ///
1.23 /// \param _Item The item type what the observers are observing, usually
1.24 /// edge or node.
1.25 @@ -74,16 +74,16 @@
1.26
1.27 friend class AlterationNotifier;
1.28
1.29 - /// Default constructor.
1.30 -
1.31 + /// \brief Default constructor.
1.32 + ///
1.33 /// Default constructor for ObserverBase.
1.34 ///
1.35 ObserverBase() : registry(0) {}
1.36
1.37 virtual ~ObserverBase() {}
1.38
1.39 - /// Attaches the observer into an AlterationNotifier.
1.40 -
1.41 + /// \brief Attaches the observer into an AlterationNotifier.
1.42 + ///
1.43 /// This member attaches the observer into an AlterationNotifier.
1.44 ///
1.45 void attach(AlterationNotifier& r) {
1.46 @@ -91,8 +91,8 @@
1.47 registry->attach(*this);
1.48 }
1.49
1.50 - /// Detaches the observer into an AlterationNotifier.
1.51 -
1.52 + /// \brief Detaches the observer into an AlterationNotifier.
1.53 + ///
1.54 /// This member detaches the observer from an AlterationNotifier.
1.55 ///
1.56 void detach() {
1.57 @@ -131,8 +131,20 @@
1.58 /// is added to the container. It have to be overrided in the
1.59 /// subclasses.
1.60
1.61 - virtual void add(const Item&) = 0;
1.62 + virtual void add(const Item&) = 0;
1.63
1.64 + /// \brief The member function to notificate the observer about
1.65 + /// simulitem is added to the container.
1.66 + ///
1.67 + /// The add() member function notificates the observer about an item
1.68 + /// is added to the container. It have to be overrided in the
1.69 + /// subclasses.
1.70 +
1.71 + virtual void add(const std::vector<Item>& items) {
1.72 + for (int i = 0; i < (int)items.size(); ++i) {
1.73 + add(items[i]);
1.74 + }
1.75 + }
1.76
1.77 /// \brief The member function to notificate the observer about an
1.78 /// item is erased from the container.
1.79 @@ -143,6 +155,12 @@
1.80
1.81 virtual void erase(const Item&) = 0;
1.82
1.83 + virtual void erase(const std::vector<Item>& items) {
1.84 + for (int i = 0; i < (int)items.size(); ++i) {
1.85 + add(items[i]);
1.86 + }
1.87 + }
1.88 +
1.89 /// \brief The member function to notificate the observer about the
1.90 /// container is built.
1.91 ///
1.92 @@ -228,20 +246,37 @@
1.93
1.94 public:
1.95
1.96 - /// Notifies all the registered observers about an Item added to the container.
1.97 -
1.98 - /// It notifies all the registered observers about an Item added to the container.
1.99 + /// \brief Notifies all the registered observers about an Item added to
1.100 + /// the container.
1.101 + ///
1.102 + /// It notifies all the registered observers about an Item added to
1.103 + /// the container.
1.104 ///
1.105 - void add(const Item& key) {
1.106 + void add(const Item& item) {
1.107 typename Container::iterator it;
1.108 for (it = container.begin(); it != container.end(); ++it) {
1.109 - (*it)->add(key);
1.110 + (*it)->add(item);
1.111 }
1.112 }
1.113
1.114 - /// Notifies all the registered observers about an Item erased from the container.
1.115 -
1.116 - /// It notifies all the registered observers about an Item erased from the container.
1.117 + /// \brief Notifies all the registered observers about more Item added to
1.118 + /// the container.
1.119 + ///
1.120 + /// It notifies all the registered observers about more Item added to
1.121 + /// the container.
1.122 + ///
1.123 + void add(const std::vector<Item>& items) {
1.124 + typename Container::iterator it;
1.125 + for (it = container.begin(); it != container.end(); ++it) {
1.126 + (*it)->add(items);
1.127 + }
1.128 + }
1.129 +
1.130 + /// \brief Notifies all the registered observers about an Item erased from
1.131 + /// the container.
1.132 + ///
1.133 + /// It notifies all the registered observers about an Item erased from
1.134 + /// the container.
1.135 ///
1.136 void erase(const Item& key) {
1.137 typename Container::iterator it;
1.138 @@ -249,10 +284,24 @@
1.139 (*it)->erase(key);
1.140 }
1.141 }
1.142 +
1.143 + /// \brief Notifies all the registered observers about more Item erased
1.144 + /// from the container.
1.145 + ///
1.146 + /// It notifies all the registered observers about more Item erased from
1.147 + /// the container.
1.148 + ///
1.149 + void erase(const std::vector<Item>& items) {
1.150 + typename Container::iterator it;
1.151 + for (it = container.begin(); it != container.end(); ++it) {
1.152 + (*it)->erase(items);
1.153 + }
1.154 + }
1.155
1.156
1.157 - /// Notifies all the registered observers about the container is built.
1.158 -
1.159 + /// \brief Notifies all the registered observers about the container is
1.160 + /// built.
1.161 + ///
1.162 /// Notifies all the registered observers about the container is built
1.163 /// from an empty container.
1.164 void build() {
1.165 @@ -263,8 +312,9 @@
1.166 }
1.167
1.168
1.169 - /// Notifies all the registered observers about all Items are erased.
1.170 -
1.171 + /// \brief Notifies all the registered observers about all Items are
1.172 + /// erased.
1.173 + ///
1.174 /// Notifies all the registered observers about all Items are erased
1.175 /// from the container.
1.176 void clear() {