Ignore:
Timestamp:
Dec 26, 2025, 9:40:14 PM (2 days ago)
Author:
Frederik Heber <frederik.heber@…>
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)
Message:

Streamlines channel creation in Observables.

  • CodePatterns is now version 1.3.4.
  • we no longer need to add the channels manually in the cstor of a class that derives from Observable. Instead, we just need to pass the maximum number of channels (as they are typically enumerated anyway) and they are generated and added.
  • added mutex protection when inserting.
  • adjusted class Relay to forward similar convenience cstors.
  • adjusted all call sites in molecuilder.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ThirdParty/CodePatterns/src/Observer/Observable.cpp

    rf2d5ce rc8cb0d  
    383383}
    384384
    385 /** Constructor for class Observable.
    386  */
    387385Observable::Observable(
    388386    std::string name,
     
    405403    insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) );
    406404  }
     405}
     406
     407Observable::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);
    407419}
    408420
     
    459471}
    460472
     473void 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
    461483void Observable::eraseNotificationChannel(Observable * const _target)
    462484{
Note: See TracChangeset for help on using the changeset viewer.