$search

mongo_ros::MessageCollection< M > Class Template Reference

#include <message_collection.h>

List of all members.

Public Member Functions

unsigned count ()
 Count messages in collection.
MessageCollectionensureIndex (const std::string &field)
MessageWithMetadata< M >::ConstPtr findOne (const Query &query, bool metadata_only=false) const
 Convenience function that returns a single matching result for the query.
void insert (const M &msg, const Metadata &metadata=Metadata())
 Insert a ROS message, together with some optional metadata, into the db.
 MessageCollection (const std::string &db_name, const std::string &collection_name, const std::string &db_host="", const unsigned db_port=0)
 Will connect to given database and collection. Collection is created if it doesn't exist.
void modifyMetadata (const Query &q, const Metadata &m)
 Modify metadata Find message matching q and update its metadata using m In other words, overwrite keys in the message using m, but keep keys that don't occur in m.
std::vector< typename
MessageWithMetadata< M >
::ConstPtr > 
pullAllResults (const mongo::BSONObj &query, bool metadata_only=false, const std::string &sort_by="", bool ascending=true) const
 Convenience function that calls queryResult and puts the results into a vector.
QueryResults< M >::range_t queryResults (const mongo::Query &query, bool metadata_only=false) const
 Version that takes a mongo::Query.
QueryResults< M >::range_t queryResults (const mongo::BSONObj &query, bool metadata_only=false, const std::string &sort_by="", bool ascending=true) const
unsigned removeMessages (const mongo::BSONObj &query)
 Remove messages matching query.

Private Member Functions

void initialize (const std::string &db, const std::string &coll, const std::string &host, unsigned port)

Private Attributes

boost::shared_ptr
< mongo::DBClientConnection > 
conn_
boost::shared_ptr< mongo::GridFS > gfs_
ros::Publisher insertion_pub_
ros::NodeHandle nh_
const std::string ns_

Detailed Description

template<class M>
class mongo_ros::MessageCollection< M >

Represents a collection of ROS Messages stored in a MongoDB database. Each stored message in the db has a unique id, a creation time, and optional additional metadata stored as a dictionary

Definition at line 52 of file message_collection.h.


Constructor & Destructor Documentation

template<class M>
mongo_ros::MessageCollection< M >::MessageCollection ( const std::string &  db_name,
const std::string &  collection_name,
const std::string &  db_host = "",
const unsigned  db_port = 0 
)

Will connect to given database and collection. Collection is created if it doesn't exist.

Parameters:
db_host If provided, will be used instead of looking up the warehouse_host ros parameter.
db_port If provided, will be used instead of looking up the warehouse_port ros parameter.

Member Function Documentation

template<class M >
unsigned mongo_ros::MessageCollection< M >::count (  )  [inline]

Count messages in collection.

Definition at line 237 of file message_collection_impl.h.

template<class M>
MessageCollection& mongo_ros::MessageCollection< M >::ensureIndex ( const std::string &  field  ) 
Postcondition:
Ensure that there's an index on the given field. Note that index on _id and creation_time are always created.
template<class M >
MessageWithMetadata< M >::ConstPtr mongo_ros::MessageCollection< M >::findOne ( const Query query,
bool  metadata_only = false 
) const [inline]

Convenience function that returns a single matching result for the query.

Exceptions:
NoMatchingMessageException 

Definition at line 186 of file message_collection_impl.h.

template<class M>
void mongo_ros::MessageCollection< M >::initialize ( const std::string &  db,
const std::string &  coll,
const std::string &  host,
unsigned  port 
) [private]
template<class M >
void mongo_ros::MessageCollection< M >::insert ( const M &  msg,
const Metadata metadata = Metadata() 
) [inline]

Insert a ROS message, together with some optional metadata, into the db.

Exceptions:
mongo::DBException if unable to insert
Parameters:
metadata Metadata to insert. Note that a unique id field _id and a field creation_time will be autogenerated for all messages.

As a secondary effect, publishes a notification message on the topic warehouse/db/collection/inserts

Get the BSON and id from the metadata

Serialize the message into a buffer

Definition at line 114 of file message_collection_impl.h.

template<class M >
void mongo_ros::MessageCollection< M >::modifyMetadata ( const Query q,
const Metadata m 
) [inline]

Modify metadata Find message matching q and update its metadata using m In other words, overwrite keys in the message using m, but keep keys that don't occur in m.

Definition at line 216 of file message_collection_impl.h.

template<class M>
std::vector<typename MessageWithMetadata<M>::ConstPtr > mongo_ros::MessageCollection< M >::pullAllResults ( const mongo::BSONObj &  query,
bool  metadata_only = false,
const std::string &  sort_by = "",
bool  ascending = true 
) const

Convenience function that calls queryResult and puts the results into a vector.

template<class M >
QueryResults< M >::range_t mongo_ros::MessageCollection< M >::queryResults ( const mongo::Query &  query,
bool  metadata_only = false 
) const [inline]

Version that takes a mongo::Query.

Definition at line 162 of file message_collection_impl.h.

template<class M>
QueryResults<M>::range_t mongo_ros::MessageCollection< M >::queryResults ( const mongo::BSONObj &  query,
bool  metadata_only = false,
const std::string &  sort_by = "",
bool  ascending = true 
) const
Return values:
Iterator range over matching messages
Parameters:
query A metadata object representing a query.
metadata_only If this is true, only retrieve the metadata (returned message objects will just be default constructed)
template<class M >
unsigned mongo_ros::MessageCollection< M >::removeMessages ( const mongo::BSONObj &  query  )  [inline]

Remove messages matching query.

Definition at line 196 of file message_collection_impl.h.


Member Data Documentation

template<class M>
boost::shared_ptr<mongo::DBClientConnection> mongo_ros::MessageCollection< M >::conn_ [private]

Definition at line 125 of file message_collection.h.

template<class M>
boost::shared_ptr<mongo::GridFS> mongo_ros::MessageCollection< M >::gfs_ [private]

Definition at line 126 of file message_collection.h.

template<class M>
ros::Publisher mongo_ros::MessageCollection< M >::insertion_pub_ [private]

Definition at line 128 of file message_collection.h.

template<class M>
ros::NodeHandle mongo_ros::MessageCollection< M >::nh_ [private]

Definition at line 127 of file message_collection.h.

template<class M>
const std::string mongo_ros::MessageCollection< M >::ns_ [private]

Definition at line 124 of file message_collection.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


mongo_ros
Author(s): Bhaskara Marthi
autogenerated on Sat Mar 2 14:18:37 2013