message_collection.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  */
30 
39 #ifndef WAREHOUSE_ROS_MESSAGE_COLLECTION_H
40 #define WAREHOUSE_ROS_MESSAGE_COLLECTION_H
41 
43 
44 namespace warehouse_ros
45 {
47 {
48 public:
49  virtual bool initialize(const std::string& datatype, const std::string& md5) = 0;
50  virtual void insert(char* msg, size_t msg_size, Metadata::ConstPtr metadata) = 0;
51  virtual ResultIteratorHelper::Ptr query(Query::ConstPtr query, const std::string& sort_by = "",
52  bool ascending = true) const = 0;
53  virtual unsigned removeMessages(Query::ConstPtr query) = 0;
54  virtual void modifyMetadata(Query::ConstPtr q, Metadata::ConstPtr m) = 0;
55  virtual unsigned count() = 0;
56  virtual Query::Ptr createQuery() const = 0;
57  virtual Metadata::Ptr createMetadata() const = 0;
58  virtual std::string collectionName() const = 0;
59  virtual ~MessageCollectionHelper() = default;
60 
62 };
63 
67 template <class M>
69 {
70 public:
74 
76  MessageCollection() = default;
77 
83  void insert(const M& msg, Metadata::Ptr metadata);
84 
89  typename QueryResults<M>::range_t query(Query::ConstPtr query, bool metadata_only = false,
90  const std::string& sort_by = "", bool ascending = true) const;
91 
94  std::vector<typename MessageWithMetadata<M>::ConstPtr> queryList(Query::ConstPtr query, bool metadata_only = false,
95  const std::string& sort_by = "",
96  bool ascending = true) const;
97 
101  typename MessageWithMetadata<M>::ConstPtr findOne(Query::ConstPtr query, bool metadata_only = false) const;
102 
105 
111 
113  unsigned count();
114 
117  bool md5SumMatches() const;
118 
119  Query::Ptr createQuery() const;
120 
122 
124  typedef M message_type;
125 
126 private:
128  bool md5sum_matches_ = false;
129 };
130 
131 } // namespace warehouse_ros
132 
134 
135 #endif // include guard
warehouse_ros::MessageCollectionHelper::insert
virtual void insert(char *msg, size_t msg_size, Metadata::ConstPtr metadata)=0
warehouse_ros::MessageCollection::removeMessages
unsigned removeMessages(Query::ConstPtr query)
Remove messages matching query.
Definition: message_collection_impl.hpp:102
boost::shared_ptr< const Metadata >
warehouse_ros::MessageCollection::MessageCollection
MessageCollection()=default
Default constructor.
warehouse_ros::MessageCollection::createQuery
Query::Ptr createQuery() const
Definition: message_collection_impl.hpp:126
warehouse_ros::MessageCollection::count
unsigned count()
Count messages in collection.
Definition: message_collection_impl.hpp:114
warehouse_ros::MessageCollectionHelper::modifyMetadata
virtual void modifyMetadata(Query::ConstPtr q, Metadata::ConstPtr m)=0
warehouse_ros::MessageCollectionHelper::removeMessages
virtual unsigned removeMessages(Query::ConstPtr query)=0
query_results.h
warehouse_ros::MessageCollection
Definition: message_collection.h:68
warehouse_ros::MessageCollection::insert
void insert(const M &msg, Metadata::Ptr metadata)
Insert a ROS message, together with some optional metadata, into the db.
Definition: message_collection_impl.hpp:53
warehouse_ros::MessageCollection::findOne
MessageWithMetadata< M >::ConstPtr findOne(Query::ConstPtr query, bool metadata_only=false) const
Convenience function that returns a single matching result for the query.
Definition: message_collection_impl.hpp:92
warehouse_ros::MessageCollection::createMetadata
Metadata::Ptr createMetadata() const
Definition: message_collection_impl.hpp:132
warehouse_ros::MessageCollectionHelper::collectionName
virtual std::string collectionName() const =0
warehouse_ros::MessageCollectionHelper
Definition: message_collection.h:46
warehouse_ros::MessageCollectionHelper::count
virtual unsigned count()=0
warehouse_ros::MessageCollection::collection_
MessageCollectionHelper::Ptr collection_
Definition: message_collection.h:127
warehouse_ros::QueryResults::range_t
std::pair< ResultIterator< M >, ResultIterator< M > > range_t
Definition: query_results.h:87
warehouse_ros::MessageCollection::Ptr
boost::shared_ptr< MessageCollection< M > > Ptr
Definition: message_collection.h:123
warehouse_ros::MessageCollection::md5SumMatches
bool md5SumMatches() const
Check if the md5 sum of the messages previously stored in the database matches that of the compiled m...
Definition: message_collection_impl.hpp:120
warehouse_ros::MessageCollectionHelper::Ptr
boost::shared_ptr< MessageCollectionHelper > Ptr
Definition: message_collection.h:61
warehouse_ros::MessageCollection::query
QueryResults< M >::range_t query(Query::ConstPtr query, bool metadata_only=false, const std::string &sort_by="", bool ascending=true) const
Definition: message_collection_impl.hpp:71
warehouse_ros::MessageCollectionHelper::createMetadata
virtual Metadata::Ptr createMetadata() const =0
datatype
const char * datatype()
warehouse_ros::MessageCollectionHelper::createQuery
virtual Query::Ptr createQuery() const =0
warehouse_ros::MessageCollection::message_type
M message_type
Definition: message_collection.h:124
warehouse_ros::MessageCollectionHelper::~MessageCollectionHelper
virtual ~MessageCollectionHelper()=default
message_collection_impl.hpp
warehouse_ros
Definition: database_connection.h:44
warehouse_ros::MessageCollection::queryList
std::vector< typename MessageWithMetadata< M >::ConstPtr > queryList(Query::ConstPtr 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.
Definition: message_collection_impl.hpp:82
warehouse_ros::MessageCollection::modifyMetadata
void modifyMetadata(Query::ConstPtr q, Metadata::ConstPtr m)
Modify metadata Find message matching q and update its metadata using m In other words,...
Definition: message_collection_impl.hpp:108
warehouse_ros::MessageCollectionHelper::initialize
virtual bool initialize(const std::string &datatype, const std::string &md5)=0
warehouse_ros::MessageCollection::md5sum_matches_
bool md5sum_matches_
Definition: message_collection.h:128
warehouse_ros::MessageCollectionHelper::query
virtual ResultIteratorHelper::Ptr query(Query::ConstPtr query, const std::string &sort_by="", bool ascending=true) const =0


warehouse_ros
Author(s): Bhaskara Marthi , Connor Brew
autogenerated on Wed Oct 16 2024 02:42:07