Ignore:
Timestamp:
Oct 30, 2015, 11:43:20 AM (10 years ago)
Author:
Frederik Heber <heber@…>
Children:
6e2f3b
Parents:
1f96ec
git-author:
Frederik Heber <heber@…> (07/10/15 09:44:07)
git-committer:
Frederik Heber <heber@…> (10/30/15 11:43:20)
Message:

Added static functions to control access to static NotificationChannels.

  • Relay is friend as it uses the mutex when accessing.
  • this is to protect changes in NotificationChannels from changes outside the scope of this library.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodePatterns/Observer/Observable.hpp

    r1f96ec rdd7c44  
    4545 */
    4646class Observable : public Observer {
     47  //!> grant Relay access to NotificationChannels as we know it uses the mutex as well
     48  friend class Relay;
    4749public:
    4850  //!> typedef for a vector of channels
     
    134136
    135137protected:
     138
     139  static void insertNotificationChannel( std::pair<Observable*, Channels *> _pair);
     140  static void eraseNotificationChannel(Observable * const _target);
     141  static bool isNotificationChannelPresent(const Observable * const _target);
     142  static const Channels *getNotificationChannels(const Observable * const _target);
     143  static Notification_ptr getNotificationChannel(const Observable * const _target, const size_t _no);
     144
     145private:
    136146
    137147  typedef std::map<Observable*, Channels *> ChannelMap;
     
    188198#define PASTE_HELPER(a,b) a ## b
    189199#define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this)
    190 #define NOTIFY(channelno) do{Observable::enque_notification_internal(this,NotificationChannels[this]->getChannel(channelno));}while(0)
     200#define NOTIFY(channelno) do{Observable::enque_notification_internal(this,Observable::getNotificationChannel(this,channelno));}while(0)
    191201#define LOCK_OBSERVABLE(observable) Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(&(observable))
    192202
Note: See TracChangeset for help on using the changeset viewer.