Skip to content

Commit eb1c449

Browse files
Apply expected formatting for C, C++, Java, Python
1 parent a985741 commit eb1c449

36 files changed

+280
-243
lines changed

tutorials/content_filtering/c++11/home_automation_publisher.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "home_automation.hpp"
1717

1818
void publish_sensor(
19-
const std::string& sensor_name,
20-
const std::string& room_name)
19+
const std::string &sensor_name,
20+
const std::string &room_name)
2121
{
2222
dds::domain::DomainParticipant participant(0);
2323
dds::topic::Topic<DeviceStatus> topic(participant, "WindowStatus");

tutorials/content_filtering/c++11/home_automation_subscriber.cxx

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ int main(int argc, char **argv)
3030
rti::sub::SampleProcessor sample_processor;
3131
sample_processor.attach_reader(
3232
reader,
33-
[](const rti::sub::LoanedSample<DeviceStatus>& sample)
34-
{
35-
if (sample.info().valid()) { // ignore samples with only meta-data
33+
[](const rti::sub::LoanedSample<DeviceStatus> &sample) {
34+
if (sample.info().valid()) { // ignore samples with only
35+
// meta-data
3636
std::cout << "WARNING: " << sample.data().sensor_name()
37-
<< " in " << sample.data().room_name()
38-
<< " is open!" << std::endl;
37+
<< " in " << sample.data().room_name()
38+
<< " is open!" << std::endl;
3939
}
4040
});
4141

42-
while (true) { // wait in a loop
42+
while (true) { // wait in a loop
4343
std::this_thread::sleep_for(std::chrono::seconds(4));
4444
}
4545
}

tutorials/content_filtering/c++11/home_automation_subscriber_update_filter.cxx

+12-8
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,29 @@ int main(int argc, char **argv)
2525
dds::topic::ContentFilteredTopic<DeviceStatus> content_filtered_topic(
2626
topic,
2727
"FilterRoomAndOpenWindows",
28-
dds::topic::Filter("is_open = true and room_name = %0", parameters));
28+
dds::topic::Filter(
29+
"is_open = true and room_name = %0",
30+
parameters));
2931
dds::sub::DataReader<DeviceStatus> reader(content_filtered_topic);
3032

3133
parameters[0] = "'Kitchen'";
32-
content_filtered_topic.filter_parameters(parameters.begin(), parameters.end());
34+
content_filtered_topic.filter_parameters(
35+
parameters.begin(),
36+
parameters.end());
3337

3438
rti::sub::SampleProcessor sample_processor;
3539
sample_processor.attach_reader(
3640
reader,
37-
[](const rti::sub::LoanedSample<DeviceStatus>& sample)
38-
{
39-
if (sample.info().valid()) { // ignore samples with only meta-data
41+
[](const rti::sub::LoanedSample<DeviceStatus> &sample) {
42+
if (sample.info().valid()) { // ignore samples with only
43+
// meta-data
4044
std::cout << "WARNING: " << sample.data().sensor_name()
41-
<< " in " << sample.data().room_name()
42-
<< " is open!" << std::endl;
45+
<< " in " << sample.data().room_name()
46+
<< " is open!" << std::endl;
4347
}
4448
});
4549

46-
while (true) { // wait in a loop
50+
while (true) { // wait in a loop
4751
std::this_thread::sleep_for(std::chrono::seconds(4));
4852
}
4953
}

tutorials/content_filtering/py/home_automation_subscriber_update_filter.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ async def sensor_monitoring():
2020
content_filtered_topic = dds.ContentFilteredTopic(
2121
topic,
2222
"FilterRoomAndOpenWindows",
23-
dds.Filter("is_open = true and room_name = %0", parameters=["'LivingRoom'"]),
23+
dds.Filter(
24+
"is_open = true and room_name = %0", parameters=["'LivingRoom'"]
25+
),
2426
)
2527
reader = dds.DataReader(content_filtered_topic)
2628

tutorials/data_persistence/c++11/temperature_durable_publisher.cxx

+11-6
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,24 @@
1515
#include <rti/rti.hpp>
1616
#include "temperature.hpp"
1717

18-
void publish_temperature(const std::string& sensor_name)
18+
void publish_temperature(const std::string &sensor_name)
1919
{
2020
dds::domain::DomainParticipant participant(0);
2121
dds::topic::Topic<Temperature> topic(participant, "Temperature");
2222

2323
dds::pub::qos::DataWriterQos writer_qos {
24-
dds::core::QosProvider::Default().datawriter_qos("MyLibrary::Persistence")
24+
dds::core::QosProvider::Default().datawriter_qos(
25+
"MyLibrary::Persistence")
2526
};
2627

27-
writer_qos.policy<dds::core::policy::Durability>().extensions()
28-
.storage_settings().enable(true);
29-
writer_qos.policy<dds::core::policy::Durability>().extensions()
30-
.storage_settings().file_name(sensor_name);
28+
writer_qos.policy<dds::core::policy::Durability>()
29+
.extensions()
30+
.storage_settings()
31+
.enable(true);
32+
writer_qos.policy<dds::core::policy::Durability>()
33+
.extensions()
34+
.storage_settings()
35+
.file_name(sensor_name);
3136

3237
dds::pub::DataWriter<Temperature> writer(topic, writer_qos);
3338

tutorials/data_persistence/c++11/temperature_durable_subscriber.cxx

+16-12
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,25 @@ void sensor_monitoring(std::string subscriber_name)
2424
dds::topic::Topic<Temperature> topic(participant, "Temperature");
2525

2626
dds::sub::qos::DataReaderQos reader_qos {
27-
dds::core::QosProvider::Default().datareader_qos("MyLibrary::Persistence")
27+
dds::core::QosProvider::Default().datareader_qos(
28+
"MyLibrary::Persistence")
2829
};
2930

30-
reader_qos.policy<dds::core::policy::Durability>().extensions()
31-
.storage_settings().enable(true);
32-
reader_qos.policy<dds::core::policy::Durability>().extensions()
33-
.storage_settings().file_name(subscriber_name);
31+
reader_qos.policy<dds::core::policy::Durability>()
32+
.extensions()
33+
.storage_settings()
34+
.enable(true);
35+
reader_qos.policy<dds::core::policy::Durability>()
36+
.extensions()
37+
.storage_settings()
38+
.file_name(subscriber_name);
3439

3540
dds::sub::DataReader<Temperature> reader(topic, reader_qos);
3641

3742
rti::sub::SampleProcessor sample_processor;
3843
sample_processor.attach_reader(
3944
reader,
40-
[](const rti::sub::LoanedSample<Temperature>& sample)
41-
{
45+
[](const rti::sub::LoanedSample<Temperature> &sample) {
4246
if (!sample.info().valid()) {
4347
// ignore samples with only meta-data
4448
return;
@@ -47,13 +51,13 @@ void sensor_monitoring(std::string subscriber_name)
4751
uint64_t timestamp =
4852
sample.info().source_timestamp().to_millisecs();
4953

50-
std::cout << sample.data().sensor_name() << ": "
51-
<< std::fixed << std::setprecision(2)
52-
<< sample.data().degrees() << " degrees ("
53-
<< timestamp / 1000.0 << "s)" << std::endl;
54+
std::cout << sample.data().sensor_name() << ": " << std::fixed
55+
<< std::setprecision(2) << sample.data().degrees()
56+
<< " degrees (" << timestamp / 1000.0 << "s)"
57+
<< std::endl;
5458
});
5559

56-
while (true) { // wait in a loop
60+
while (true) { // wait in a loop
5761
std::this_thread::sleep_for(std::chrono::seconds(4));
5862
}
5963
}

tutorials/data_persistence/c++11/temperature_publisher.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <rti/rti.hpp>
1616
#include "temperature.hpp"
1717

18-
void publish_temperature(const std::string& sensor_name)
18+
void publish_temperature(const std::string &sensor_name)
1919
{
2020
dds::domain::DomainParticipant participant(0);
2121
dds::topic::Topic<Temperature> topic(participant, "Temperature");

tutorials/data_persistence/c++11/temperature_subscriber.cxx

+6-7
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ int main(int argc, char **argv)
2626
rti::sub::SampleProcessor sample_processor;
2727
sample_processor.attach_reader(
2828
reader,
29-
[](const rti::sub::LoanedSample<Temperature>& sample)
30-
{
29+
[](const rti::sub::LoanedSample<Temperature> &sample) {
3130
if (!sample.info().valid()) {
3231
// ignore samples with only meta-data
3332
return;
@@ -36,13 +35,13 @@ int main(int argc, char **argv)
3635
uint64_t timestamp =
3736
sample.info().source_timestamp().to_millisecs();
3837

39-
std::cout << sample.data().sensor_name() << ": "
40-
<< std::fixed << std::setprecision(2)
41-
<< sample.data().degrees() << " degrees ("
42-
<< timestamp / 1000.0 << "s)" << std::endl;
38+
std::cout << sample.data().sensor_name() << ": " << std::fixed
39+
<< std::setprecision(2) << sample.data().degrees()
40+
<< " degrees (" << timestamp / 1000.0 << "s)"
41+
<< std::endl;
4342
});
4443

45-
while (true) { // wait in a loop
44+
while (true) { // wait in a loop
4645
std::this_thread::sleep_for(std::chrono::seconds(4));
4746
}
4847
}

tutorials/data_persistence/py/temperature.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
import rti.types as idl
1313

14-
@idl.struct(
15-
member_annotations={"sensor_name": [idl.key, idl.bound(100)]}
16-
)
14+
15+
@idl.struct(member_annotations={"sensor_name": [idl.key, idl.bound(100)]})
1716
class Temperature:
1817
sensor_name: str = ""
1918
degrees: float = 0.0

tutorials/data_persistence/py/temperature_durable_publisher.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import rti.connextdds as dds
1717
from temperature import Temperature
1818

19+
1920
def publish_temperature(sensor_name: str):
2021
participant = dds.DomainParticipant(domain_id=0)
2122
topic = dds.Topic(participant, "Temperature", Temperature)

tutorials/data_persistence/py/temperature_durable_subscriber.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ async def sensor_monitoring(subscriber_name: str):
3434
continue # skip updates with only meta-data
3535

3636
timestamp = datetime.fromtimestamp(info.source_timestamp.to_seconds())
37-
print(
38-
f"{data.sensor_name}: {data.degrees:.2f} degrees ({timestamp})"
39-
)
37+
print(f"{data.sensor_name}: {data.degrees:.2f} degrees ({timestamp})")
4038

4139

4240
if __name__ == "__main__":

tutorials/data_persistence/py/temperature_publisher.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import rti.connextdds as dds
1717
from temperature import Temperature
1818

19+
1920
def publish_temperature(sensor_name: str):
2021
participant = dds.DomainParticipant(domain_id=0)
2122
topic = dds.Topic(participant, "Temperature", Temperature)

tutorials/data_persistence/py/temperature_subscriber.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ async def sensor_monitoring():
2626
continue # skip updates with only meta-data
2727

2828
timestamp = datetime.fromtimestamp(info.source_timestamp.to_seconds())
29-
print(
30-
f"{data.sensor_name}: {data.degrees:.2f} degrees ({timestamp})"
31-
)
29+
print(f"{data.sensor_name}: {data.degrees:.2f} degrees ({timestamp})")
3230

3331

3432
if __name__ == "__main__":

tutorials/discovery/c++11/home_automation_publisher.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "home_automation.hpp"
1717

1818
void publish_sensor(
19-
const std::string& sensor_name,
20-
const std::string& room_name)
19+
const std::string &sensor_name,
20+
const std::string &room_name)
2121
{
2222
dds::domain::DomainParticipant participant(0);
2323
dds::topic::Topic<DeviceStatus> topic(participant, "WindowStatus");

tutorials/discovery/c++11/home_automation_subscriber.cxx

+15-16
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717
#include "rti/sub/SampleProcessor.hpp"
1818
#include "home_automation.hpp"
1919

20-
class SensorListener
21-
: public dds::sub::NoOpDataReaderListener<DeviceStatus> {
22-
20+
class SensorListener : public dds::sub::NoOpDataReaderListener<DeviceStatus> {
2321
void on_subscription_matched(
2422
dds::sub::DataReader<DeviceStatus> &reader,
2523
const dds::core::status::SubscriptionMatchedStatus &status) override
2624
{
27-
std::cout << std::endl << "Total publishers: " << status.current_count()
28-
<< ", Change: " << status.current_count_change()
29-
<< std::endl;
25+
std::cout << std::endl
26+
<< "Total publishers: " << status.current_count()
27+
<< ", Change: " << status.current_count_change() << std::endl;
3028

3129
dds::core::InstanceHandleSeq publications =
3230
dds::sub::matched_publications(reader);
@@ -37,11 +35,12 @@ class SensorListener
3735

3836
std::cout << "Publisher " << i << ": " << std::endl;
3937
std::cout << " Publisher Virtual GUID: "
40-
<< pub_data.extensions().virtual_guid() << std::endl;
38+
<< pub_data.extensions().virtual_guid() << std::endl;
4139
std::cout << " Publisher Name: "
42-
<< (pub_data.extensions().publication_name().name()
43-
? pub_data->publication_name().name().value()
44-
: "(N/A)") << std::endl;
40+
<< (pub_data.extensions().publication_name().name()
41+
? pub_data->publication_name().name().value()
42+
: "(N/A)")
43+
<< std::endl;
4544
}
4645
}
4746
};
@@ -61,18 +60,18 @@ int main(int argc, char **argv)
6160
rti::sub::SampleProcessor sample_processor;
6261
sample_processor.attach_reader(
6362
reader,
64-
[](const rti::sub::LoanedSample<DeviceStatus>& sample)
65-
{
66-
if (sample.info().valid()) { // ignore samples with only meta-data
63+
[](const rti::sub::LoanedSample<DeviceStatus> &sample) {
64+
if (sample.info().valid()) { // ignore samples with only
65+
// meta-data
6766
if (sample.data().is_open()) {
6867
std::cout << "WARNING: " << sample.data().sensor_name()
69-
<< " in " << sample.data().room_name()
70-
<< " is open!" << std::endl;
68+
<< " in " << sample.data().room_name()
69+
<< " is open!" << std::endl;
7170
}
7271
}
7372
});
7473

75-
while (true) { // wait in a loop
74+
while (true) { // wait in a loop
7675
std::this_thread::sleep_for(std::chrono::seconds(4));
7776
}
7877
}

tutorials/distributed_data_cache/c++11/home_automation_subscriber.cxx

+16-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
void wait_for_input(std::string query)
2121
{
22-
std::cout << std::endl << std::endl
22+
std::cout << std::endl
23+
<< std::endl
2324
<< "Press Enter to " << query << std::endl;
2425
std::cin.get();
2526
}
@@ -45,10 +46,9 @@ int main(int argc, char **argv)
4546

4647
wait_for_input(
4748
"obtain all the samples with the attribute is_open set to true.");
48-
print_data(
49-
reader.select()
50-
.content(dds::sub::Query(reader, "is_open = true"))
51-
.read());
49+
print_data(reader.select()
50+
.content(dds::sub::Query(reader, "is_open = true"))
51+
.read());
5252

5353

5454
wait_for_input(
@@ -65,7 +65,8 @@ int main(int argc, char **argv)
6565
"LivingRoom.");
6666
print_data(
6767
reader.select()
68-
.content(dds::sub::Query(reader, "room_name = 'LivingRoom'"))
68+
.content(
69+
dds::sub::Query(reader, "room_name = 'LivingRoom'"))
6970
.read());
7071

7172

@@ -78,24 +79,21 @@ int main(int argc, char **argv)
7879

7980

8081
wait_for_input("obtain all the samples that you have not read yet.");
81-
print_data(
82-
reader.select()
83-
.state(dds::sub::status::SampleState::not_read())
84-
.read());
82+
print_data(reader.select()
83+
.state(dds::sub::status::SampleState::not_read())
84+
.read());
8585

8686

8787
wait_for_input("obtain again, all the samples that you have not read yet.");
88-
print_data(
89-
reader.select()
90-
.state(dds::sub::status::SampleState::not_read())
91-
.read());
88+
print_data(reader.select()
89+
.state(dds::sub::status::SampleState::not_read())
90+
.read());
9291

9392

9493
wait_for_input("obtain the new instances.");
95-
print_data(
96-
reader.select()
97-
.state(dds::sub::status::ViewState::new_view())
98-
.read());
94+
print_data(reader.select()
95+
.state(dds::sub::status::ViewState::new_view())
96+
.read());
9997

10098

10199
wait_for_input(

0 commit comments

Comments
 (0)