Changeset 454bc54 for src/Observer/Observable.cpp
- Timestamp:
- Oct 30, 2015, 11:43:01 AM (10 years ago)
- Children:
- e24dde
- Parents:
- 1b5188
- git-author:
- Frederik Heber <heber@…> (06/19/15 22:28:24)
- git-committer:
- Frederik Heber <heber@…> (10/30/15 11:43:01)
- File:
-
- 1 edited
-
src/Observer/Observable.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Observer/Observable.cpp
r1b5188 r454bc54 26 26 #include "CodePatterns/Observer/defs.hpp" 27 27 #include "CodePatterns/Observer/Notification.hpp" 28 29 #include <algorithm> 28 30 29 31 //!> This function does nothing with the given Observable … … 107 109 ObservablesMapLock.lock(); 108 110 --depth[publisher]; 109 ObservablesMapLock.unlock();110 111 #ifdef LOG_OBSERVER 111 112 observerLog().addMessage(depth[publisher]) << "<< Unlocking " << observerLog().getName(publisher); 112 113 #endif 113 ObservablesMapLock.lock();114 114 int depth_publisher = depth[publisher]; 115 115 ObservablesMapLock.unlock(); … … 203 203 // send out all notifications that need to be done 204 204 205 ObservablesMapLock.lock(); 205 206 notificationSet currentNotifications = notifications[this]; 207 ObservablesMapLock.unlock(); 206 208 for(notificationSet::iterator it = currentNotifications.begin(); 207 209 it != currentNotifications.end();++it){ … … 317 319 } 318 320 319 void Observable::signOn(Observer *target, size_t channelno) const 321 void Observable::signOn( 322 Observer *target, 323 size_t channelno, 324 PriorityLevel priority) const 320 325 { 321 326 boost::recursive_mutex::scoped_lock guard(ObservablesMapLock); … … 326 331 << "'s channel no." << channelno << "."; 327 332 #endif 328 notification->addObserver(target );333 notification->addObserver(target, priority.level); 329 334 } 330 335 … … 398 403 /** Constructor for class Observable. 399 404 */ 400 Observable::Observable(std::string name ) :405 Observable::Observable(std::string name, const channels_t &_channels) : 401 406 Observer(Observer::BaseConstructor()), 402 407 graveyard_informer(&noop_informer) … … 407 412 << observerLog().getName(static_cast<Observable *>(this)); 408 413 #endif 414 415 if (!_channels.empty()) { 416 Channels *OurChannel = new Channels; 417 NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) ); 418 // add instance for each notification type 419 for (channels_t::const_iterator iter = _channels.begin(); 420 iter != _channels.end(); ++iter) 421 OurChannel->addChannel(*iter); 422 } 409 423 } 410 424 … … 442 456 } 443 457 } 458 459 Observable::channels_t Observable::getChannelList(const size_t max) 460 { 461 channels_t channels(max); 462 std::generate(channels.begin(), channels.end(), UniqueNumber()); 463 return channels; 464 }
Note:
See TracChangeset
for help on using the changeset viewer.
