Project

General

Profile

Feature #2279

Updated by Junxiao Shi over 9 years ago

``` 
 I'm proposing the following way to protect emissions of the events: 

     template<typename Owner, ...TArgs, typename ...TArgs> 
 Owner> 
     class EventEmitter 
 
     { 
 
       ... 
 
     private: 
   
       void 
   
       operator()(const TArgs&... args) TArgs&...args) const; 

   
    
       friend typename Owner; 
 
     }; 

 

     class Face 
 SomeClass 
     { 
 public: 
   EventEmitter<Face, Interest> onReceiveInterest; 

 protected: 
   void 
   raiseOnReceiveInterest(const Interest& interest) 
   { 
     onReceiveInterest(interest); 
   } 
 private: 
       EventEmitter<int, SomeClass> m_emitter; 
     }; 
 ``` 

 I haven't checked, but I think this way only SomeClass will be able to emit events.

Back