yarp.os is a library in the YARP framework that provides functionality for easy communication between different modules in a robotic system. An important feature in this library is the Searchable class, which can be used to store and retrieve key-value pairs associated with different objects.
One of its methods is the findGroup function, which can be used to search for all objects that have a specific value associated with a certain key. The function returns a list of pointers to the matching objects. Here is an example of how to use the findGroup function:
#include #include
using namespace yarp::os; using namespace std;
int main() { // Create a searchable object with some key-value pairs Searchable mySearchable; mySearchable.put("name", "John"); mySearchable.put("age", 27); mySearchable.put("city", "New York");
// Create a list of searchable objects vector myList; myList.push_back(&mySearchable);
// Search for objects with age=27 vector result = Searchable::findGroup(myList, "age", 27);
// Print the number of matching objects cout << "Found " << result.size() << " objects with age=27" << endl;
return 0; }
In this example, we create a searchable object called mySearchable and add some key-value pairs to it. We then create a vector of searchable objects and add mySearchable to it. Finally, we use the findGroup function to search for all objects in the vector that have the value 27 associated with the key "age". The function returns a vector of pointers to the matching objects, which we then print to the console.
The package library for yarp.os is yarp\_core.
C++ (Cpp) Searchable::findGroup - 30 examples found. These are the top rated real world C++ (Cpp) examples of yarp::os::Searchable::findGroup extracted from open source projects. You can rate examples to help us improve the quality of examples.