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
 
using CallbackUpdatedOnly
 
template<class CalleeT>
using MemberCallback
 
template<class CalleeT>
using MemberCallbackUpdatedOnly
 

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:
 
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.
 

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
 
long nextId = 0
 
std::mutex subscribeMutex
 

Detailed Description

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

Definition at line 26 of file MemoryListener.h.

Member Typedef Documentation

◆ Callback

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

Definition at line 30 of file MemoryListener.h.

◆ CallbackUpdatedOnly

Initial value:
std::function<void(const std::vector<MemoryID>& updatedSnapshotIDs)>

Definition at line 32 of file MemoryListener.h.

◆ MemberCallback

template<class CalleeT>
using MemberCallback
Initial value:
void (CalleeT::*)(const MemoryID& subscriptionID,
const std::vector<MemoryID>& updatedSnapshotIDs)

Definition at line 36 of file MemoryListener.h.

◆ MemberCallbackUpdatedOnly

template<class CalleeT>
using MemberCallbackUpdatedOnly
Initial value:
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.

+ Here is the caller graph for this function:

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 118 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 139 of file MemoryListener.cpp.

+ Here is the call graph for this function:

◆ subscribe() [3/4]

template<class CalleeT>
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 61 of file MemoryListener.h.

+ Here is the call graph for this function:

◆ subscribe() [4/4]

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

Definition at line 71 of file MemoryListener.h.

+ Here is the call graph for this function:

◆ unsubscribe()

void unsubscribe ( SubscriptionHandle & subscriptionHandle)

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

◆ memoryRefCount

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

memoryName -> callbacks needing memory topic

Definition at line 106 of file MemoryListener.h.

◆ nextId

long nextId = 0
protected

Definition at line 94 of file MemoryListener.h.

◆ subscribeMutex

std::mutex subscribeMutex
mutableprotected

Definition at line 102 of file MemoryListener.h.


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