unique_id.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*- */
00002 /*********************************************************************
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (C) 2012 Jack O'Quin
00006 *  All rights reserved.
00007 *
00008 *  Redistribution and use in source and binary forms, with or without
00009 *  modification, are permitted provided that the following conditions
00010 *  are met:
00011 *
00012 *   * Redistributions of source code must retain the above copyright
00013 *     notice, this list of conditions and the following disclaimer.
00014 *   * Redistributions in binary form must reproduce the above
00015 *     copyright notice, this list of conditions and the following
00016 *     disclaimer in the documentation and/or other materials provided
00017 *     with the distribution.
00018 *   * Neither the name of the author nor other contributors may be
00019 *     used to endorse or promote products derived from this software
00020 *     without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 *  POSSIBILITY OF SUCH DAMAGE.
00034 *********************************************************************/
00035 
00036 #ifndef _UNIQUE_ID_H_
00037 #define _UNIQUE_ID_H_ 1
00038 
00046 #include <string>
00047 
00048 #include <boost/uuid/uuid.hpp>
00049 #include <boost/uuid/uuid_io.hpp>
00050 
00051 #include <ros/ros.h>
00052 #include <uuid_msgs/UniqueID.h>
00053 
00054 #include <unique_id/impl/unique_id.h> // private implementation details
00055 
00077 namespace unique_id
00078 {
00079 
00085 static inline boost::uuids::uuid fromMsg(uuid_msgs::UniqueID const &msg)
00086 {
00087   boost::uuids::uuid uu;
00088   std::copy(msg.uuid.begin(), msg.uuid.end(), uu.begin());
00089   return uu;
00090 }
00091 
00100 static inline boost::uuids::uuid fromRandom(void)
00101 {
00102   return impl::genRandom();
00103 }
00104 
00125 static inline boost::uuids::uuid fromHexString(std::string const &str)
00126 {
00127   return impl::genString(str);
00128 }
00129 
00151 static inline boost::uuids::uuid fromURL(std::string const &url)
00152 {
00153   return impl::genURL(url);
00154 }
00155 
00167 static inline boost::uuids::uuid fromTime(ros::Time timestamp, uint64_t hw_addr)
00168 {
00169   return impl::genTime(timestamp, hw_addr);
00170 }
00171 
00177 static inline uuid_msgs::UniqueID toMsg(boost::uuids::uuid const &uu)
00178 {
00179   uuid_msgs::UniqueID msg;
00180   std::copy(uu.begin(), uu.end(), msg.uuid.begin());
00181   return msg;
00182 }
00183 
00192 static inline std::string toHexString(boost::uuids::uuid const &uu)
00193 {
00194   return boost::uuids::to_string(uu);
00195 }
00196 
00202 static inline std::string toHexString(uuid_msgs::UniqueID const &msg)
00203 {
00204   return boost::uuids::to_string(fromMsg(msg));
00205 }
00206 
00207 } // end namespace unique_id
00208 
00209 #endif // _UNIQUE_ID_H_


unique_id
Author(s): Jack O'Quin
autogenerated on Thu Jun 6 2019 20:57:45