lemon/bits/alteration_notifier.h
changeset 1718 6a958ab38386
parent 1701 77bb84387815
child 1729 06f939455cb1
equal deleted inserted replaced
3:4a1feb055ad0 4:424d7f6a9070
   137       /// subclasses.
   137       /// subclasses.
   138 	
   138 	
   139       virtual void add(const Item&) = 0;
   139       virtual void add(const Item&) = 0;
   140 
   140 
   141       /// \brief The member function to notificate the observer about 
   141       /// \brief The member function to notificate the observer about 
   142       /// simulitem is added to the container.
   142       /// more item is added to the container.
   143       ///
   143       ///
   144       /// The add() member function notificates the observer about an item
   144       /// The add() member function notificates the observer about more item
   145       /// is added to the container. It have to be overrided in the
   145       /// is added to the container. It have to be overrided in the
   146       /// subclasses.
   146       /// subclasses.
   147 
   147 
   148       virtual void add(const std::vector<Item>& items) {
   148       virtual void add(const std::vector<Item>& items) {
   149 	for (int i = 0; i < (int)items.size(); ++i) {
   149 	for (int i = 0; i < (int)items.size(); ++i) {
   158       /// item is erased from the container. It have to be overrided in
   158       /// item is erased from the container. It have to be overrided in
   159       /// the subclasses.
   159       /// the subclasses.
   160 	
   160 	
   161       virtual void erase(const Item&) = 0;
   161       virtual void erase(const Item&) = 0;
   162 
   162 
       
   163       /// \brief The member function to notificate the observer about 
       
   164       /// more item is erased from the container.
       
   165       ///
       
   166       /// The erase() member function notificates the observer about more item
       
   167       /// is erased from the container. It have to be overrided in the
       
   168       /// subclasses.
   163       virtual void erase(const std::vector<Item>& items) {
   169       virtual void erase(const std::vector<Item>& items) {
   164 	for (int i = 0; i < (int)items.size(); ++i) {
   170 	for (int i = 0; i < (int)items.size(); ++i) {
   165 	  erase(items[i]);
   171 	  erase(items[i]);
   166 	}
   172 	}
   167       }
   173       }
       
   174 
       
   175       /// \brief Signal a property change on the given item.
       
   176       ///
       
   177       /// Signal a property change on the given item. It should
       
   178       /// be used always with the commitChange() function.
       
   179       /// This function is called always the property change.
       
   180       /// The commitChange() is called always after the change.
       
   181       virtual void signalChange(const Item&) {}
       
   182 
       
   183       /// \brief Commit the property change on the given item.
       
   184       ///
       
   185       /// Commit the property change on the given item. It should
       
   186       /// be used always with the signalChange() function.
       
   187       /// This function is called always the property change.
       
   188       /// The commitChange() is called always after the change.
       
   189       virtual void commitChange(const Item&) {}
   168 
   190 
   169       /// \brief The member function to notificate the observer about the
   191       /// \brief The member function to notificate the observer about the
   170       /// container is built.
   192       /// container is built.
   171       ///
   193       ///
   172       /// The build() member function notificates the observer about the
   194       /// The build() member function notificates the observer about the
   301       for (it = container.begin(); it != container.end(); ++it) {
   323       for (it = container.begin(); it != container.end(); ++it) {
   302 	(*it)->erase(items);
   324 	(*it)->erase(items);
   303       }
   325       }
   304     }
   326     }
   305     
   327     
       
   328     /// \brief Signal a property change on the given item.
       
   329     ///
       
   330     /// Signal a property change on the given item. It should
       
   331     /// be used always with the commitChange() function.
       
   332     /// This function is called always the property change.
       
   333     /// The commitChange() is called always after the change.
       
   334     void signalChange(const Item& item) {
       
   335       typename Container::iterator it;
       
   336       for (it = container.begin(); it != container.end(); ++it) {
       
   337 	(*it)->signalChange(item);
       
   338       }
       
   339     }
       
   340     
       
   341     /// \brief Commit the property change on the given item.
       
   342     ///
       
   343     /// Commit the property change on the given item. It should
       
   344     /// be used always with the signalChange() function.
       
   345     /// This function is called always the property change.
       
   346     /// The commitChange() is called always after the change.
       
   347     void commitChange(const Item& item) {
       
   348       typename Container::iterator it;
       
   349       for (it = container.begin(); it != container.end(); ++it) {
       
   350 	(*it)->commitChange(item);
       
   351       }
       
   352     }
   306 
   353 
   307     /// \brief Notifies all the registered observers about the container is 
   354     /// \brief Notifies all the registered observers about the container is 
   308     /// built.
   355     /// built.
   309     ///		
   356     ///		
   310     /// Notifies all the registered observers about the container is built
   357     /// Notifies all the registered observers about the container is built