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 
104  unsigned removeMessages(Query::ConstPtr query);
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
virtual unsigned removeMessages(Query::ConstPtr query)=0
virtual void insert(char *msg, size_t msg_size, Metadata::ConstPtr metadata)=0
virtual void modifyMetadata(Query::ConstPtr q, Metadata::ConstPtr m)=0
std::pair< ResultIterator< M >, ResultIterator< M > > range_t
Definition: query_results.h:87
virtual std::string collectionName() const =0
const char * datatype()
boost::shared_ptr< MessageCollectionHelper > Ptr
MessageCollectionHelper::Ptr collection_
boost::shared_ptr< MessageCollection< M > > Ptr
virtual bool initialize(const std::string &datatype, const std::string &md5)=0
virtual Query::Ptr createQuery() const =0
virtual Metadata::Ptr createMetadata() const =0
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 Fri Aug 20 2021 03:00:01