-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We actually do need this to break the cyclic dependency between `RealTime.hpp` and `FramLayout.hpp`.
- Loading branch information
Showing
6 changed files
with
95 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
|
||
#include <Sts1CobcSw/Serial/Serial.hpp> | ||
|
||
#include <strong_type/affine_point.hpp> | ||
#include <strong_type/difference.hpp> | ||
#include <strong_type/equality.hpp> | ||
#include <strong_type/ordered.hpp> | ||
#include <strong_type/type.hpp> | ||
|
||
#include <bit> | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
|
||
namespace sts1cobcsw | ||
{ | ||
using Duration = strong:: | ||
type<std::int64_t, struct DurationTag, strong::difference, strong::default_constructible>; | ||
using RodosTime = strong::type<std::int64_t, | ||
struct RodosTimeTag, | ||
strong::affine_point<Duration>, | ||
strong::default_constructible, | ||
strong::equality, | ||
strong::strongly_ordered>; | ||
using RealTime = strong::type<std::int32_t, | ||
struct RealTimeTag, | ||
strong::default_constructible, | ||
strong::equality, | ||
strong::strongly_ordered>; | ||
|
||
|
||
template<> | ||
inline constexpr std::size_t serialSize<RealTime> = | ||
totalSerialSize<strong::underlying_type_t<RealTime>>; | ||
template<> | ||
inline constexpr std::size_t serialSize<Duration> = | ||
totalSerialSize<strong::underlying_type_t<Duration>>; | ||
|
||
|
||
template<std::endian endianness> | ||
[[nodiscard]] auto SerializeTo(void * destination, RealTime const & data) -> void *; | ||
template<std::endian endianness> | ||
[[nodiscard]] auto DeserializeFrom(void const * source, RealTime * data) -> void const *; | ||
template<std::endian endianness> | ||
[[nodiscard]] auto SerializeTo(void * destination, Duration const & data) -> void *; | ||
template<std::endian endianness> | ||
[[nodiscard]] auto DeserializeFrom(void const * source, Duration * data) -> void const *; | ||
} | ||
|
||
|
||
#include <Sts1CobcSw/Utility/TimeTypes.ipp> // IWYU pragma: keep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
|
||
#include <Sts1CobcSw/Utility/TimeTypes.hpp> | ||
|
||
|
||
namespace sts1cobcsw | ||
{ | ||
template<std::endian endianness> | ||
inline auto SerializeTo(void * destination, RealTime const & data) -> void * | ||
{ | ||
return SerializeTo<endianness>(destination, value_of(data)); | ||
} | ||
|
||
|
||
template<std::endian endianness> | ||
inline auto DeserializeFrom(void const * source, RealTime * data) -> void const * | ||
{ | ||
source = DeserializeFrom<endianness>(source, &(value_of(*data))); | ||
return source; | ||
} | ||
|
||
|
||
template<std::endian endianness> | ||
inline auto SerializeTo(void * destination, Duration const & data) -> void * | ||
{ | ||
return SerializeTo<endianness>(destination, value_of(data)); | ||
} | ||
|
||
|
||
template<std::endian endianness> | ||
inline auto DeserializeFrom(void const * source, Duration * data) -> void const * | ||
{ | ||
source = DeserializeFrom<endianness>(source, &(value_of(*data))); | ||
return source; | ||
} | ||
} |