Skip to content

Commit

Permalink
Refs #12290. Uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Jul 29, 2021
1 parent 2fa5f2b commit d520b99
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 101 deletions.
29 changes: 24 additions & 5 deletions examples/C++/RTPSTest_as_socket/TestReaderSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,42 @@
class TestReaderSocket
{
public:

TestReaderSocket();

virtual ~TestReaderSocket();

eprosima::fastrtps::rtps::RTPSParticipant* mp_participant;

eprosima::fastrtps::rtps::RTPSReader* mp_reader;

eprosima::fastrtps::rtps::ReaderHistory* mp_history;
bool init(std::string ip,uint32_t port);

bool init(
std::string ip,
uint32_t port);

void run();
class MyListener:public eprosima::fastrtps::rtps::ReaderListener

class MyListener : public eprosima::fastrtps::rtps::ReaderListener
{
public:
MyListener():m_received(0){};
~MyListener(){};

MyListener()
: m_received(0)
{
}

~MyListener()
{
}

void onNewCacheChangeAdded(
eprosima::fastrtps::rtps::RTPSReader* reader,
const eprosima::fastrtps::rtps::CacheChange_t* const change) override;
uint32_t m_received;
}m_listener;
}
m_listener;

};

Expand Down
28 changes: 20 additions & 8 deletions examples/C++/RTPSTest_as_socket/TestWriterSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,27 @@
#include <cstdio>
#include <cstdint>

class TestWriterSocket {
class TestWriterSocket
{

public:
TestWriterSocket();
virtual ~TestWriterSocket();
eprosima::fastrtps::rtps::RTPSParticipant* mp_participant;
eprosima::fastrtps::rtps::RTPSWriter* mp_writer;
eprosima::fastrtps::rtps::WriterHistory* mp_history;
bool init(std::string ip,uint32_t port);
void run(uint16_t nmsgs);

TestWriterSocket();

virtual ~TestWriterSocket();

eprosima::fastrtps::rtps::RTPSParticipant* mp_participant;

eprosima::fastrtps::rtps::RTPSWriter* mp_writer;

eprosima::fastrtps::rtps::WriterHistory* mp_history;

bool init(
std::string ip,
uint32_t port);

void run(
uint16_t nmsgs);
};

#endif /* TESTWRITER_H_ */
4 changes: 1 addition & 3 deletions examples/C++/RTPSTest_custom_transport/TestReaderSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ TestReaderSocket::TestReaderSocket()
, mp_reader(nullptr)
, mp_history(nullptr)
{


}

TestReaderSocket::~TestReaderSocket()
Expand Down Expand Up @@ -91,7 +89,7 @@ bool TestReaderSocket::init(
#else
// Header reduction on top of timestamp
auto hrDesc = std::make_shared<HeaderReductionTransportDescriptor>(tsDesc);
#endif
#endif // if HAVE_ZLIB || HAVE_BZIP2
PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_version",
"true"));
PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_vendor_id",
Expand Down
7 changes: 4 additions & 3 deletions examples/C++/RTPSTest_custom_transport/TestReaderSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TestReaderSocket
void run();
class MyListener : public eprosima::fastrtps::rtps::ReaderListener
{
public:
public:

MyListener()
: m_received(0)
Expand All @@ -54,8 +54,9 @@ class TestReaderSocket
eprosima::fastrtps::rtps::RTPSReader* reader,
const eprosima::fastrtps::rtps::CacheChange_t* const change);
uint32_t m_received;
} m_listener;
}
m_listener;

};

#endif /* TESTREADER_H_ */
#endif // ifndef TESTREADERSOCKET_H_
13 changes: 6 additions & 7 deletions examples/C++/RTPSTest_custom_transport/TestWriterSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ TestWriterSocket::TestWriterSocket()
, mp_writer(nullptr)
, mp_history(nullptr)
{


}

TestWriterSocket::~TestWriterSocket()
Expand Down Expand Up @@ -89,7 +87,7 @@ bool TestWriterSocket::init(
#else
// Header reduction on top of timestamp
auto hrDesc = std::make_shared<HeaderReductionTransportDescriptor>(tsDesc);
#endif
#endif // if HAVE_ZLIB || HAVE_BZIP2
PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_version",
"true"));
PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_vendor_id",
Expand Down Expand Up @@ -142,16 +140,17 @@ void TestWriterSocket::run(
{
for (int i = 0; i < nmsgs; ++i )
{
fastrtps::rtps::CacheChange_t* ch = mp_writer->new_change([]() -> uint32_t {
return 255;
}, fastrtps::rtps::ALIVE);
fastrtps::rtps::CacheChange_t* ch = mp_writer->new_change([]() -> uint32_t
{
return 255;
}, fastrtps::rtps::ALIVE);
#if defined(_WIN32)
ch->serializedPayload.length =
sprintf_s((char*)ch->serializedPayload.data, 255, "My example string %d", i) + 1;
#else
ch->serializedPayload.length =
sprintf((char*)ch->serializedPayload.data, "My example string %d", i) + 1;
#endif
#endif // if defined(_WIN32)
printf("Sending: %s\n", (char*)ch->serializedPayload.data);
mp_history->add_change(ch);
}
Expand Down
48 changes: 28 additions & 20 deletions examples/C++/RTPSTest_custom_transport/main_RTPSTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,27 @@ using namespace rtps;
using namespace std;


int main(int argc, char** argv){
int main(
int argc,
char** argv)
{

std::cout << "Starting" << std::endl;
int type;
uint32_t port = 7000;
if(argc > 1)
if (argc > 1)
{
if(strcmp(argv[1],"writer")==0)
if (strcmp(argv[1], "writer") == 0)
{
type = 1;
else if(strcmp(argv[1],"reader")==0)
}
else if (strcmp(argv[1], "reader") == 0)
{
type = 2;
}
else
{
std::cout << "NEEDS writer OR reader as first argument"<<std::endl;
std::cout << "NEEDS writer OR reader as first argument" << std::endl;
return 0;
}

Expand All @@ -56,34 +63,35 @@ int main(int argc, char** argv){
}
else
{
std::cout << "NEEDS writer OR reader ARGUMENT"<<std::endl;
std::cout << "RTPSTest writer"<<std::endl;
std::cout << "RTPSTest reader" <<std::endl;
std::cout << "NEEDS writer OR reader ARGUMENT" << std::endl;
std::cout << "RTPSTest writer" << std::endl;
std::cout << "RTPSTest reader" << std::endl;
return 0;
}
switch (type)
{
case 1:
{
TestWriterSocket TW;
if (TW.init("239.255.1.5", port))
{
TestWriterSocket TW;
if(TW.init("239.255.1.5",port))
TW.run(10);
break;
TW.run(10);
}
break;
}
case 2:
{
TestReaderSocket TR;
if (TR.init("239.255.1.5", port))
{
TestReaderSocket TR;
if(TR.init("239.255.1.5",port))
TR.run();
break;
TR.run();
}
break;
}
}

RTPSDomain::stopAll();
std::cout << "EVERYTHING STOPPED FINE"<<std::endl;
std::cout << "EVERYTHING STOPPED FINE" << std::endl;

return 0;
}



2 changes: 1 addition & 1 deletion include/fastdds/rtps/transport/ChainingTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ class RTPS_DllAPI ChainingTransport : public TransportInterface
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // ifndef CHAINING_TRANSPORT_H
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ typedef struct RTPS_DllAPI ChainingTransportDescriptor : public TransportDescrip
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // ifndef CHAINING_TRANSPORT_DESCRIPTOR
2 changes: 1 addition & 1 deletion include/fastrtps/rtps/network/NetworkFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

#include <fastdds/rtps/network/NetworkFactory.h>

#endif
#endif // ifndef NETWORK_FACTORY_HPP
2 changes: 1 addition & 1 deletion include/fastrtps/transport/TransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ static const std::string s_IPv6AddressAny = fastdds::rtps::s_IPv6AddressAny;
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // ifndef TRANSPORT_INTERFACE_H
2 changes: 1 addition & 1 deletion include/fastrtps/transport/UDPv4TransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ using UDPv4TransportDescriptor = fastdds::rtps::UDPv4TransportDescriptor;
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // ifndef UDPV4_TRANSPORT_DESCRIPTOR
2 changes: 1 addition & 1 deletion include/fastrtps/transport/UDPv6TransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ using UDPv6TransportDescriptor = fastdds::rtps::UDPv6TransportDescriptor;
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // ifndef UDPV6_TRANSPORT_DESCRIPTOR
2 changes: 1 addition & 1 deletion include/fastrtps/transport/test_UDPv4TransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ using test_UDPv4TransportDescriptor = fastdds::rtps::test_UDPv4TransportDescript
} // namespace fastrtps
} // namespace eprosima

#endif
#endif // ifndef TEST_UDPV4_TRANSPORT_DESCRIPTOR
5 changes: 3 additions & 2 deletions include/fastrtps/utils/StringMatching.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class RTPS_DllAPI StringMatching
int base = 10);
};

}
} // namespace rtps
} /* namespace rtps */
} /* namespace eprosima */

#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif /* STRINGMATCHING_H_ */
#endif // ifndef STRINGMATCHING_H_
6 changes: 3 additions & 3 deletions src/cpp/rtps/transport/ChainingReceiverResource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class ChainingReceiverResource : public TransportReceiverInterface
};


}
}
}
} // namespace rtps
} // namespace fastdds
} // namespace eprosima

#endif // TRANSPORT_CHAININGRECEIVERRESOURCE_HPP
6 changes: 3 additions & 3 deletions src/cpp/rtps/transport/ChainingTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ bool ChainingTransport::OpenOutputChannel(
return returned_value;
}

}
}
}
} // namespace rtps
} // namespace fastdds
} // namespace eprosima
2 changes: 1 addition & 1 deletion src/cpp/rtps/transport/UDPTransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class UDPTransportInterface : public TransportInterface
std::vector<fastrtps::rtps::IPFinder::info_IP> currentInterfaces;

mutable std::recursive_mutex mInputMapMutex;
std::map<uint16_t, std::vector<UDPChannelResource*> > mInputSockets;
std::map<uint16_t, std::vector<UDPChannelResource*>> mInputSockets;

uint32_t mSendBufferSize;
uint32_t mReceiveBufferSize;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/transport/shared_mem/SharedMemTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SharedMemTransport : public TransportInterface

std::shared_ptr<SharedMemManager::Segment> shared_mem_segment_;

std::shared_ptr<PacketsLog<SHMPacketFileConsumer> > packet_logger_;
std::shared_ptr<PacketsLog<SHMPacketFileConsumer>> packet_logger_;

friend class SharedMemChannelResource;

Expand Down
23 changes: 17 additions & 6 deletions src/cpp/utils/StringMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,37 @@ bool StringMatching::matchString(

#endif // if defined(__cplusplus_winrt)

std::vector<std::string> StringMatching::split(const std::string& str, const std::string& delim)
std::vector<std::string> StringMatching::split(
const std::string& str,
const std::string& delim)
{
std::vector<std::string> tokens;
size_t prev = 0, pos = 0;
do
{
pos = str.find(delim, prev);
if (pos == std::string::npos) pos = str.length();
if (pos == std::string::npos)
{
pos = str.length();
}
std::string token = str.substr(prev, pos - prev);
if (!token.empty()) tokens.push_back(token);
if (!token.empty())
{
tokens.push_back(token);
}
prev = pos + delim.length();
} while (pos < str.length() && prev < str.length());
return tokens;
}

bool StringMatching::readUint32(uint32_t& n, std::string const& str, int base)
bool StringMatching::readUint32(
uint32_t& n,
std::string const& str,
int base)
{
char *endp;
char* endp;
unsigned long value = strtoul(str.c_str(), &endp, base);
if ( (endp == str.c_str()) || (value == ULONG_MAX && errno == ERANGE) )
if ((endp == str.c_str()) || (value == ULONG_MAX && errno == ERANGE))
{
return false;
}
Expand Down
Loading

0 comments on commit d520b99

Please sign in to comment.