COMMS
Template library intended to help with implementation of communication protocols.
iterator.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 - 2024 (C). Alex Robenko. All rights reserved.
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 
8 #pragma once
9 
12 
13 #include "comms/details/ReadIteratorHelper.h"
14 #include "comms/details/WriteIteratorHelper.h"
15 
16 namespace comms
17 {
18 
23 template <typename TMessage, typename TIter>
24 auto readIteratorFor(TIter&& iter) -> decltype(details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
25 {
26  return details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
27 }
28 
34 template <typename TMessage, typename TIter>
35 auto readIteratorFor(TMessage&& msg, TIter&& iter) ->
36  decltype(details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
37 {
38  static_cast<void>(msg);
39  return details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
40 }
41 
46 template <typename TMessage, typename TIter>
47 auto writeIteratorFor(TIter&& iter) -> decltype(details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
48 {
49  return details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
50 }
51 
57 template <typename TMessage, typename TIter>
58 auto writeIteratorFor(TMessage&& msg, TIter&& iter) ->
59  decltype(details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
60 {
61  static_cast<void>(msg);
62  return details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
63 }
64 
65 } // namespace comms
Main namespace for all classes / functions of COMMS library.
auto readIteratorFor(TIter &&iter) -> decltype(details::ReadIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message read.
Definition: iterator.h:24
auto writeIteratorFor(TIter &&iter) -> decltype(details::WriteIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message write.
Definition: iterator.h:47