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:

Classes

struct  ManagedCallback
 

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)
 
SubscriptionHandle subscribe (const MemoryID &subscriptionID, Callback Callback)
 
SubscriptionHandle subscribe (const MemoryID &subscriptionID, CallbackUpdatedOnly Callback)
 
template<class CalleeT >
SubscriptionHandle subscribe (const MemoryID &subscriptionID, CalleeT *callee, MemberCallback< CalleeT > callback)
 Subscribe with a class member function: More...
 
template<class CalleeT >
SubscriptionHandle subscribe (const MemoryID &subscriptionID, CalleeT *callee, MemberCallbackUpdatedOnly< CalleeT > callback)
 
void unsubscribe (SubscriptionHandle &subscriptionHandle)
 
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< ManagedCallback > > callbacks
 
std::unordered_map< std::string, int > memoryRefCount
 memoryName -> callbacks needing memory topic More...
 
long nextId = 0
 

Detailed Description

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

Definition at line 25 of file MemoryListener.h.

Member Typedef Documentation

◆ Callback

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

Definition at line 30 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 36 of file MemoryListener.h.

◆ MemberCallbackUpdatedOnly

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

Definition at line 39 of file MemoryListener.h.

Constructor & Destructor Documentation

◆ MemoryListener()

MemoryListener ( ManagedIceObject component = nullptr)

Definition at line 22 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 27 of file MemoryListener.cpp.

+ Here is the caller graph for this function:

◆ subscribe() [1/4]

SubscriptionHandle subscribe ( const MemoryID subscriptionID,
Callback  Callback 
)

Definition at line 116 of file MemoryListener.cpp.

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

◆ subscribe() [2/4]

SubscriptionHandle subscribe ( const MemoryID subscriptionID,
CallbackUpdatedOnly  Callback 
)

Definition at line 135 of file MemoryListener.cpp.

+ Here is the call graph for this function:

◆ subscribe() [3/4]

SubscriptionHandle 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 60 of file MemoryListener.h.

+ Here is the call graph for this function:

◆ subscribe() [4/4]

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

Definition at line 70 of file MemoryListener.h.

+ Here is the call graph for this function:

◆ unsubscribe()

void unsubscribe ( SubscriptionHandle subscriptionHandle)

Definition at line 144 of file MemoryListener.cpp.

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

◆ updated() [1/2]

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

Definition at line 33 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 41 of file MemoryListener.cpp.

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

Member Data Documentation

◆ callbacks

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

Definition at line 101 of file MemoryListener.h.

◆ memoryRefCount

std::unordered_map<std::string, int> memoryRefCount
protected

memoryName -> callbacks needing memory topic

Definition at line 104 of file MemoryListener.h.

◆ nextId

long nextId = 0
protected

Definition at line 93 of file MemoryListener.h.


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