Changeset c8cb0d for ThirdParty/CodePatterns/src/Observer
- Timestamp:
- Dec 26, 2025, 9:40:14 PM (2 days ago)
- Branches:
- Candidate_v1.7.1, stable
- Children:
- 033646
- Parents:
- f2d5ce
- git-author:
- Frederik Heber <frederik.heber@…> (12/10/25 16:15:28)
- git-committer:
- Frederik Heber <frederik.heber@…> (12/26/25 21:40:14)
- Location:
- ThirdParty/CodePatterns/src/Observer
- Files:
-
- 3 edited
-
Observable.cpp (modified) (3 diffs)
-
Relay.cpp (modified) (1 diff)
-
unittests/stubs/ObserverStub.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ThirdParty/CodePatterns/src/Observer/Observable.cpp
rf2d5ce rc8cb0d 383 383 } 384 384 385 /** Constructor for class Observable.386 */387 385 Observable::Observable( 388 386 std::string name, … … 405 403 insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) ); 406 404 } 405 } 406 407 Observable::Observable( 408 std::string name, 409 const unsigned int _maximum_notification_types) : 410 Observer(Observer::BaseConstructor()), 411 graveyard_informer(&noop_informer) 412 { 413 #ifdef LOG_OBSERVER 414 observerLog().addName(this,name); 415 observerLog().addMessage() << "++ Creating Observable " 416 << observerLog().getName(static_cast<Observable *>(this)); 417 #endif 418 createAndInsertNotificationChannel(_maximum_notification_types); 407 419 } 408 420 … … 459 471 } 460 472 473 void Observable::createAndInsertNotificationChannel(const unsigned int _maximum_notification_types) 474 { 475 boost::recursive_mutex::scoped_lock lock(GlobalObservableInfo::getInstance().getObservablesMapMutex()); 476 Channels *OurChannel = new Channels; 477 // add instance for each notification type 478 for (size_t type = 0; type < _maximum_notification_types; ++type) 479 OurChannel->addChannel(type); 480 insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) ); 481 } 482 461 483 void Observable::eraseNotificationChannel(Observable * const _target) 462 484 { -
ThirdParty/CodePatterns/src/Observer/Relay.cpp
rf2d5ce rc8cb0d 33 33 Relay::Relay(std::string name) : 34 34 Observable(name), 35 Updater(NULL) 36 { 37 #ifdef LOG_OBSERVER 38 observerLog().addName(this,name); 39 observerLog().addMessage() << "++ Creating Relay " << observerLog().getName(this); 40 #endif 41 } 42 43 /** Constructor for class Relay. 44 */ 45 Relay::Relay(std::string name, const channels_t &_channels) : 46 Observable(name, _channels), 47 Updater(NULL) 48 { 49 #ifdef LOG_OBSERVER 50 observerLog().addName(this,name); 51 observerLog().addMessage() << "++ Creating Relay " << observerLog().getName(this); 52 #endif 53 } 54 55 /** Constructor for class Relay. 56 */ 57 Relay::Relay(std::string name, const unsigned int _maximum_notification_types) : 58 Observable(name, _maximum_notification_types), 35 59 Updater(NULL) 36 60 { -
ThirdParty/CodePatterns/src/Observer/unittests/stubs/ObserverStub.cpp
rf2d5ce rc8cb0d 133 133 134 134 NotificationObservable::NotificationObservable() : 135 Observable("NotificationObservable") 136 { 137 Channels *OurChannel = new Channels(); 138 Observable::insertNotificationChannel( std::make_pair(this, OurChannel) ); 139 OurChannel->addChannel(Operation1Notify); 140 OurChannel->addChannel(Operation2Notify); 141 } 135 Observable("NotificationObservable", { Operation1Notify, Operation2Notify }) 136 {} 142 137 143 138 NotificationObservable::~NotificationObservable() … … 242 237 243 238 RelayNotification::RelayNotification() : 244 Relay(std::string("RelayTest")) 245 { 246 Channels *OurChannel = new Channels(); 247 Observable::insertNotificationChannel( std::make_pair(this, OurChannel) ); 248 OurChannel->addChannel(NotificationObservable::Operation1Notify); 249 OurChannel->addChannel(NotificationObservable::Operation2Notify); 250 } 239 Relay(std::string("RelayTest"), { NotificationObservable::Operation1Notify, NotificationObservable::Operation2Notify }) 240 {} 251 241 252 242 RelayNotification::~RelayNotification()
Note:
See TracChangeset
for help on using the changeset viewer.
