Changeset 74e0f7 for src/Patterns/Observer.cpp
- Timestamp:
- Sep 1, 2011, 11:07:47 AM (14 years ago)
- Children:
- 9e776f
- Parents:
- 451f17
- git-author:
- Frederik Heber <heber@…> (09/01/11 11:02:49)
- git-committer:
- Frederik Heber <heber@…> (09/01/11 11:07:47)
- File:
-
- 1 edited
-
src/Patterns/Observer.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Observer.cpp
r451f17 r74e0f7 271 271 } 272 272 273 Notification_ptr Observable::getChannel(size_t no) const 274 { 275 ASSERT(NotificationChannels != NULL, 276 "Observable::getChannel() - observable has no channels."); 277 return NotificationChannels->getChannel(no); 278 } 279 273 280 /** Handles sub-observables that just got killed 274 281 * when an sub-observerable dies we usually don't need to do anything … … 350 357 351 358 Notification::Notification(Observable *_owner) : 352 owner(_owner) 359 owner(_owner), channelno(-1) 360 {} 361 362 Notification::Notification(Observable *_owner, size_t _channelno) : 363 owner(_owner), channelno(_channelno) 353 364 {} 354 365 … … 369 380 } 370 381 } 382 383 Channels::Channels(Observable *_owner) : 384 owner(_owner) 385 {} 386 387 Channels::~Channels() 388 { 389 // free all present Notifications 390 for(NotificationTypetoRefMap::iterator iter = ChannelMap.begin(); 391 !ChannelMap.empty(); iter = ChannelMap.begin()) { 392 delete iter->second; 393 ChannelMap.erase(iter); 394 } 395 } 396 397 void Channels::addChannel(size_t no) 398 { 399 NotificationTypetoRefMap::const_iterator iter = ChannelMap.find(no); 400 ASSERT(iter == ChannelMap.end(), 401 "Channels::addChannel() - channel "+toString(int(no))+" is already present in ChannelMap."); 402 ChannelMap.insert( std::make_pair(no, new Notification(owner, no)) ); 403 } 404 405 void Channels::removeChannel(size_t no) 406 { 407 NotificationTypetoRefMap::iterator iter = ChannelMap.find(no); 408 ASSERT(iter != ChannelMap.end(), 409 "Channels::removeChannel() - channel "+toString(int(no))+" not present in ChannelMap."); 410 delete iter->second; 411 ChannelMap.erase(iter); 412 } 413 414 Notification_ptr Channels::getChannel(size_t no) const 415 { 416 NotificationTypetoRefMap::const_iterator iter = ChannelMap.find(no); 417 ASSERT(iter != ChannelMap.end(), 418 "Channels::getChannel() - channel "+toString(int(no))+" not present in ChannelMap."); 419 return iter->second; 420 } 421 422 size_t Channels::getType(Notification_ptr channel) const 423 { 424 return channel->getChannelNo(); 425 } 426 371 427 372 428 #ifdef LOG_OBSERVER
Note:
See TracChangeset
for help on using the changeset viewer.
