bipedal locomotion framework
A suite of libraries for achieving bipedal locomotion on humanoid robots
BipedalLocomotion::YarpUtilities::VectorsCollectionServer Class Reference

VectorsCollectionServer is a class that implements the VectorsCollectionMetadataService. More...

#include <YarpUtilities/include/BipedalLocomotion/YarpUtilities/VectorsCollectionServer.h>

Public Member Functions

 VectorsCollectionServer ()
 Constructor.
 
virtual ~VectorsCollectionServer ()
 Destructor.
 
bool initialize (std::weak_ptr< const ParametersHandler::IParametersHandler > handler)
 Initialize the server. More...
 
bool populateMetadata (const std::string &key, const std::vector< std::string > &metadata)
 Populate the metadata. More...
 
bool finalizeMetadata ()
 Finalize the metadata. More...
 
bool populateData (const std::string &key, const iDynTree::Span< const double > &data)
 Set the data. More...
 
VectorsCollectionMetadata getMetadata () override
 Get the metadata. More...
 
VectorsCollectionMetadata getMetadataIncremental (const std::int32_t fromVersion) override
 Read only the metadata introduced after the provided version. More...
 
bool areMetadataReady () override
 Check if the metadata is ready. More...
 
void prepareData ()
 Prepare the data. More...
 
void sendData (bool forceStrict=false)
 Send the data filled with populateData. More...
 
bool clearData ()
 Deallocates the memory held by the internal buffer used to store data. More...
 

Detailed Description

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>();
// fill the handler with the parameters shown in the documentation
VectorCollectionServer server;
server.initialize(handler);
// The metadata should be populated before the data is sent.
// The metadata are available to the client only after the finalizeMetadata function is called.
server.populateMetadata("key1", {"metadata1", "metadata2", "metadata3"});
server.populateMetadata("key2", {"metadata4", "metadata5", "metadata6"});
server.finalizeMetadata();
// prepare the data
server.prepareData();
server.clearData(); // optional
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.

Member Function Documentation

◆ initialize()

bool VectorsCollectionServer::initialize ( std::weak_ptr< const ParametersHandler::IParametersHandler handler)

Initialize the server.

Parameters
handlerpointer 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
keykey of the metadata.
metadatametadata.
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
keykey of the data.
datadata.
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
fromVersionversion 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
forceStrictIf 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: