Changeset 160:a7fa406b8ffc in rrlib_serialization


Ignore:
Timestamp:
31.05.2017 23:28:51 (20 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds check for valid 'uid' parameter to PublishedRegisters::AddListener

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • PublishedRegisters.cpp

    r158 r160  
    3333// External includes (system with <>, local with "") 
    3434//---------------------------------------------------------------------- 
     35#include "rrlib/logging/messages.h" 
    3536 
    3637//---------------------------------------------------------------------- 
     
    6768//---------------------------------------------------------------------- 
    6869 
     70void PublishedRegisters::AddListener(uint uid, const std::function<void()>& callback, const void* address) 
     71{ 
     72  if (RegisteredRegisters()[uid]) 
     73  { 
     74    RegisteredRegisters()[uid]->AddListener(callback, address); 
     75  } 
     76  else 
     77  { 
     78    RRLIB_LOG_PRINT(WARNING, "There is no register with uid ", uid); 
     79  } 
     80} 
     81 
    6982std::array<std::unique_ptr<PublishedRegisters::tPerRegisterInfo>, cMAX_PUBLISHED_REGISTERS>& PublishedRegisters::RegisteredRegisters() 
    7083{ 
  • PublishedRegisters.h

    r158 r160  
    142142   * \param address Address of listener. Optional: only required for identification when removing listener. 
    143143   */ 
    144   static void AddListener(uint uid, const std::function<void()>& callback, const void* address = nullptr) 
    145   { 
    146     RegisteredRegisters()[uid]->AddListener(callback, address); 
    147   } 
     144  static void AddListener(uint uid, const std::function<void()>& callback, const void* address = nullptr); 
    148145 
    149146  /*! 
Note: See TracChangeset for help on using the changeset viewer.