|
|
To write data to an existing memory server you have two different options: You can use an instantiation of the armarx::armem::client::Writer-class or use a specific Writer for the core segment you want to write.
The first option is general and does not need any additional implementation outside of the core segment definition, but offers less convenience as the user needs to do everything themselves (including conversions to data transfer objects).
The second option requieres someone to have already encapsulated all of those steps into a convenience method.
An example of this can be found in this tutorial in the section on how to commit data.
Be aware that you need access to the MemoryNameSystem (MNS) and include dependencies of the aron conversions, the armem::EntityUpdate class and the armarx::armem::client::Writer class.
If specific data needs to be written to a specific core segment form more than one component it makes sense to encapsulate this into its own Writer class. An example of such a class can be found in the Object Memory - Class Writer.
To write such a Writer class one needs to inherit from armem::client::util::SimpleWriterBase and implement at least the methods defaultProperties() and propertyPrefix(). Additionally one needs to set the provider name and can then use the memoryWriter of the parent class to commit data once the armarx::armem::Commit (which consists of one or more armem::EntityUpdates) has been constructed.
In general one should add functions to allow using this Writer with Business Objects and without having to take care of updates or commits.
Reading data from a memory server is very similar to writing to one.
There are again two different options: You can use an instantiation of the armarx::armem::client::Reader-class or use a specific Reader for the core segment you want to read.
The first option is general and does not need any additional implementation outside of the core segment definition, but offers less convenience as the user needs to do everything themselves (including conversions to data transfer objects).
The second option requieres someone to have already encapsulated all of those steps into a convenience method.
An example of this can be found in this tutorial in the section on how to read data.
Be aware that you need access to the MemoryNameSystem (MNS) and include dependencies of the aron conversions, the armem::client::QueryBuilder class and the armarx::armem::client::Reader class.
If specific data needs to be read from a specific core segment form more than one component it makes sense to encapsulate this into its own Reader class. An example of such a class can be found in the Object Memory - Class Reader.
To write such a Reader class one needs to inherit from armem::client::util::SimpleReaderBase and implement at least the methods defaultProperties() and propertyPrefix(). One can use the memoryReader() function of the parent class to access the general Reader implementation and use it's query() method and a armem::client::query::Builder to query data from the memory server.
In general one should add functions to encapsulate the query building and the error handeling if something is going wrong with the underlying Reader.
Similar to writing data directly into a memory server one can also load data from the long-term memory into the current working memory of any memory server. To do so one can use a Memory Loader.
Currently there is only the general implementation of a Loader class, providing methods to load data from a specified location on the disk into a specified working memory server. It is possible to specify how many snapshots one wants to load (per entity) and provide a list of core segment names to load from.
An usage example can be found at this component or as part of the Example Memory.