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 
00161 static inline uuid_msgs::UniqueID toMsg(boost::uuids::uuid const &uu)
00162 {
00163   uuid_msgs::UniqueID msg;
00164   std::copy(uu.begin(), uu.end(), msg.uuid.begin());
00165   return msg;
00166 }
00167 
00176 static inline std::string toHexString(boost::uuids::uuid const &uu)
00177 {
00178   return boost::uuids::to_string(uu);
00179 }
00180 
00186 static inline std::string toHexString(uuid_msgs::UniqueID const &msg)
00187 {
00188   return boost::uuids::to_string(fromMsg(msg));
00189 }
00190 
00191 } // end namespace unique_id
00192 
00193 #endif // _UNIQUE_ID_H_


unique_id
Author(s): Jack O'Quin
autogenerated on Fri Aug 28 2015 13:29:41