Skip to content

Commit af9186a

Browse files
committed
chore: rename type aliases
1 parent 1646641 commit af9186a

20 files changed

+134
-67
lines changed

libs/core/include/rtbot/BinaryJoin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct BinaryJoin : public Join<T, V> {
2323
this->addOutput("o1");
2424
}
2525

26-
PortPayload<T, V> processData() override {
27-
PortPayload<T, V> outputMsgs;
26+
OperatorMessage<T, V> processData() override {
27+
OperatorMessage<T, V> outputMsgs;
2828
Message<T, V> m1 = this->getDataInputMessage("i2", 0);
2929
Message<T, V> m0 = this->getDataInputMessage("i1", 0);
3030
Message<T, V> out;
@@ -33,7 +33,7 @@ struct BinaryJoin : public Join<T, V> {
3333
if (!result.has_value()) return {};
3434
out.value = result.value();
3535

36-
Messages<T, V> v;
36+
PortMessage<T, V> v;
3737
v.push_back(out);
3838
outputMsgs.emplace("o1", v);
3939

libs/core/include/rtbot/Collector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct Collector : public Operator<T, V> {
1212

1313
string typeName() const override { return "Collector"; }
1414

15-
PortPayload<T, V> processData() override { return {}; }
15+
OperatorMessage<T, V> processData() override { return {}; }
1616
};
1717

1818
} // end namespace rtbot

libs/core/include/rtbot/Composite.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ struct Composite : public Operator<T, V> // TODO: improve from chain to graph
309309
throw std::runtime_error(typeName() + ": the input operator have not been found");
310310
}
311311

312-
virtual OperatorPayload<T, V> executeData() override {
312+
virtual ProgramMessage<T, V> executeData() override {
313313
if (this->input != nullptr)
314314
return this->input.get()->executeData();
315315
else
@@ -323,16 +323,16 @@ struct Composite : public Operator<T, V> // TODO: improve from chain to graph
323323
throw std::runtime_error(typeName() + ": the input operator have not been found");
324324
}
325325

326-
virtual OperatorPayload<T, V> executeControl() override {
326+
virtual ProgramMessage<T, V> executeControl() override {
327327
if (this->input != nullptr)
328328
return this->input.get()->executeControl();
329329
else
330330
throw std::runtime_error(typeName() + ": the input operator have not been found");
331331
}
332332

333-
virtual PortPayload<T, V> processData() override { return {}; }
333+
virtual OperatorMessage<T, V> processData() override { return {}; }
334334

335-
virtual PortPayload<T, V> processControl() override { return {}; }
335+
virtual OperatorMessage<T, V> processControl() override { return {}; }
336336

337337
virtual Operator<T, V> *connect(Operator<T, V> &child, string outputPort = "", string inputPort = "") override {
338338
if (this->output != nullptr)

libs/core/include/rtbot/Demultiplexer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Demultiplexer : public Operator<T, V> {
4040
throw std::runtime_error(typeName() + ": " + inputPort + " refers to a non existing input data port");
4141
}
4242

43-
virtual OperatorPayload<T, V> executeData() override {
43+
virtual ProgramMessage<T, V> executeData() override {
4444
auto toEmit = processData();
4545
if (!toEmit.empty()) return this->emit(toEmit);
4646
return {};
@@ -61,21 +61,21 @@ class Demultiplexer : public Operator<T, V> {
6161
throw std::runtime_error(typeName() + ": " + inputPort + " : refers to a non existing input control port");
6262
}
6363

64-
virtual OperatorPayload<T, V> executeControl() override {
64+
virtual ProgramMessage<T, V> executeControl() override {
6565
auto toEmit = processControl();
6666
if (!toEmit.empty()) return this->emit(toEmit);
6767
return {};
6868
}
6969

70-
virtual PortPayload<T, V> processData() { return join(); }
70+
virtual OperatorMessage<T, V> processData() { return join(); }
7171

72-
virtual PortPayload<T, V> processControl() { return join(); }
72+
virtual OperatorMessage<T, V> processControl() { return join(); }
7373

7474
private:
7575
map<string, string> controlMap;
7676

77-
PortPayload<T, V> join() {
78-
PortPayload<T, V> outputMsgs;
77+
OperatorMessage<T, V> join() {
78+
OperatorMessage<T, V> outputMsgs;
7979

8080
vector<string> in = this->getDataInputs();
8181
string inputPort;
@@ -105,7 +105,7 @@ class Demultiplexer : public Operator<T, V> {
105105
if (instructions == this->getNumControlInputs()) {
106106
for (auto it = this->controlInputs.begin(); it != this->controlInputs.end(); ++it) {
107107
if (it->second.front().value == 1) {
108-
Messages<T, V> v;
108+
PortMessage<T, V> v;
109109
v.push_back(this->dataInputs.find(inputPort)->second.front());
110110
outputMsgs.emplace(this->controlMap.find(it->first)->second, v);
111111
}

libs/core/include/rtbot/FilterByValue.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ struct FilterByValue : public Operator<T, V> {
2020
this->addOutput("o1");
2121
}
2222

23-
PortPayload<T, V> processData() override {
23+
OperatorMessage<T, V> processData() override {
2424
string inputPort;
2525
auto in = this->getDataInputs();
2626
if (in.size() == 1)
2727
inputPort = in.at(0);
2828
else
2929
throw runtime_error(this->typeName() + " : more than 1 input port found");
30-
PortPayload<T, V> outputMsgs;
30+
OperatorMessage<T, V> outputMsgs;
3131
Message<T, V> out = this->getDataInputLastMessage(inputPort);
3232
if (filter(out.value)) {
33-
Messages<T, V> v;
33+
PortMessage<T, V> v;
3434
v.push_back(out);
3535
outputMsgs.emplace("o1", v);
3636
return outputMsgs;

libs/std/include/rtbot/std/Add.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ struct Add : public Operator<T, V> {
1616
this->value = value;
1717
}
1818
string typeName() const override { return "Add"; }
19-
PortPayload<T, V> processData() override {
19+
OperatorMessage<T, V> processData() override {
2020
string inputPort;
2121
auto in = this->getDataInputs();
2222
if (in.size() == 1)
2323
inputPort = in.at(0);
2424
else
2525
throw runtime_error(typeName() + " : more than 1 input port found");
26-
PortPayload<T, V> outputMsgs;
26+
OperatorMessage<T, V> outputMsgs;
2727
Message<T, V> out = this->getDataInputLastMessage(inputPort);
2828
out.value = out.value + this->value;
29-
Messages<T, V> v;
29+
PortMessage<T, V> v;
3030
v.push_back(out);
3131
outputMsgs.emplace("o1", v);
3232
return outputMsgs;

libs/std/include/rtbot/std/AutoRegressive.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct AutoRegressive : public Operator<T, V> {
3737
throw runtime_error(typeName() + ": " + inputPort + " refers to a non existing input port");
3838
}
3939

40-
virtual OperatorPayload<T, V> executeData() override {
40+
virtual ProgramMessage<T, V> executeData() override {
4141
string inputPort;
4242
auto in = this->getDataInputs();
4343
if (in.size() == 1)
@@ -51,7 +51,7 @@ struct AutoRegressive : public Operator<T, V> {
5151
return this->emit(toEmit);
5252
}
5353

54-
virtual PortPayload<T, V> processData() override {
54+
virtual OperatorMessage<T, V> processData() override {
5555
string inputPort;
5656
auto in = this->getDataInputs();
5757
if (in.size() == 1)
@@ -61,8 +61,8 @@ struct AutoRegressive : public Operator<T, V> {
6161
size_t n = this->getDataInputMaxSize(inputPort);
6262
Message<T, V> out = this->getDataInputLastMessage(inputPort);
6363
for (auto i = 0; i < n; i++) out.value += this->coeff[i] * this->getDataInputMessage(inputPort, i).value;
64-
PortPayload<T, V> toEmit;
65-
Messages<T, V> v;
64+
OperatorMessage<T, V> toEmit;
65+
PortMessage<T, V> v;
6666
v.push_back(out);
6767
toEmit.emplace("o1", v);
6868
return toEmit;

libs/std/include/rtbot/std/Constant.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ struct Constant : public Operator<T, V> {
1616
this->value = value;
1717
}
1818
string typeName() const override { return "Constant"; }
19-
PortPayload<T, V> processData() override {
19+
OperatorMessage<T, V> processData() override {
2020
string inputPort;
2121
auto in = this->getDataInputs();
2222
if (in.size() == 1)
2323
inputPort = in.at(0);
2424
else
2525
throw runtime_error(typeName() + " : more than 1 input port found");
26-
PortPayload<T, V> outputMsgs;
26+
OperatorMessage<T, V> outputMsgs;
2727
Message<T, V> out = this->getDataInputLastMessage(inputPort);
2828
out.value = this->value;
29-
Messages<T, V> v;
29+
PortMessage<T, V> v;
3030
v.push_back(out);
3131
outputMsgs.emplace("o1", v);
3232
return outputMsgs;

libs/std/include/rtbot/std/CosineResampler.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,34 @@ struct CosineResampler : public Operator<T, V> {
2626
this->addOutput("o1");
2727
}
2828

29+
virtual Bytes collect() {
30+
Bytes bytes = Operator<T, V>::collect();
31+
32+
// Serialize carryOver
33+
bytes.insert(bytes.end(), reinterpret_cast<const unsigned char *>(&carryOver),
34+
reinterpret_cast<const unsigned char *>(&carryOver) + sizeof(carryOver));
35+
36+
return bytes;
37+
}
38+
39+
virtual void restore(Bytes::const_iterator &it) {
40+
Operator<T, V>::restore(it);
41+
// Deserialize carryOver
42+
carryOver = *reinterpret_cast<const T *>(&(*it));
43+
it += sizeof(carryOver);
44+
}
45+
2946
string typeName() const override { return "CosineResampler"; }
3047

31-
PortPayload<T, V> processData() override {
48+
OperatorMessage<T, V> processData() override {
3249
string inputPort;
3350
auto in = this->getDataInputs();
3451
if (in.size() == 1)
3552
inputPort = in.at(0);
3653
else
3754
throw runtime_error(typeName() + " : more than 1 input port found");
38-
PortPayload<T, V> outputMsgs;
39-
Messages<T, V> toEmit;
55+
OperatorMessage<T, V> outputMsgs;
56+
PortMessage<T, V> toEmit;
4057

4158
int j = 1;
4259

libs/std/include/rtbot/std/Count.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,49 @@ using namespace std;
1010
template <class T, class V>
1111
struct Count : public Operator<T, V> {
1212
size_t count;
13+
1314
Count() = default;
15+
1416
Count(string const &id) : Operator<T, V>(id) {
1517
this->count = 0;
1618
this->addDataInput("i1", 1);
1719
this->addOutput("o1");
1820
}
21+
22+
virtual Bytes collect() {
23+
Bytes bytes = Operator<T, V>::collect();
24+
// Serialize count
25+
bytes.insert(bytes.end(), reinterpret_cast<const unsigned char *>(&count),
26+
reinterpret_cast<const unsigned char *>(&count) + sizeof(count));
27+
return bytes;
28+
}
29+
30+
virtual void restore(Bytes::const_iterator &it) {
31+
Operator<T, V>::restore(it);
32+
// Deserialize count
33+
count = *reinterpret_cast<const size_t *>(&(*it));
34+
it += sizeof(count);
35+
}
36+
1937
string typeName() const override { return "Count"; }
20-
PortPayload<T, V> processData() override {
38+
39+
string debug() {
40+
string s = "count: " + to_string(count);
41+
return Operator<T, V>::debug(s);
42+
}
43+
44+
OperatorMessage<T, V> processData() override {
2145
string inputPort;
2246
auto in = this->getDataInputs();
2347
if (in.size() == 1)
2448
inputPort = in.at(0);
2549
else
2650
throw runtime_error(typeName() + " : more than 1 input port found");
27-
PortPayload<T, V> outputMsgs;
51+
OperatorMessage<T, V> outputMsgs;
2852
Message<T, V> out = this->getDataInputLastMessage(inputPort);
2953
this->count = this->count + 1;
3054
out.value = this->count;
31-
Messages<T, V> v;
55+
PortMessage<T, V> v;
3256
v.push_back(out);
3357
outputMsgs.emplace("o1", v);
3458
return outputMsgs;

0 commit comments

Comments
 (0)