|
The memory name system (MNS) client. More...
#include <RobotAPI/libraries/armem/client/MemoryNameSystem.h>
Public Member Functions | |
std::map< std::string, Reader > | getAllReaders () const |
Get Readers for all registered servers (without updating). More... | |
std::map< std::string, Reader > | getAllReaders (bool update=true) |
Get Readers for all registered servers. More... | |
std::map< std::string, Writer > | getAllWriters () const |
Get Writers for all registered servers (without updating). More... | |
std::map< std::string, Writer > | getAllWriters (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::EntityInstance > | resolveEntityInstance (const MemoryID &id) |
Resolve a memory ID to an EntityInstance. More... | |
std::map< MemoryID, wm::EntityInstance > | resolveEntityInstances (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 |
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.
MemoryNameSystem | ( | ) |
Definition at line 17 of file MemoryNameSystem.cpp.
MemoryNameSystem | ( | mns::MemoryNameSystemInterfacePrx | mns, |
ManagedIceObject * | component = nullptr |
||
) |
Construct an MNS client.
mns | The MNS proxy. |
component | The owning component. When using a memory server, dependencies will be added to this component. |
Definition at line 22 of file MemoryNameSystem.cpp.
std::map< std::string, Reader > getAllReaders | ( | ) | const |
Get Readers for all registered servers (without updating).
Definition at line 264 of file MemoryNameSystem.cpp.
std::map< std::string, Reader > getAllReaders | ( | bool | update = true | ) |
Get Readers for all registered servers.
update | If true, perform an update first. |
Definition at line 253 of file MemoryNameSystem.cpp.
std::map< std::string, Writer > getAllWriters | ( | ) | const |
Get Writers for all registered servers (without updating).
Definition at line 310 of file MemoryNameSystem.cpp.
std::map< std::string, Writer > getAllWriters | ( | bool | update = true | ) |
Get Writers for all registered servers.
update | If true, perform an update first. |
Definition at line 300 of file MemoryNameSystem.cpp.
mns::MemoryNameSystemInterfacePrx getMemoryNameSystem | ( | ) | const |
void getMemoryNameSystem | ( | mns::MemoryNameSystemInterfacePrx | mns | ) |
Definition at line 434 of file MemoryNameSystem.cpp.
Get a reader to the given memory name.
memoryID | The memory ID. |
<tt>error::CouldNotResolveMemoryServer</tt> | If the memory name could not be resolved. |
Definition at line 177 of file MemoryNameSystem.cpp.
Get a writer to the given memory name.
memoryID | The memory ID. |
<tt>error::CouldNotResolveMemoryServer</tt> | If the memory name could not be resolved. |
Definition at line 270 of file MemoryNameSystem.cpp.
void initialize | ( | mns::MemoryNameSystemInterfacePrx | mns, |
ManagedIceObject * | component = nullptr |
||
) |
Definition at line 29 of file MemoryNameSystem.cpp.
|
inline |
Indicate whether the proxy is set.
Definition at line 220 of file MemoryNameSystem.h.
void registerServer | ( | const MemoryID & | memoryID, |
mns::dto::MemoryServerInterfaces | server | ||
) |
Register a memory server in the MNS.
memoryID | The memoryID. |
server | The memory server proxy. |
<tt>error::ServerRegistrationOrRemovalFailed</tt> | If the registration failed. |
Definition at line 398 of file MemoryNameSystem.cpp.
void removeServer | ( | const MemoryID & | memoryID | ) |
Remove a memory server from the MNS.
memoryID | The memoryID. |
<tt>error::ServerRegistrationOrRemovalFailed</tt> | If the removal failed. |
Definition at line 414 of file MemoryNameSystem.cpp.
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.
id | The entity, snapshot or instance ID. |
Definition at line 316 of file MemoryNameSystem.cpp.
std::map< MemoryID, wm::EntityInstance > resolveEntityInstances | ( | const std::vector< MemoryID > & | ids | ) |
Definition at line 330 of file MemoryNameSystem.cpp.
mns::dto::MemoryServerInterfaces resolveServer | ( | const MemoryID & | memoryID | ) |
Resolve the given memory server for the given memory ID.
memoryID | The memory ID. |
<tt>error::CouldNotResolveMemoryServer</tt> | If the memory name could not be resolved. |
Definition at line 97 of file MemoryNameSystem.cpp.
void setComponent | ( | ManagedIceObject * | component | ) |
Definition at line 440 of file MemoryNameSystem.cpp.
void update | ( | ) |
Update the internal registry to the data in the MNS.
<tt>error::MemoryNameSystemQueryFailed</tt> | If the call to the MNS failed. |
Definition at line 36 of file MemoryNameSystem.cpp.
Use a memory server and get a reader for it.
Definition at line 184 of file MemoryNameSystem.cpp.
Reader useReader | ( | const MemoryID & | memoryID, |
ManagedIceObject & | component | ||
) |
Definition at line 191 of file MemoryNameSystem.cpp.
Reader useReader | ( | const std::string & | memoryName | ) |
Reader useReader | ( | const std::string & | memoryName, |
ManagedIceObject & | component | ||
) |
Use a memory server and get a writer for it.
Definition at line 276 of file MemoryNameSystem.cpp.
Writer useWriter | ( | const MemoryID & | memoryID, |
ManagedIceObject & | component | ||
) |
Definition at line 282 of file MemoryNameSystem.cpp.
Writer useWriter | ( | const std::string & | memoryName | ) |
Writer useWriter | ( | const std::string & | memoryName, |
ManagedIceObject & | component | ||
) |