RDMnet  HEAD (unstable)
Implementation of ANSI E1.33 (RDMnet)
View other versions:
rpt_client.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************
16  * This file is a part of RDMnet. For more information, go to:
17  * https://github.com/ETCLabs/RDMnet
18  *****************************************************************************/
19 
22 
23 #ifndef RDMNET_CPP_MESSAGE_TYPES_RPT_CLIENT_H_
24 #define RDMNET_CPP_MESSAGE_TYPES_RPT_CLIENT_H_
25 
26 #include <algorithm>
27 #include <cstddef>
28 #include <iterator>
29 #include <string>
30 #include <utility>
31 #include <vector>
32 #include "etcpal/cpp/uuid.h"
33 #include "rdm/cpp/uid.h"
34 #include "rdmnet/message.h"
35 
36 namespace rdmnet
37 {
41 {
42  RptClientEntry() = default;
43  RptClientEntry(const RdmnetRptClientEntry& c_entry);
45 
46  const char* TypeToCString() const noexcept;
47  std::string TypeToString() const;
48 
50  rdm::Uid uid;
53 };
54 
56 inline RptClientEntry::RptClientEntry(const RdmnetRptClientEntry& c_entry)
57  : cid(c_entry.cid), uid(c_entry.uid), type(c_entry.type), binding_cid(c_entry.binding_cid)
58 {
59 }
60 
63 {
64  cid = c_entry.cid;
65  uid = c_entry.uid;
66  type = c_entry.type;
67  binding_cid = c_entry.binding_cid;
68  return *this;
69 }
70 
72 inline const char* RptClientEntry::TypeToCString() const noexcept
73 {
75 }
76 
79 {
81 }
82 
89 {
90 public:
92  RptClientList() = delete;
94  RptClientList(const RptClientList& other) = delete;
96  RptClientList& operator=(const RptClientList& other) = delete;
97 
98  constexpr RptClientList(const RdmnetRptClientList& c_list) noexcept;
99 
101 
102  constexpr bool more_coming() const noexcept;
103  constexpr const RdmnetRptClientEntry* raw_entry_array() const noexcept;
104  constexpr size_t raw_entry_array_size() const noexcept;
105 
106 private:
107  const RdmnetRptClientList& list_;
108 };
109 
111 constexpr RptClientList::RptClientList(const RdmnetRptClientList& c_list) noexcept : list_(c_list)
112 {
113 }
114 
120 {
121  std::vector<RptClientEntry> to_return;
122  to_return.reserve(list_.num_client_entries);
124  [](const RdmnetRptClientEntry& entry) { return RptClientEntry(entry); });
125  return to_return;
126 }
127 
134 constexpr bool RptClientList::more_coming() const noexcept
135 {
136  return list_.more_coming;
137 }
138 
140 constexpr const RdmnetRptClientEntry* RptClientList::raw_entry_array() const noexcept
141 {
142  return list_.client_entries;
143 }
144 
146 constexpr size_t RptClientList::raw_entry_array_size() const noexcept
147 {
148  return list_.num_client_entries;
149 }
150 }; // namespace rdmnet
151 
152 #endif // RDMNET_CPP_MESSAGE_TYPES_RPT_CLIENT_H_
T back_inserter(T... args)
A list of RPT client entries.
Definition: rpt_client.h:89
RptClientList(const RptClientList &other)=delete
Not copyable - use GetClientEntries() to copy out the data.
constexpr size_t raw_entry_array_size() const noexcept
Get the size of the raw array of client entry C structures.
Definition: rpt_client.h:146
constexpr bool more_coming() const noexcept
This message contains a partial list.
Definition: rpt_client.h:134
RptClientList & operator=(const RptClientList &other)=delete
Not copyable - use GetClientEntries() to copy out the data.
constexpr const RdmnetRptClientEntry * raw_entry_array() const noexcept
Get a pointer to the raw array of client entry C structures.
Definition: rpt_client.h:140
std::vector< RptClientEntry > GetClientEntries() const
Copy out the list of client entries.
Definition: rpt_client.h:119
RptClientList()=delete
Not default-constructible.
rpt_client_type_t
Definition: message.h:352
const char * rdmnet_rpt_client_type_to_string(rpt_client_type_t client_type)
Get a string description of an RPT client type.
Definition: message.c:50
Basic types for parsed RDMnet messages.
A namespace which contains all C++ language definitions in the RDMnet library.
Definition: broker.h:45
T reserve(T... args)
Definition: message.h:363
EtcPalUuid cid
Definition: message.h:364
rpt_client_type_t type
Definition: message.h:366
EtcPalUuid binding_cid
Definition: message.h:367
RdmUid uid
Definition: message.h:365
Definition: message.h:399
RdmnetRptClientEntry * client_entries
Definition: message.h:401
bool more_coming
Definition: message.h:410
size_t num_client_entries
Definition: message.h:403
A descriptive structure for an RPT client.
Definition: rpt_client.h:41
RptClientEntry & operator=(const RdmnetRptClientEntry &c_entry)
Assign an instance of the C RdmnetRptClientEntry type to an instance of this class.
Definition: rpt_client.h:62
rdm::Uid uid
The client's RDM UID.
Definition: rpt_client.h:50
const char * TypeToCString() const noexcept
Get the client's RPT client type (controller or device) as a C-style string.
Definition: rpt_client.h:72
std::string TypeToString() const
Get the client's RPT client type (controller or device) as a string.
Definition: rpt_client.h:78
etcpal::Uuid binding_cid
An optional identifier for another component that the client is associated with.
Definition: rpt_client.h:52
rpt_client_type_t type
Whether the client is a controller or a device.
Definition: rpt_client.h:51
etcpal::Uuid cid
The client's Component Identifier (CID).
Definition: rpt_client.h:49
T transform(T... args)