VectorsCollectionServer is a class that implements the VectorsCollectionMetadataService.
More...
#include <YarpUtilities/include/BipedalLocomotion/YarpUtilities/VectorsCollectionServer.h>
VectorsCollectionServer is a class that implements the VectorsCollectionMetadataService.
It allows to send a VectorsCollection to a client.
- Note
- The VectorCollectionServer allows to send a VectorsCollection to a client. You can use the VectorsCollectionServer as follows
auto handler = std::make_shared<ParametersHandler::StdImplementation>();
VectorCollectionServer server;
server.initialize(handler);
server.populateMetadata("key1", {"metadata1", "metadata2", "metadata3"});
server.populateMetadata("key2", {"metadata4", "metadata5", "metadata6"});
server.finalizeMetadata();
server.prepareData();
server.clearData();
server.populateData("key1", {1.0, 2.0, 3.0});
server.populateData("key2", {4.0, 5.0, 6.0});
server.sendData();
server.write() will send the data to the client.
◆ initialize()
Initialize the server.
- Parameters
-
| handler | pointer to the parameters handler. |
- Note
- The following parameters are required:
| Parameter Name | Type | Description |
| remote | string | Name of the port that will be created. |
- Returns
- true if the server has been initialized successfully, false otherwise.
◆ populateMetadata()
| bool VectorsCollectionServer::populateMetadata |
( |
const std::string & |
key, |
|
|
const std::vector< std::string > & |
metadata |
|
) |
| |
Populate the metadata.
- Parameters
-
| key | key of the metadata. |
| metadata | metadata. |
- Returns
- true if the metadata has been populated successfully, false otherwise.
◆ finalizeMetadata()
| bool VectorsCollectionServer::finalizeMetadata |
( |
| ) |
|
Finalize the metadata.
- Returns
- true if the metadata has been finalized successfully, false otherwise.
- Note
- this function should be called after the metadata has been populated. It opens the ports.
◆ populateData()
| bool VectorsCollectionServer::populateData |
( |
const std::string & |
key, |
|
|
const iDynTree::Span< const double > & |
data |
|
) |
| |
Set the data.
- Parameters
-
| key | key of the data. |
| data | data. |
- Returns
- true if the data has been set successfully, false otherwise.
- Note
- this function should be called after the metadata has been finalized and after the prepareData function has been called.
◆ getMetadata()
| VectorsCollectionMetadata VectorsCollectionServer::getMetadata |
( |
| ) |
|
|
override |
Get the metadata.
- Returns
- the metadata.
- Note
- if the metadata is not ready, an empty VectorsCollectionMetadata is returned.
-
if some keys are pending to be finalized, the last finalized metadata is returned.
◆ getMetadataIncremental()
| VectorsCollectionMetadata VectorsCollectionServer::getMetadataIncremental |
( |
const std::int32_t |
fromVersion | ) |
|
|
override |
Read only the metadata introduced after the provided version.
- Parameters
-
| fromVersion | version from which the metadata should be returned. Pass -1 to get the full metadata. |
- Returns
- the metadata introduced after the provided version.
- Note
- if the metadata is not ready, an empty VectorsCollectionMetadata is returned.
◆ areMetadataReady()
| bool VectorsCollectionServer::areMetadataReady |
( |
| ) |
|
|
override |
Check if the metadata is ready.
- Returns
- true if the metadata is ready (it has been finalized at least once), false otherwise.
◆ prepareData()
| void VectorsCollectionServer::prepareData |
( |
| ) |
|
Prepare the data.
- Note
- this function should be called before the data is populated.
◆ sendData()
| void VectorsCollectionServer::sendData |
( |
bool |
forceStrict = false | ) |
|
Send the data filled with populateData.
- Parameters
-
| forceStrict | If this is true, wait until any previous sends are complete. If false, the current object will not be sent on connections that are currently busy. |
◆ clearData()
| bool VectorsCollectionServer::clearData |
( |
| ) |
|
Deallocates the memory held by the internal buffer used to store data.
- Note
- If you have previously populated the object using populateData and intend to reuse it without reallocating memory, you may skip calling this function. Otherwise, use VectorsCollection::clearData to free the memory allocated in the internal buffer.
-
Note that this function only clears the data and does not affect the metadata.
- Returns
- true if the data has been cleared successfully, false otherwise.
The documentation for this class was generated from the following files: