Skip to content

Commit e4e233c

Browse files
committed
Documentation
1 parent d6ae2b9 commit e4e233c

File tree

20 files changed

+165
-21
lines changed

20 files changed

+165
-21
lines changed

doc/layout.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@
1010
<tab type="modulelist" visible="yes" title="" intro=""/>
1111
<tab type="modulemembers" visible="yes" title="" intro=""/>
1212
</tab>
13-
<tab type="namespaces" visible="yes" title="">
13+
<tab type="namespaces" visible="no" title="">
1414
<tab type="namespacelist" visible="yes" title="" intro=""/>
1515
<tab type="namespacemembers" visible="yes" title="" intro=""/>
1616
</tab>
17-
<tab type="concepts" visible="yes" title="">
17+
<tab type="concepts" visible="no" title="">
1818
</tab>
19-
<tab type="interfaces" visible="yes" title="">
19+
<tab type="interfaces" visible="no" title="">
2020
<tab type="interfacelist" visible="yes" title="" intro=""/>
2121
<tab type="interfaceindex" visible="$ALPHABETICAL_INDEX" title=""/>
2222
<tab type="interfacehierarchy" visible="yes" title="" intro=""/>
2323
</tab>
24-
<tab type="classes" visible="yes" title="">
24+
<tab type="classes" visible="no" title="">
2525
<tab type="classlist" visible="yes" title="" intro=""/>
2626
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
2727
<tab type="hierarchy" visible="yes" title="" intro=""/>
2828
<tab type="classmembers" visible="yes" title="" intro=""/>
2929
</tab>
30-
<tab type="structs" visible="yes" title="">
30+
<tab type="structs" visible="no" title="">
3131
<tab type="structlist" visible="yes" title="" intro=""/>
3232
<tab type="structindex" visible="$ALPHABETICAL_INDEX" title=""/>
3333
</tab>
34-
<tab type="exceptions" visible="yes" title="">
34+
<tab type="exceptions" visible="no" title="">
3535
<tab type="exceptionlist" visible="yes" title="" intro=""/>
3636
<tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/>
3737
<tab type="exceptionhierarchy" visible="yes" title="" intro=""/>
3838
</tab>
39-
<tab type="files" visible="yes" title="">
39+
<tab type="files" visible="no" title="">
4040
<tab type="filelist" visible="yes" title="" intro=""/>
4141
<tab type="globals" visible="yes" title="" intro=""/>
4242
</tab>

include/scl/argparser.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,21 @@ class ProgramOptions {
124124
std::unordered_map<std::string_view, bool> m_flags;
125125
};
126126

127+
/**
128+
* @brief Get a command-line provided option as a boolean.
129+
*/
127130
template <>
128131
bool ProgramOptions::get<bool>(std::string_view name) const;
129132

133+
/**
134+
* @brief Get a command-line provided option as an int.
135+
*/
130136
template <>
131137
int ProgramOptions::get<int>(std::string_view name) const;
132138

139+
/**
140+
* @brief Get a command-line provided option as an std::string.
141+
*/
133142
template <>
134143
std::size_t ProgramOptions::get<std::size_t>(std::string_view name) const;
135144

include/scl/bitmap.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,24 @@ class Bitmap {
266266
*/
267267
template <>
268268
struct Serializer<Bitmap> {
269+
270+
/**
271+
* @brief Returns the size of a bitmap.
272+
*/
269273
static std::size_t sizeOf(const Bitmap& bm) {
270274
return Serializer<Bitmap::ContainerType>::sizeOf(bm.m_bits);
271275
}
276+
277+
/**
278+
* @brief Write the bitmap to a buffer.
279+
*/
272280
static std::size_t write(const Bitmap& bm, unsigned char* buf) {
273281
return Serializer<Bitmap::ContainerType>::write(bm.m_bits, buf);
274282
}
283+
284+
/**
285+
* @brief Reads a bitmap from a buffer.
286+
*/
275287
static std::size_t read(Bitmap& bm, const unsigned char* buf) {
276288
return Serializer<Bitmap::ContainerType>::read(bm.m_bits, buf);
277289
}

include/scl/coro/promise.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <utility>
2424
#include <variant>
2525

26-
#include "scl/coro/batch.h"
2726
#include "scl/coro/future.h"
2827
#include "scl/coro/sleep_awaiter.h"
2928

include/scl/coro/runtime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <functional>
2222
#include <list>
2323

24-
#include "scl/coro/batch.h"
2524
#include "scl/coro/future.h"
2625
#include "scl/coro/promise.h"
2726
#include "scl/coro/sleep_awaiter.h"

include/scl/coro/task.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <coroutine>
2121
#include <utility>
2222

23-
#include "scl/coro/batch.h"
2423
#include "scl/coro/promise.h"
2524

2625
namespace scl {

include/scl/net/tcp/network.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#pragma once
1919

2020
#include "scl/coro/task.h"
21-
#include "scl/net/config.h"
2221
#include "scl/net/network.h"
22+
#include "scl/net/tcp/config.h"
2323

2424
namespace scl {
2525

include/scl/protocol.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,22 @@ struct Result {
140140
return Result{.next = std::move(next), .output = output};
141141
}
142142

143+
/**
144+
* @brief A pointer to the next Protocol to run.
145+
*/
143146
std::unique_ptr<Protocol> next;
147+
148+
/**
149+
* @brief The protocols output.
150+
*/
144151
std::any output;
145152
};
146153

147154
/**
148155
* @brief Run a protocol.
156+
*
157+
* This function runs a protocol. A provided callback is invoked every time the
158+
* protocol produces an output.
149159
*/
150160
template <typename CALLBACK>
151161
Task<void> runProtocol(std::unique_ptr<Protocol> protocol,
@@ -162,6 +172,14 @@ Task<void> runProtocol(std::unique_ptr<Protocol> protocol,
162172
}
163173
}
164174

175+
/**
176+
* @brief Run a protocol that returns a value.
177+
*
178+
* This function runs a protocol, returning the non-void value returned by its
179+
* last step.
180+
*
181+
* @throws std::runtime_error if the provided protocol has no output.
182+
*/
165183
template <typename R>
166184
Task<R> runProtocol(std::unique_ptr<Protocol> protocol, Env& env) {
167185
Result result;

include/scl/serialization.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,25 @@ concept Serializable =
7575
template <typename T>
7676
requires(std::is_trivially_copyable_v<T>)
7777
struct Serializer<T> {
78+
79+
/**
80+
* @brief Determine the size of a value.
81+
*/
7882
static constexpr std::size_t sizeOf(const T& /* ignored */) {
7983
return sizeof(T);
8084
}
8185

86+
/**
87+
* @brief Write the value to a buffer.
88+
*/
8289
static constexpr std::size_t write(const T& obj, unsigned char* out) {
8390
std::memcpy(out, &obj, sizeof(T));
8491
return sizeOf(obj);
8592
}
8693

94+
/**
95+
* @brief Read a value from a buffer.
96+
*/
8797
static constexpr std::size_t read(T& obj, const unsigned char* in) {
8898
std::memcpy(&obj, in, sizeof(T));
8999
return sizeOf(obj);
@@ -95,8 +105,16 @@ struct Serializer<T> {
95105
*/
96106
template <Serializable T>
97107
struct Serializer<std::vector<T>> {
108+
109+
/**
110+
* @brief Type used to denote the size of the vector.
111+
*/
98112
using VecSizeType = std::uint32_t;
99113

114+
115+
/**
116+
* @brief Get the bytes required to write \p vec with this serializer.
117+
*/
100118
static constexpr std::size_t sizeOf(const std::vector<T>& vec) {
101119
auto total_size = sizeof(VecSizeType);
102120
for (const auto& v : vec) {
@@ -105,6 +123,9 @@ struct Serializer<std::vector<T>> {
105123
return total_size;
106124
}
107125

126+
/**
127+
* @brief Write a vector to a buffer.
128+
*/
108129
static constexpr std::size_t write(const std::vector<T>& vec,
109130
unsigned char* out) {
110131
const auto vec_size = static_cast<VecSizeType>(vec.size());
@@ -115,6 +136,9 @@ struct Serializer<std::vector<T>> {
115136
return written;
116137
}
117138

139+
/**
140+
* @brief Read a vector from a buffer.
141+
*/
118142
static constexpr std::size_t read(std::vector<T>& vec,
119143
const unsigned char* in) {
120144
VecSizeType vec_size = 0;

include/scl/simulation/channel.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@
2525

2626
namespace scl::details {
2727

28+
/**
29+
* @brief Channel implementation for simulations.
30+
* @ingroup net-sim
31+
*
32+
* SimulatedChannel implements Channel for non-local parties in simulations. The
33+
* main responsibilities of this class are (1) calling a Transport object with
34+
* the stuff to be sent/received, and (2) generating the right Events.
35+
*/
2836
class SimulatedChannel final : public Channel {
2937
public:
38+
/**
39+
* @brief Create a new SimulatedChannel.
40+
*/
3041
static std::shared_ptr<Channel> create(ChannelId id,
3142
Context ctx,
3243
std::shared_ptr<Transport> transport) {
@@ -36,19 +47,44 @@ class SimulatedChannel final : public Channel {
3647
SimulatedChannel(ChannelId id,
3748
Context ctx,
3849
std::shared_ptr<Transport> transport)
39-
: m_id(id), m_ctx(ctx), m_transport(transport) {}
50+
: m_id(id), m_ctx(ctx), m_transport(transport), m_closed(false) {}
4051

52+
/**
53+
* @brief Closes the channel.
54+
*/
4155
void close() override;
56+
57+
/**
58+
* @brief Send a packet.
59+
*/
4260
Task<void> send(Packet&& packet) override;
61+
62+
/**
63+
* @brief Send a packet.
64+
*/
4365
Task<void> send(const Packet& packet) override;
66+
67+
/**
68+
* @brief Recv a packet.
69+
*/
4470
Task<Packet> recv() override;
71+
72+
/**
73+
* @brief Attempt to receive a packet within a provied timeout.
74+
*/
4575
Task<std::optional<Packet>> recv(Time::Duration timeout) override;
76+
77+
/**
78+
* @brief Poll the channel for data.
79+
*/
4680
Task<bool> poll() override;
4781

4882
private:
4983
ChannelId m_id;
5084
Context m_ctx;
5185
std::shared_ptr<Transport> m_transport;
86+
87+
bool m_closed;
5288
};
5389

5490
} // namespace scl::details

0 commit comments

Comments
 (0)