Class used to query and update a collection in the warehouse External code shouldn't directly create objects of this class: instead, use WarehouseClient::setupCollection. More...
#include <collection.h>
Classes | |
struct | Impl |
Public Member Functions | |
Collection () | |
Default constructor. Can be called by external code if you want to create a Collection object and assign it later. | |
Collection (const Collection &pub) | |
Copy constructor. Should not be called by external code. Should only be used when rhs is about to go out of scope. | |
Collection (const std::string &topic, const std::string &db, const std::string &collection, const ros::NodeHandle &nh) | |
Constructor. Should not be called by external code. | |
std::string | collectionName () const |
Get the collection name. | |
Collection< M > & | operator= (const Collection< M > &c) |
Assignment operator. | |
std::string | publish (const M &msg, const std::string &metadata=std::string()) |
Publishes a message with given metadata. Waits for notification and returns the id of the message. | |
std::vector< typename MessageWithMetadata< M > ::ConstPtr > | pullAllResults (const std::vector< Condition > &conditions, bool metadata_only=false, const OrderingCriterion &order=OrderingCriterion()) const |
Front-end to queryResults that fetches all the results and puts them into a vector. | |
QueryResults< M >::range_t | queryResults (const std::vector< Condition > &conditions, bool metadata_only=false, const OrderingCriterion &order=OrderingCriterion()) const |
Query the collection. | |
unsigned | removeMessages (const std::vector< Condition > &conditions) |
Remove messages from a collection. | |
Private Types | |
typedef boost::shared_ptr< Impl > | ImplPtr |
Private Member Functions | |
void | addMetadata (const std::string &id, const std::string &metadata) |
Assumes lock is held on mutex_. | |
Private Attributes | |
ImplPtr | impl_ |
Class used to query and update a collection in the warehouse External code shouldn't directly create objects of this class: instead, use WarehouseClient::setupCollection.
Definition at line 52 of file collection.h.
typedef boost::shared_ptr<Impl> warehouse::Collection< M >::ImplPtr [private] |
Definition at line 145 of file collection.h.
warehouse::Collection< M >::Collection | ( | const std::string & | topic, | |
const std::string & | db, | |||
const std::string & | collection, | |||
const ros::NodeHandle & | nh | |||
) |
Constructor. Should not be called by external code.
warehouse::Collection< M >::Collection | ( | const Collection< M > & | pub | ) | [inline] |
Copy constructor. Should not be called by external code. Should only be used when rhs is about to go out of scope.
Definition at line 65 of file collection_impl.h.
warehouse::Collection< M >::Collection | ( | ) | [inline] |
Default constructor. Can be called by external code if you want to create a Collection object and assign it later.
Definition at line 71 of file collection_impl.h.
void warehouse::Collection< M >::addMetadata | ( | const std::string & | id, | |
const std::string & | metadata | |||
) | [private] |
Assumes lock is held on mutex_.
string warehouse::Collection< M >::collectionName | ( | ) | const [inline] |
Get the collection name.
Definition at line 312 of file collection_impl.h.
Collection< M > & warehouse::Collection< M >::operator= | ( | const Collection< M > & | c | ) | [inline] |
Assignment operator.
Definition at line 76 of file collection_impl.h.
std::string warehouse::Collection< M >::publish | ( | const M & | msg, | |
const std::string & | metadata = std::string() | |||
) |
Publishes a message with given metadata. Waits for notification and returns the id of the message.
metadata | A yaml encoded dictionary of key-value pairs, where the keys are strings and the values are numbers or strings (use the yaml_cpp library to generate) |
M | must equal the advertised type of this Collection |
std::vector<typename MessageWithMetadata<M>::ConstPtr > warehouse::Collection< M >::pullAllResults | ( | const std::vector< Condition > & | conditions, | |
bool | metadata_only = false , |
|||
const OrderingCriterion & | order = OrderingCriterion() | |||
) | const |
Front-end to queryResults that fetches all the results and puts them into a vector.
QueryResults<M>::range_t warehouse::Collection< M >::queryResults | ( | const std::vector< Condition > & | conditions, | |
bool | metadata_only = false , |
|||
const OrderingCriterion & | order = OrderingCriterion() | |||
) | const |
Query the collection.
Message | type. Must match message type in collection |
metadata_only | If true, only get the metadata, not the message objects themselves (i.e., default constructed message objects will be returned, which saves space if the actual messages include large arrays) |
WarehouseClientException | if any of the service calls involved fails |
The | return value is a pair of iterators, that models Boost single pass range. In other words, you can use the iterators in loops and STL operations, or use the returned range directly in something like BOOST_FOREACH. The iterators lazily pull messages from the warehouse as needed. |
Can conceivably get stuck if the warehouse dies during the interaction
unsigned warehouse::Collection< M >::removeMessages | ( | const std::vector< Condition > & | conditions | ) |
Remove messages from a collection.
Number | of messages removed |
WarehouseClientException |
ImplPtr warehouse::Collection< M >::impl_ [private] |
Definition at line 146 of file collection.h.