message_instance.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 #ifndef ROSBAG_MESSAGE_INSTANCE_H
36 #define ROSBAG_MESSAGE_INSTANCE_H
37 
38 #include <ros/message_traits.h>
39 #include <ros/serialization.h>
40 //#include <ros/ros.h>
41 #include <ros/time.h>
42 
43 #include "rosbag/structures.h"
44 #include "rosbag/macros.h"
45 
46 namespace rosbag {
47 
48 class Bag;
49 
51 
59 class ROSBAG_STORAGE_DECL MessageInstance
60 {
61  friend class View;
62 
63 public:
64  ros::Time const& getTime() const;
65  std::string const& getTopic() const;
66  std::string const& getDataType() const;
67  std::string const& getMD5Sum() const;
68  std::string const& getMessageDefinition() const;
69 
70  boost::shared_ptr<ros::M_string> getConnectionHeader() const;
71 
72  std::string getCallerId() const;
73  bool isLatching() const;
74 
76 
79  template<class T>
80  bool isType() const;
81 
83 
86  template<class T>
87  boost::shared_ptr<T> instantiate() const;
88 
90  template<typename Stream>
91  void write(Stream& stream) const;
92 
94  uint32_t size() const;
95 
96 private:
97  MessageInstance(ConnectionInfo const* connection_info, IndexEntry const& index, Bag const& bag);
98 
99  ConnectionInfo const* connection_info_;
100  IndexEntry const index_entry_;
101  Bag const* bag_;
102 };
103 
104 
105 } // namespace rosbag
106 
107 namespace ros {
108 namespace message_traits {
109 
110 template<>
111 struct MD5Sum<rosbag::MessageInstance>
112 {
113  static const char* value(const rosbag::MessageInstance& m) { return m.getMD5Sum().c_str(); }
114 };
115 
116 template<>
117 struct DataType<rosbag::MessageInstance>
118 {
119  static const char* value(const rosbag::MessageInstance& m) { return m.getDataType().c_str(); }
120 };
121 
122 template<>
123 struct Definition<rosbag::MessageInstance>
124 {
125  static const char* value(const rosbag::MessageInstance& m) { return m.getMessageDefinition().c_str(); }
126 };
127 
128 } // namespace message_traits
129 
130 namespace serialization
131 {
132 
133 template<>
134 struct Serializer<rosbag::MessageInstance>
135 {
136  template<typename Stream>
137  inline static void write(Stream& stream, const rosbag::MessageInstance& m) {
138  m.write(stream);
139  }
140 
141  inline static uint32_t serializedLength(const rosbag::MessageInstance& m) {
142  return m.size();
143  }
144 };
145 
146 } // namespace serialization
147 
148 } // namespace ros
149 
150 #include "rosbag/bag.h"
151 
152 namespace rosbag {
153 
154 template<class T>
157  return md5sum == std::string("*") || md5sum == getMD5Sum();
158 }
159 
160 template<class T>
162  if (!isType<T>())
163  return boost::shared_ptr<T>();
164 
165  return bag_->instantiateBuffer<T>(index_entry_);
166 }
167 
168 template<typename Stream>
169 void MessageInstance::write(Stream& stream) const {
171 }
172 
173 } // namespace rosbag
174 
175 #endif
md5sum
const char * md5sum()
rosbag::Bag
Definition: bag.h:131
boost::shared_ptr< ros::M_string >
rosbag::MessageInstance
A class pointing into a bag file.
Definition: message_instance.h:91
ros
rosbag::MessageInstance::write
void write(Stream &stream) const
Write serialized message contents out to a stream.
Definition: message_instance.h:169
time.h
rosbag::Bag::instantiateBuffer
boost::shared_ptr< T > instantiateBuffer(IndexEntry const &index_entry) const
deserializes the message held in record_buffer_
Definition: bag.h:431
ros::serialization::Serializer< rosbag::MessageInstance >::write
static void write(Stream &stream, const rosbag::MessageInstance &m)
Definition: message_instance.h:137
ros::serialization::Serializer< rosbag::MessageInstance >::serializedLength
static uint32_t serializedLength(const rosbag::MessageInstance &m)
Definition: message_instance.h:141
ros::serialization::Stream
ros::message_traits::DataType
macros.h
rosbag::ConnectionInfo
Definition: structures.h:79
rosbag::MessageInstance::getMD5Sum
std::string const & getMD5Sum() const
Definition: message_instance.cpp:46
structures.h
rosbag::MessageInstance::isType
bool isType() const
Test whether the underlying message of the specified type.
Definition: message_instance.h:155
message_traits.h
ros::message_traits::MD5Sum< rosbag::MessageInstance >::value
static const char * value(const rosbag::MessageInstance &m)
Definition: message_instance.h:113
ros::message_traits::MD5Sum::value
static const char * value()
serialization.h
ros::message_traits::DataType< rosbag::MessageInstance >::value
static const char * value(const rosbag::MessageInstance &m)
Definition: message_instance.h:119
ros::message_traits::MD5Sum
ROSBAG_STORAGE_DECL
#define ROSBAG_STORAGE_DECL
Definition: macros.h:50
ros::message_traits::Definition< rosbag::MessageInstance >::value
static const char * value(const rosbag::MessageInstance &m)
Definition: message_instance.h:125
bag.h
rosbag::IndexEntry
Definition: structures.h:108
rosbag::MessageInstance::size
uint32_t size() const
Size of serialized message.
Definition: message_instance.cpp:61
rosbag::MessageInstance::bag_
Bag const * bag_
Definition: message_instance.h:133
rosbag::MessageInstance::index_entry_
const IndexEntry index_entry_
Definition: message_instance.h:132
rosbag::Bag::readMessageDataIntoStream
void readMessageDataIntoStream(IndexEntry const &index_entry, Stream &stream) const
Definition: bag.h:403
ros::Time
rosbag::Stream
Definition: stream.h:100
rosbag::MessageInstance::getMessageDefinition
std::string const & getMessageDefinition() const
Definition: message_instance.cpp:47
rosbag::MessageInstance::instantiate
boost::shared_ptr< T > instantiate() const
Templated call to instantiate a message.
Definition: message_instance.h:161
rosbag
Definition: aes_encryptor.h:43
ros::message_traits::Definition
rosbag::MessageInstance::getDataType
std::string const & getDataType() const
Definition: message_instance.cpp:45
ros::serialization::Serializer


rosbag_storage
Author(s): Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:52