RDMnet  0.3.0
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 <string>
29 #include <utility>
30 #include <vector>
31 #include "etcpal/cpp/uuid.h"
32 #include "rdm/cpp/uid.h"
33 #include "rdmnet/message.h"
34 
35 namespace rdmnet
36 {
40 {
41  RptClientEntry() = default;
42  RptClientEntry(const RdmnetRptClientEntry& c_entry);
44 
45  const char* TypeToCString() const noexcept;
46  std::string TypeToString() const;
47 
49  rdm::Uid uid;
52 };
53 
55 inline RptClientEntry::RptClientEntry(const RdmnetRptClientEntry& c_entry)
56  : cid(c_entry.cid), uid(c_entry.uid), type(c_entry.type), binding_cid(c_entry.binding_cid)
57 {
58 }
59 
62 {
63  cid = c_entry.cid;
64  uid = c_entry.uid;
65  type = c_entry.type;
66  binding_cid = c_entry.binding_cid;
67  return *this;
68 }
69 
71 inline const char* RptClientEntry::TypeToCString() const noexcept
72 {
74 }
75 
78 {
80 }
81 
88 {
89 public:
91  RptClientList() = delete;
93  RptClientList(const RptClientList& other) = delete;
95  RptClientList& operator=(const RptClientList& other) = delete;
96 
97  constexpr RptClientList(const RdmnetRptClientList& c_list) noexcept;
98 
100 
101  constexpr bool more_coming() const noexcept;
102  constexpr const RdmnetRptClientEntry* raw_entry_array() const noexcept;
103  constexpr size_t raw_entry_array_size() const noexcept;
104 
105 private:
106  const RdmnetRptClientList& list_;
107 };
108 
110 constexpr RptClientList::RptClientList(const RdmnetRptClientList& c_list) noexcept : list_(c_list)
111 {
112 }
113 
119 {
120  std::vector<RptClientEntry> to_return;
121  to_return.reserve(list_.num_client_entries);
123  [](const RdmnetRptClientEntry& entry) { return RptClientEntry(entry); });
124  return to_return;
125 }
126 
133 constexpr bool RptClientList::more_coming() const noexcept
134 {
135  return list_.more_coming;
136 }
137 
139 constexpr const RdmnetRptClientEntry* RptClientList::raw_entry_array() const noexcept
140 {
141  return list_.client_entries;
142 }
143 
145 constexpr size_t RptClientList::raw_entry_array_size() const noexcept
146 {
147  return list_.num_client_entries;
148 }
149 }; // namespace rdmnet
150 
151 #endif // RDMNET_CPP_MESSAGE_TYPES_RPT_CLIENT_H_
T back_inserter(T... args)
A list of RPT client entries.
Definition: rpt_client.h:88
std::vector< RptClientEntry > GetClientEntries() const
Copy out the list of client entries.
Definition: rpt_client.h:118
RptClientList()=delete
Not default-constructible.
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:139
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:145
constexpr bool more_coming() const noexcept
This message contains a partial list.
Definition: rpt_client.h:133
RptClientList(const RptClientList &other)=delete
Not copyable - use GetClientEntries() to copy out the data.
rpt_client_type_t
An RPT client type.
Definition: message.h:351
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)
A descriptive structure for an RPT client.
Definition: message.h:362
EtcPalUuid binding_cid
An optional identifier for another component that the client is associated with.
Definition: message.h:366
EtcPalUuid cid
The client's Component Identifier (CID).
Definition: message.h:363
rpt_client_type_t type
Whether the client is a controller or device.
Definition: message.h:365
RdmUid uid
The client's RDM UID.
Definition: message.h:364
A structure that represents a list of RPT Client Entries.
Definition: message.h:398
RdmnetRptClientEntry * client_entries
An array of RPT Client Entries.
Definition: message.h:400
size_t num_client_entries
The size of the client_entries array.
Definition: message.h:402
bool more_coming
This message contains a partial list.
Definition: message.h:409
A descriptive structure for an RPT client.
Definition: rpt_client.h:40
RptClientEntry & operator=(const RdmnetRptClientEntry &c_entry)
Assign an instance of the C RdmnetRptClientEntry type to an instance of this class.
Definition: rpt_client.h:61
std::string TypeToString() const
Get the client's RPT client type (controller or device) as a string.
Definition: rpt_client.h:77
const char * TypeToCString() const noexcept
Get the client's RPT client type (controller or device) as a C-style string.
Definition: rpt_client.h:71
etcpal::Uuid binding_cid
An optional identifier for another component that the client is associated with.
Definition: rpt_client.h:51
etcpal::Uuid cid
The client's Component Identifier (CID).
Definition: rpt_client.h:48
rdm::Uid uid
The client's RDM UID.
Definition: rpt_client.h:49
rpt_client_type_t type
Whether the client is a controller or a device.
Definition: rpt_client.h:50
T transform(T... args)