version_info.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Ifdefs
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_VERSION_HPP_
14 #define KOBUKI_VERSION_HPP_
15 
16 /*****************************************************************************
17 ** Includes
18 *****************************************************************************/
19 
20 #include <string>
21 #include <sstream>
22 #include <stdint.h>
23 #include <vector>
24 
25 #include "macros.hpp"
26 
27 /*****************************************************************************
28 ** Namespaces
29 *****************************************************************************/
30 
31 namespace kobuki {
32 
33 /*****************************************************************************
34 ** Interfaces
35 *****************************************************************************/
40 public:
41  VersionInfo(const uint32_t &fw, const uint32_t &hw, const uint32_t udid0_, const uint32_t udid1_, const uint32_t udid2_ ) :
42  firmware(fw),
43  hardware(hw),
44  software(0),
45  udid0(udid0_),
46  udid1(udid1_),
47  udid2(udid2_)
48  {}
49  const uint32_t firmware;
50  const uint32_t hardware;
51  const uint32_t software;
52  const uint32_t udid0;
53  const uint32_t udid1;
54  const uint32_t udid2;
55 
56  static int majorVersion(const uint32_t &version) {
57  return ((version & 0x00FF0000) >> 16);
58  }
59 
60  static int minorVersion(const uint32_t &version) {
61  return ((version & 0x0000FF00) >> 8);
62  }
63 
64  static int patchVersion(const uint32_t &version) {
65  return (version & 0x000000FF);
66  }
67 
68  static std::string toString(const uint32_t &version)
69  {
70  // Convert an unsigned int into a string of type <major>.<minor>.<patch>; first byte is ignored
71  std::stringstream ss;
72  ss << majorVersion(version) << "." << minorVersion(version) << "." << patchVersion(version);
73  return std::string(ss.str());
74  }
75 
76  static std::string toString(const std::vector<uint32_t> &versions)
77  {
78  std::stringstream ss;
79  std::size_t number_versions = versions.size();
80  for(std::size_t i = 0; i < number_versions; ++i) {
81  ss << VersionInfo::toString(versions[i]);
82  if (i != (number_versions - 1)) {
83  ss << " / ";
84  }
85  }
86  return std::string(ss.str());
87  }
88 
89  static std::string toString(const uint32_t &udid0, const uint32_t &udid1, const uint32_t &udid2)
90  {
91  // Convert three udid unsigned integers into a string of type <udid0>-<udid1>-<udid2>
92  std::stringstream ss;
93  ss << udid0 << "-" << udid1 << "-" << udid2;
94  return std::string(ss.str());
95  }
96 
97  static std::string getSoftwareVersion();
98 };
99 
100 } // namespace kobuki
101 #endif /* KOBUKI_VERSION_HPP_ */
const uint32_t udid0
const uint32_t udid2
static int majorVersion(const uint32_t &version)
const uint32_t hardware
const uint32_t firmware
static std::string toString(const std::vector< uint32_t > &versions)
const uint32_t udid1
#define kobuki_PUBLIC
Definition: macros.hpp:39
static std::string toString(const uint32_t &version)
Macros for kobuki_driver.
static int patchVersion(const uint32_t &version)
static int minorVersion(const uint32_t &version)
VersionInfo(const uint32_t &fw, const uint32_t &hw, const uint32_t udid0_, const uint32_t udid1_, const uint32_t udid2_)
const uint32_t software
static std::string toString(const uint32_t &udid0, const uint32_t &udid1, const uint32_t &udid2)


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Fri Sep 18 2020 03:22:02