include
dataspeed_can_usb
ModuleVersion.h
Go to the documentation of this file.
1
/*********************************************************************
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2015-2020, Dataspeed 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 Dataspeed 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 _DATASPEED_CAN_USB_MODULE_VERSION_H
36
#define _DATASPEED_CAN_USB_MODULE_VERSION_H
37
#include <stdint.h>
38
#include <endian.h>
39
40
// Undefine GNU C system macros that we use for other purposes
41
#ifdef major
42
#undef major
43
#endif
44
#ifdef minor
45
#undef minor
46
#endif
47
48
namespace
dataspeed_can_usb
49
{
50
51
class
ModuleVersion {
52
public
:
53
ModuleVersion
() :
full
(0) {};
54
ModuleVersion
(uint16_t
major
, uint16_t
minor
, uint16_t
build
) :
55
#if __BYTE_ORDER == __LITTLE_ENDIAN
56
build_
(
build
),
minor_
(
minor
),
major_
(
major
),
extra_
(0) {};
57
#elif __BYTE_ORDER == __BIG_ENDIAN
58
extra_
(0),
major_
(
major
),
minor_
(
minor
),
build_
(
build
) {};
59
#endif
60
bool
operator<
(
const
ModuleVersion
& other)
const
{
return
this->
full
< other.full; }
61
bool
operator>
(
const
ModuleVersion
& other)
const
{
return
this->
full
> other.full; }
62
bool
operator<=
(
const
ModuleVersion
& other)
const
{
return
this->
full
<= other.full; }
63
bool
operator>=
(
const
ModuleVersion
& other)
const
{
return
this->
full
>= other.full; }
64
bool
operator==
(
const
ModuleVersion
& other)
const
{
return
this->
full
== other.full; }
65
bool
operator!=
(
const
ModuleVersion
& other)
const
{
return
this->
full
!= other.full; }
66
bool
valid
()
const
{
return
full
!= 0; }
67
uint16_t
major
()
const
{
return
major_
; }
68
uint16_t
minor
()
const
{
return
minor_
; }
69
uint16_t
build
()
const
{
return
build_
; }
70
private
:
71
union
{
72
uint64_t
full
;
73
struct
{
74
#if __BYTE_ORDER == __LITTLE_ENDIAN
75
uint16_t
build_
; uint16_t
minor_
; uint16_t
major_
; uint16_t
extra_
;
76
#elif __BYTE_ORDER == __BIG_ENDIAN
77
uint16_t
extra_
; uint16_t
major_
; uint16_t
minor_
; uint16_t
build_
;
78
#else
79
#error Failed to determine system endianness
80
#endif
81
};
82
};
83
};
84
85
}
// namespace dataspeed_can_usb
86
87
#endif // _DATASPEED_CAN_USB_MODULE_VERSION_H
88
dataspeed_can_usb::ModuleVersion::operator==
bool operator==(const ModuleVersion &other) const
Definition:
ModuleVersion.h:128
dataspeed_can_usb::ModuleVersion::ModuleVersion
ModuleVersion()
Definition:
ModuleVersion.h:117
dataspeed_can_usb::ModuleVersion::minor_
uint16_t minor_
Definition:
ModuleVersion.h:139
dataspeed_can_usb::ModuleVersion::operator>
bool operator>(const ModuleVersion &other) const
Definition:
ModuleVersion.h:125
dataspeed_can_usb::ModuleVersion::operator!=
bool operator!=(const ModuleVersion &other) const
Definition:
ModuleVersion.h:129
dataspeed_can_usb::ModuleVersion::extra_
uint16_t extra_
Definition:
ModuleVersion.h:139
dataspeed_can_usb::ModuleVersion::operator<
bool operator<(const ModuleVersion &other) const
Definition:
ModuleVersion.h:124
dataspeed_can_usb::ModuleVersion::build_
uint16_t build_
Definition:
ModuleVersion.h:139
dataspeed_can_usb::ModuleVersion::build
uint16_t build() const
Definition:
ModuleVersion.h:133
dataspeed_can_usb::ModuleVersion::operator<=
bool operator<=(const ModuleVersion &other) const
Definition:
ModuleVersion.h:126
dataspeed_can_usb::ModuleVersion::valid
bool valid() const
Definition:
ModuleVersion.h:130
dataspeed_can_usb::ModuleVersion::major
uint16_t major() const
Definition:
ModuleVersion.h:131
dataspeed_can_usb::ModuleVersion::major_
uint16_t major_
Definition:
ModuleVersion.h:139
dataspeed_can_usb::ModuleVersion::operator>=
bool operator>=(const ModuleVersion &other) const
Definition:
ModuleVersion.h:127
dataspeed_can_usb
Definition:
CanDriver.h:55
dataspeed_can_usb::ModuleVersion::full
uint64_t full
Definition:
ModuleVersion.h:136
dataspeed_can_usb::ModuleVersion::minor
uint16_t minor() const
Definition:
ModuleVersion.h:132
dataspeed_can_usb
Author(s): Kevin Hallenbeck
autogenerated on Sat Feb 4 2023 03:39:26