Skip to content

Commit 0ec5d54

Browse files
committed
c++ formatter changes according to linter
1 parent 24591af commit 0ec5d54

File tree

3 files changed

+160
-146
lines changed

3 files changed

+160
-146
lines changed

examples/connext_secure/dynamic_permissions/c++11/application.h

Lines changed: 104 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* (c) Copyright, Real-Time Innovations, 2025. All rights reserved.
3-
* RTI grants Licensee a license to use, modify, compile, and create derivative
4-
* works of the software solely for use with RTI Connext DDS. Licensee may
5-
* redistribute copies of the software provided that all such copies are subject
6-
* to this license. The software is provided "as is", with no warranty of any
7-
* type, including any warranty for fitness for any purpose. RTI is under no
8-
* obligation to maintain or support the software. RTI shall not be liable for
9-
* any incidental or consequential damages arising out of the use or inability
10-
* to use the software.
11-
*/
2+
* (c) Copyright, Real-Time Innovations, 2025. All rights reserved.
3+
* RTI grants Licensee a license to use, modify, compile, and create derivative
4+
* works of the software solely for use with RTI Connext DDS. Licensee may
5+
* redistribute copies of the software provided that all such copies are subject
6+
* to this license. The software is provided "as is", with no warranty of any
7+
* type, including any warranty for fitness for any purpose. RTI is under no
8+
* obligation to maintain or support the software. RTI shall not be liable for
9+
* any incidental or consequential damages arising out of the use or inability
10+
* to use the software.
11+
*/
1212

1313
#ifndef APPLICATION_H
1414
#define APPLICATION_H
@@ -19,109 +19,113 @@
1919

2020
namespace application {
2121

22-
// Catch control-C and tell application to shut down
23-
bool shutdown_requested = false;
22+
// Catch control-C and tell application to shut down
23+
bool shutdown_requested = false;
2424

25-
inline void stop_handler(int)
26-
{
27-
shutdown_requested = true;
28-
std::cout << "preparing to shut down..." << std::endl;
29-
}
25+
inline void stop_handler(int)
26+
{
27+
shutdown_requested = true;
28+
std::cout << "preparing to shut down..." << std::endl;
29+
}
3030

31-
inline void setup_signal_handlers()
32-
{
33-
signal(SIGINT, stop_handler);
34-
signal(SIGTERM, stop_handler);
35-
}
31+
inline void setup_signal_handlers()
32+
{
33+
signal(SIGINT, stop_handler);
34+
signal(SIGTERM, stop_handler);
35+
}
3636

37-
enum ParseReturn { PARSE_RETURN_OK, PARSE_RETURN_FAILURE, PARSE_RETURN_EXIT };
37+
enum ParseReturn { PARSE_RETURN_OK, PARSE_RETURN_FAILURE, PARSE_RETURN_EXIT };
3838

39-
struct ApplicationArguments {
40-
ParseReturn parse_result;
41-
unsigned int domain_id;
42-
unsigned int sample_count;
43-
NDDS_Config_LogVerbosity verbosity;
44-
};
39+
struct ApplicationArguments {
40+
ParseReturn parse_result;
41+
unsigned int domain_id;
42+
unsigned int sample_count;
43+
NDDS_Config_LogVerbosity verbosity;
44+
};
4545

46-
inline void set_verbosity(
47-
ApplicationArguments& arguments,
48-
int verbosity)
49-
{
50-
switch (verbosity) {
51-
case 0:
52-
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_SILENT;
53-
break;
54-
case 1:
55-
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_ERROR;
56-
break;
57-
case 2:
58-
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_WARNING;
59-
break;
60-
case 3:
61-
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_STATUS_ALL;
62-
break;
63-
default:
64-
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_ERROR;
65-
break;
66-
}
46+
inline void set_verbosity(ApplicationArguments &arguments, int verbosity)
47+
{
48+
switch (verbosity) {
49+
case 0:
50+
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_SILENT;
51+
break;
52+
case 1:
53+
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_ERROR;
54+
break;
55+
case 2:
56+
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_WARNING;
57+
break;
58+
case 3:
59+
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_STATUS_ALL;
60+
break;
61+
default:
62+
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_ERROR;
63+
break;
6764
}
65+
}
6866

69-
// Parses application arguments for example. Returns whether to exit.
70-
inline void parse_arguments(
71-
ApplicationArguments& arguments,
67+
// Parses application arguments for example. Returns whether to exit.
68+
inline void parse_arguments(
69+
ApplicationArguments &arguments,
7270
int argc,
7371
char *argv[])
74-
{
75-
int arg_processing = 1;
76-
bool show_usage = false;
77-
arguments.domain_id = 0;
78-
arguments.sample_count = INT_MAX;
79-
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_ERROR;
80-
arguments.parse_result = PARSE_RETURN_OK;
72+
{
73+
int arg_processing = 1;
74+
bool show_usage = false;
75+
arguments.domain_id = 0;
76+
arguments.sample_count = INT_MAX;
77+
arguments.verbosity = NDDS_CONFIG_LOG_VERBOSITY_ERROR;
78+
arguments.parse_result = PARSE_RETURN_OK;
8179

82-
while (arg_processing < argc) {
83-
if ((argc > arg_processing + 1)
80+
while (arg_processing < argc) {
81+
if ((argc > arg_processing + 1)
8482
&& (strcmp(argv[arg_processing], "-d") == 0
85-
|| strcmp(argv[arg_processing], "--domain") == 0)) {
86-
arguments.domain_id = atoi(argv[arg_processing + 1]);
87-
arg_processing += 2;
88-
} else if ((argc > arg_processing + 1)
89-
&& (strcmp(argv[arg_processing], "-s") == 0
90-
|| strcmp(argv[arg_processing], "--sample-count") == 0)) {
91-
arguments.sample_count = atoi(argv[arg_processing + 1]);
92-
arg_processing += 2;
93-
} else if ((argc > arg_processing + 1)
94-
&& (strcmp(argv[arg_processing], "-v") == 0
95-
|| strcmp(argv[arg_processing], "--verbosity") == 0)) {
96-
set_verbosity(arguments, atoi(argv[arg_processing + 1]));
97-
arg_processing += 2;
98-
} else if (strcmp(argv[arg_processing], "-h") == 0
99-
|| strcmp(argv[arg_processing], "--help") == 0) {
100-
std::cout << "Example application." << std::endl;
101-
show_usage = true;
102-
arguments.parse_result = PARSE_RETURN_EXIT;
103-
break;
104-
} else {
105-
std::cout << "Bad parameter." << std::endl;
106-
show_usage = true;
107-
arguments.parse_result = PARSE_RETURN_FAILURE;
108-
break;
109-
}
110-
}
111-
if (show_usage) {
112-
std::cout << "Usage:\n"\
113-
" -d, --domain <int> Domain ID this application will\n" \
114-
" subscribe in. \n"
115-
" Default: 0\n"\
116-
" -s, --sample_count <int> Number of samples to receive before\n"\
117-
" cleanly shutting down. \n"
118-
" Default: infinite\n"
119-
" -v, --verbosity <int> How much debugging output to show.\n"\
120-
" Range: 0-3 \n"
121-
" Default: 1"
122-
<< std::endl;
83+
|| strcmp(argv[arg_processing], "--domain") == 0)) {
84+
arguments.domain_id = atoi(argv[arg_processing + 1]);
85+
arg_processing += 2;
86+
} else if (
87+
(argc > arg_processing + 1)
88+
&& (strcmp(argv[arg_processing], "-s") == 0
89+
|| strcmp(argv[arg_processing], "--sample-count") == 0)) {
90+
arguments.sample_count = atoi(argv[arg_processing + 1]);
91+
arg_processing += 2;
92+
} else if (
93+
(argc > arg_processing + 1)
94+
&& (strcmp(argv[arg_processing], "-v") == 0
95+
|| strcmp(argv[arg_processing], "--verbosity") == 0)) {
96+
set_verbosity(arguments, atoi(argv[arg_processing + 1]));
97+
arg_processing += 2;
98+
} else if (
99+
strcmp(argv[arg_processing], "-h") == 0
100+
|| strcmp(argv[arg_processing], "--help") == 0) {
101+
std::cout << "Example application." << std::endl;
102+
show_usage = true;
103+
arguments.parse_result = PARSE_RETURN_EXIT;
104+
break;
105+
} else {
106+
std::cout << "Bad parameter." << std::endl;
107+
show_usage = true;
108+
arguments.parse_result = PARSE_RETURN_FAILURE;
109+
break;
123110
}
124111
}
112+
if (show_usage) {
113+
std::cout << "Usage:\n"
114+
" -d, --domain <int> Domain ID this "
115+
"application will\n"
116+
" subscribe in. \n"
117+
" Default: 0\n"
118+
" -s, --sample_count <int> Number of samples to "
119+
"receive before\n"
120+
" cleanly shutting down. \n"
121+
" Default: infinite\n"
122+
" -v, --verbosity <int> How much debugging output "
123+
"to show.\n"
124+
" Range: 0-3 \n"
125+
" Default: 1"
126+
<< std::endl;
127+
}
128+
}
125129

126130
} // namespace application
127131

examples/connext_secure/dynamic_permissions/c++11/dynamic_permissions_publisher.cxx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* (c) Copyright, Real-Time Innovations, 2025. All rights reserved.
3-
* RTI grants Licensee a license to use, modify, compile, and create derivative
4-
* works of the software solely for use with RTI Connext DDS. Licensee may
5-
* redistribute copies of the software provided that all such copies are subject
6-
* to this license. The software is provided "as is", with no warranty of any
7-
* type, including any warranty for fitness for any purpose. RTI is under no
8-
* obligation to maintain or support the software. RTI shall not be liable for
9-
* any incidental or consequential damages arising out of the use or inability
10-
* to use the software.
11-
*/
2+
* (c) Copyright, Real-Time Innovations, 2025. All rights reserved.
3+
* RTI grants Licensee a license to use, modify, compile, and create derivative
4+
* works of the software solely for use with RTI Connext DDS. Licensee may
5+
* redistribute copies of the software provided that all such copies are subject
6+
* to this license. The software is provided "as is", with no warranty of any
7+
* type, including any warranty for fitness for any purpose. RTI is under no
8+
* obligation to maintain or support the software. RTI shall not be liable for
9+
* any incidental or consequential damages arising out of the use or inability
10+
* to use the software.
11+
*/
1212

1313
#include <iostream>
1414

@@ -19,31 +19,36 @@
1919
#include "application.hpp" // for command line parsing and ctrl-c
2020
#include "dynamic_permissions.hpp"
2121

22-
void run_publisher_application(unsigned int domain_id, unsigned int sample_count)
22+
void run_publisher_application(
23+
unsigned int domain_id,
24+
unsigned int sample_count)
2325
{
2426
// Start communicating in a domain, usually one participant per application
2527
dds::domain::DomainParticipant participant(
2628
domain_id,
2729
dds::core::QosProvider::Default().participant_qos(
28-
"dynamic_permissions_Library::publisher"));
30+
"dynamic_permissions_Library::publisher"));
2931

3032
// Create a Topic with a name and a datatype
31-
dds::topic::Topic< ::DynamicPermissions> topic(participant, "Example DynamicPermissions");
33+
dds::topic::Topic<::DynamicPermissions> topic(
34+
participant,
35+
"Example DynamicPermissions");
3236

3337
// Create a Publisher
3438
dds::pub::Publisher publisher(participant);
3539

3640
// Create a DataWriter with default QoS
37-
dds::pub::DataWriter< ::DynamicPermissions> writer(publisher, topic);
41+
dds::pub::DataWriter<::DynamicPermissions> writer(publisher, topic);
3842

3943
::DynamicPermissions data;
4044
// Main loop, write data
4145
for (unsigned int samples_written = 0;
42-
!application::shutdown_requested && samples_written < sample_count;
43-
samples_written++) {
46+
!application::shutdown_requested && samples_written < sample_count;
47+
samples_written++) {
4448
// Modify the data to be written here
4549
data.value(static_cast<int32_t>(samples_written));
46-
std::cout << "Writing ::DynamicPermissions, count " << samples_written << std::endl;
50+
std::cout << "Writing ::DynamicPermissions, count " << samples_written
51+
<< std::endl;
4752

4853
writer.write(data);
4954

@@ -68,7 +73,6 @@ void run_publisher_application(unsigned int domain_id, unsigned int sample_count
6873

6974
int main(int argc, char *argv[])
7075
{
71-
7276
using namespace application;
7377

7478
// Parse arguments and handle control-C
@@ -85,10 +89,10 @@ int main(int argc, char *argv[])
8589

8690
try {
8791
run_publisher_application(arguments.domain_id, arguments.sample_count);
88-
} catch (const std::exception& ex) {
92+
} catch (const std::exception &ex) {
8993
// This will catch DDS exceptions
9094
std::cerr << "Exception in run_publisher_application(): " << ex.what()
91-
<< std::endl;
95+
<< std::endl;
9296
return EXIT_FAILURE;
9397
}
9498

0 commit comments

Comments
 (0)