ros_message.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright 2016-2017 Davide Faconti
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of Willow Garage, Inc. nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 * *******************************************************************/
00034 
00035 #ifndef ROS_INTROSPECTION_ROSMESSAGE_H
00036 #define ROS_INTROSPECTION_ROSMESSAGE_H
00037 
00038 #include "ros_type_introspection/utils/tree.hpp"
00039 #include "ros_type_introspection/ros_field.hpp"
00040 
00041 namespace RosIntrospection{
00042 
00043 
00044 class ROSMessage{
00045 public:
00046 
00049   ROSMessage(const std::string& msg_def );
00050 
00054   const ROSField& field(size_t index) const { return _fields[index]; }
00055 
00060   const std::vector<ROSField>& fields() const { return _fields; }
00061 
00062   const ROSType& type() const { return _type; }
00063 
00064   void mutateType(const ROSType& new_type ) { _type = new_type; }
00065 
00066   void updateMissingPkgNames(const std::vector<const ROSType *> &all_types);
00067 
00068 private:
00069 
00070   ROSType _type;
00071   std::vector<ROSField> _fields;
00072 };
00073 
00074 typedef details::TreeNode<std::string> StringTreeNode;
00075 typedef details::Tree<std::string> StringTree;
00076 
00077 typedef details::TreeNode<const ROSMessage*> MessageTreeNode;
00078 typedef details::Tree<const ROSMessage*> MessageTree;
00079 
00080 struct ROSMessageInfo
00081 {
00082   StringTree  string_tree;
00083   MessageTree message_tree;
00084   std::vector<ROSMessage> type_list;
00085 };
00086 
00087 //------------------------------------------------
00088 
00089 inline std::ostream& operator<<(std::ostream &os, const ROSMessage& msg )
00090 {
00091   os << msg.type();
00092   return os;
00093 }
00094 
00095 inline std::ostream& operator<<(std::ostream &os, const ROSMessage* msg )
00096 {
00097   os << msg->type();
00098   return os;
00099 }
00100 
00101 
00102 }
00103 
00104 #endif


ros_type_introspection
Author(s): Davide Faconti
autogenerated on Tue May 14 2019 02:49:42