MemoryNameSystem Class Reference

The memory name system (MNS) client. More...

#include <RobotAPI/libraries/armem/client/MemoryNameSystem.h>

+ Inheritance diagram for MemoryNameSystem:

Public Member Functions

std::map< std::string, ReadergetAllReaders () const
 Get Readers for all registered servers (without updating). More...
 
std::map< std::string, ReadergetAllReaders (bool update=true)
 Get Readers for all registered servers. More...
 
std::map< std::string, WritergetAllWriters () const
 Get Writers for all registered servers (without updating). More...
 
std::map< std::string, WritergetAllWriters (bool update=true)
 Get Writers for all registered servers. More...
 
mns::MemoryNameSystemInterfacePrx getMemoryNameSystem () const
 
void getMemoryNameSystem (mns::MemoryNameSystemInterfacePrx mns)
 
Reader getReader (const MemoryID &memoryID)
 Get a reader to the given memory name. More...
 
Writer getWriter (const MemoryID &memoryID)
 Get a writer to the given memory name. More...
 
void initialize (mns::MemoryNameSystemInterfacePrx mns, ManagedIceObject *component=nullptr)
 
 MemoryNameSystem ()
 
 MemoryNameSystem (mns::MemoryNameSystemInterfacePrx mns, ManagedIceObject *component=nullptr)
 Construct an MNS client. More...
 
 operator bool () const
 Indicate whether the proxy is set. More...
 
void registerServer (const MemoryID &memoryID, mns::dto::MemoryServerInterfaces server)
 Register a memory server in the MNS. More...
 
void removeServer (const MemoryID &memoryID)
 Remove a memory server from the MNS. More...
 
std::optional< wm::EntityInstanceresolveEntityInstance (const MemoryID &id)
 Resolve a memory ID to an EntityInstance. More...
 
std::map< MemoryID, wm::EntityInstanceresolveEntityInstances (const std::vector< MemoryID > &ids)
 
mns::dto::MemoryServerInterfaces resolveServer (const MemoryID &memoryID)
 Resolve the given memory server for the given memory ID. More...
 
void setComponent (ManagedIceObject *component)
 
void update ()
 Update the internal registry to the data in the MNS. More...
 
Reader useReader (const MemoryID &memoryID)
 Use a memory server and get a reader for it. More...
 
Reader useReader (const MemoryID &memoryID, ManagedIceObject &component)
 
Reader useReader (const std::string &memoryName)
 
Reader useReader (const std::string &memoryName, ManagedIceObject &component)
 
Writer useWriter (const MemoryID &memoryID)
 Use a memory server and get a writer for it. More...
 
Writer useWriter (const MemoryID &memoryID, ManagedIceObject &component)
 
Writer useWriter (const std::string &memoryName)
 
Writer useWriter (const std::string &memoryName, ManagedIceObject &component)
 
- Public Member Functions inherited from MemoryListener
 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...
 

Additional Inherited Members

- Public Types inherited from MemoryListener
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)
 
- Static Public Member Functions inherited from MemoryListener
static std::string MakeMemoryTopicName (const MemoryID &memoryID)
 
- Protected Attributes inherited from MemoryListener
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

The memory name system (MNS) client.

This client class serves provides the MNS interface and is a local cache of the MNS registry. It can be used to resolve memory servers by their memory ID and to construct client::Readers and client::Writers.

During server resolution, it first consults the locally cached registry. If the memory server is not known locally, the local registry is updated to that of the remote MNS before trying again.

In addition, the MNS client can be used to send queries over multiple memory servers, as well as retrieving the data for arbitrary entity or entity snapshot IDs.

Definition at line 69 of file MemoryNameSystem.h.

Constructor & Destructor Documentation

◆ MemoryNameSystem() [1/2]

Definition at line 17 of file MemoryNameSystem.cpp.

◆ MemoryNameSystem() [2/2]

MemoryNameSystem ( mns::MemoryNameSystemInterfacePrx  mns,
ManagedIceObject component = nullptr 
)

Construct an MNS client.

Parameters
mnsThe MNS proxy.
componentThe owning component. When using a memory server, dependencies will be added to this component.

Definition at line 22 of file MemoryNameSystem.cpp.

Member Function Documentation

◆ getAllReaders() [1/2]

std::map< std::string, Reader > getAllReaders ( ) const

Get Readers for all registered servers (without updating).

Returns
The readers.

Definition at line 264 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ getAllReaders() [2/2]

std::map< std::string, Reader > getAllReaders ( bool  update = true)

Get Readers for all registered servers.

Parameters
updateIf true, perform an update first.
Returns
The readers.

Definition at line 253 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ getAllWriters() [1/2]

std::map< std::string, Writer > getAllWriters ( ) const

Get Writers for all registered servers (without updating).

Returns
The readers.

Definition at line 310 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ getAllWriters() [2/2]

std::map< std::string, Writer > getAllWriters ( bool  update = true)

Get Writers for all registered servers.

Parameters
updateIf true, perform an update first.
Returns
The readers.

Definition at line 300 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ getMemoryNameSystem() [1/2]

mns::MemoryNameSystemInterfacePrx getMemoryNameSystem ( ) const

Definition at line 428 of file MemoryNameSystem.cpp.

+ Here is the caller graph for this function:

◆ getMemoryNameSystem() [2/2]

void getMemoryNameSystem ( mns::MemoryNameSystemInterfacePrx  mns)

Definition at line 434 of file MemoryNameSystem.cpp.

◆ getReader()

Reader getReader ( const MemoryID memoryID)

Get a reader to the given memory name.

Parameters
memoryIDThe memory ID.
Returns
The reader.
Exceptions
<tt>error::CouldNotResolveMemoryServer</tt>If the memory name could not be resolved.

Definition at line 177 of file MemoryNameSystem.cpp.

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

◆ getWriter()

Writer getWriter ( const MemoryID memoryID)

Get a writer to the given memory name.

Parameters
memoryIDThe memory ID.
Returns
The writer.
Exceptions
<tt>error::CouldNotResolveMemoryServer</tt>If the memory name could not be resolved.

Definition at line 270 of file MemoryNameSystem.cpp.

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

◆ initialize()

void initialize ( mns::MemoryNameSystemInterfacePrx  mns,
ManagedIceObject component = nullptr 
)

Definition at line 29 of file MemoryNameSystem.cpp.

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

◆ operator bool()

operator bool ( ) const
inline

Indicate whether the proxy is set.

Definition at line 220 of file MemoryNameSystem.h.

◆ registerServer()

void registerServer ( const MemoryID memoryID,
mns::dto::MemoryServerInterfaces  server 
)

Register a memory server in the MNS.

Parameters
memoryIDThe memoryID.
serverThe memory server proxy.
Exceptions
<tt>error::ServerRegistrationOrRemovalFailed</tt>If the registration failed.

Definition at line 398 of file MemoryNameSystem.cpp.

+ Here is the caller graph for this function:

◆ removeServer()

void removeServer ( const MemoryID memoryID)

Remove a memory server from the MNS.

Parameters
memoryIDThe memoryID.
Exceptions
<tt>error::ServerRegistrationOrRemovalFailed</tt>If the removal failed.

Definition at line 414 of file MemoryNameSystem.cpp.

+ Here is the caller graph for this function:

◆ resolveEntityInstance()

std::optional< wm::EntityInstance > resolveEntityInstance ( const MemoryID id)

Resolve a memory ID to an EntityInstance.

The ID can refer to an entity, an entity snapshot, or an entity instance. When not referring to an entity instance, the latest snapshot and first instance will be queried.

Parameters
idThe entity, snapshot or instance ID.
Returns

Definition at line 316 of file MemoryNameSystem.cpp.

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

◆ resolveEntityInstances()

std::map< MemoryID, wm::EntityInstance > resolveEntityInstances ( const std::vector< MemoryID > &  ids)

Definition at line 330 of file MemoryNameSystem.cpp.

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

◆ resolveServer()

mns::dto::MemoryServerInterfaces resolveServer ( const MemoryID memoryID)

Resolve the given memory server for the given memory ID.

Parameters
memoryIDThe memory ID.
Returns
The memory server proxy.
Exceptions
<tt>error::CouldNotResolveMemoryServer</tt>If the memory name could not be resolved.

Definition at line 97 of file MemoryNameSystem.cpp.

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

◆ setComponent()

void setComponent ( ManagedIceObject component)

Definition at line 440 of file MemoryNameSystem.cpp.

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

◆ update()

void update ( )

Update the internal registry to the data in the MNS.

Exceptions
<tt>error::MemoryNameSystemQueryFailed</tt>If the call to the MNS failed.

Definition at line 36 of file MemoryNameSystem.cpp.

+ Here is the caller graph for this function:

◆ useReader() [1/4]

Reader useReader ( const MemoryID memoryID)

Use a memory server and get a reader for it.

Definition at line 184 of file MemoryNameSystem.cpp.

+ Here is the caller graph for this function:

◆ useReader() [2/4]

Reader useReader ( const MemoryID memoryID,
ManagedIceObject component 
)

Definition at line 191 of file MemoryNameSystem.cpp.

◆ useReader() [3/4]

Reader useReader ( const std::string &  memoryName)

Definition at line 198 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ useReader() [4/4]

Reader useReader ( const std::string &  memoryName,
ManagedIceObject component 
)

Definition at line 204 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ useWriter() [1/4]

Writer useWriter ( const MemoryID memoryID)

Use a memory server and get a writer for it.

Definition at line 276 of file MemoryNameSystem.cpp.

+ Here is the caller graph for this function:

◆ useWriter() [2/4]

Writer useWriter ( const MemoryID memoryID,
ManagedIceObject component 
)

Definition at line 282 of file MemoryNameSystem.cpp.

◆ useWriter() [3/4]

Writer useWriter ( const std::string &  memoryName)

Definition at line 288 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

◆ useWriter() [4/4]

Writer useWriter ( const std::string &  memoryName,
ManagedIceObject component 
)

Definition at line 294 of file MemoryNameSystem.cpp.

+ Here is the call graph for this function:

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