MemoryListener Class Reference

Handles update signals from the memory system and distributes it to its subsribers. More...

#include <RobotAPI/libraries/armem/client/util/MemoryListener.h>

+ Inheritance diagram for MemoryListener:

Public Types

using Callback = std::function< void(const MemoryID &subscriptionID, const std::vector< MemoryID > &updatedSnapshotIDs)>
 
using CallbackUpdatedOnly = std::function< void(const std::vector< MemoryID > &updatedSnapshotIDs)>
 
template<class CalleeT >
using MemberCallback = void(CalleeT::*)(const MemoryID &subscriptionID, const std::vector< MemoryID > &updatedSnapshotIDs)
 
template<class CalleeT >
using MemberCallbackUpdatedOnly = void(CalleeT::*)(const std::vector< MemoryID > &updatedSnapshotIDs)
 

Public Member Functions

 MemoryListener (ManagedIceObject *component=nullptr)
 
void setComponent (ManagedIceObject *component)
 
void subscribe (const MemoryID &subscriptionID, Callback Callback)
 
void subscribe (const MemoryID &subscriptionID, CallbackUpdatedOnly Callback)
 
template<class CalleeT >
void subscribe (const MemoryID &subscriptionID, CalleeT *callee, MemberCallback< CalleeT > callback)
 Subscribe with a class member function: More...
 
template<class CalleeT >
void subscribe (const MemoryID &subscriptionID, CalleeT *callee, MemberCallbackUpdatedOnly< CalleeT > callback)
 
void updated (const std::vector< data::MemoryID > &updatedIDs) const
 
void updated (const std::vector< MemoryID > &updatedIDs) const
 Function handling updates from the MemoryListener ice topic. More...
 

Static Public Member Functions

static std::string MakeMemoryTopicName (const MemoryID &memoryID)
 

Protected Attributes

std::unordered_map< MemoryID, std::vector< Callback > > callbacks
 

Detailed Description

Handles update signals from the memory system and distributes it to its subsribers.

Definition at line 27 of file MemoryListener.h.

Member Typedef Documentation

◆ Callback

using Callback = std::function<void(const MemoryID& subscriptionID, const std::vector<MemoryID>& updatedSnapshotIDs)>

Definition at line 31 of file MemoryListener.h.

◆ CallbackUpdatedOnly

using CallbackUpdatedOnly = std::function<void(const std::vector<MemoryID>& updatedSnapshotIDs)>

Definition at line 32 of file MemoryListener.h.

◆ MemberCallback

using MemberCallback = void(CalleeT::*)(const MemoryID& subscriptionID, const std::vector<MemoryID>& updatedSnapshotIDs)

Definition at line 35 of file MemoryListener.h.

◆ MemberCallbackUpdatedOnly

using MemberCallbackUpdatedOnly = void(CalleeT::*)(const std::vector<MemoryID>& updatedSnapshotIDs)

Definition at line 37 of file MemoryListener.h.

Constructor & Destructor Documentation

◆ MemoryListener()

MemoryListener ( ManagedIceObject component = nullptr)

Definition at line 23 of file MemoryListener.cpp.

Member Function Documentation

◆ MakeMemoryTopicName()

std::string MakeMemoryTopicName ( const MemoryID memoryID)
static

Definition at line 17 of file MemoryListener.cpp.

+ Here is the caller graph for this function:

◆ setComponent()

void setComponent ( ManagedIceObject component)

Definition at line 29 of file MemoryListener.cpp.

+ Here is the caller graph for this function:

◆ subscribe() [1/4]

void subscribe ( const MemoryID subscriptionID,
Callback  Callback 
)

Definition at line 123 of file MemoryListener.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscribe() [2/4]

void subscribe ( const MemoryID subscriptionID,
CallbackUpdatedOnly  Callback 
)

Definition at line 134 of file MemoryListener.cpp.

+ Here is the call graph for this function:

◆ subscribe() [3/4]

void subscribe ( const MemoryID subscriptionID,
CalleeT *  callee,
MemberCallback< CalleeT >  callback 
)
inline

Subscribe with a class member function:

listener.subscribe(entityID, this, &This::myCallback);

Definition at line 58 of file MemoryListener.h.

+ Here is the call graph for this function:

◆ subscribe() [4/4]

void subscribe ( const MemoryID subscriptionID,
CalleeT *  callee,
MemberCallbackUpdatedOnly< CalleeT >  callback 
)
inline

Definition at line 68 of file MemoryListener.h.

+ Here is the call graph for this function:

◆ updated() [1/2]

void updated ( const std::vector< data::MemoryID > &  updatedIDs) const

Definition at line 36 of file MemoryListener.cpp.

+ Here is the call graph for this function:

◆ updated() [2/2]

void updated ( const std::vector< MemoryID > &  updatedIDs) const

Function handling updates from the MemoryListener ice topic.

Definition at line 45 of file MemoryListener.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ callbacks

std::unordered_map<MemoryID, std::vector<Callback> > callbacks
protected

Definition at line 88 of file MemoryListener.h.


The documentation for this class was generated from the following files: