Skip to content

Commit

Permalink
Refs #21129: Uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
  • Loading branch information
elianalf committed Jun 10, 2024
1 parent 8333472 commit 5590928
Show file tree
Hide file tree
Showing 17 changed files with 357 additions and 231 deletions.
292 changes: 166 additions & 126 deletions include/fastdds/rtps/common/BinaryProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,149 +30,189 @@ namespace rtps {

class BinaryProperty
{
public:

BinaryProperty() : propagate_(false) {}

BinaryProperty(const BinaryProperty& property) :
name_(property.name_),
value_(property.value_),
propagate_(property.propagate_) {}

BinaryProperty(BinaryProperty&& property) :
name_(std::move(property.name_)),
value_(std::move(property.value_)),
propagate_(property.propagate_) {}

BinaryProperty(const std::string& name,
const std::vector<uint8_t>& value) :
name_(name), value_(value) {}

BinaryProperty(std::string&& name,
std::vector<uint8_t>&& value) :
name_(std::move(name)), value_(std::move(value)) {}

BinaryProperty& operator=(const BinaryProperty& property)
{
name_ = property.name_;
value_ = property.value_;
propagate_ = property.propagate_;
return *this;
}

BinaryProperty& operator=(BinaryProperty&& property)
{
name_ = std::move(property.name_);
value_ = std::move(property.value_);
propagate_ = property.propagate_;
return *this;
}

bool operator==(const BinaryProperty& b) const
{
return (this->name_ == b.name_) &&
(this->value_ == b.value_);
}

void name(const std::string& name)
{
name_ = name;
}

void name(std::string&& name)
{
name_ = std::move(name);
}

const std::string& name() const
{
return name_;
}

std::string& name()
{
return name_;
}

void value(const std::vector<uint8_t>& value)
{
value_ = value;
}

void value(std::vector<uint8_t>&& value)
{
value_ = std::move(value);
}

const std::vector<uint8_t>& value() const
{
return value_;
}

std::vector<uint8_t>& value()
{
return value_;
}

void propagate(bool propagate)
{
propagate_ = propagate;
}

bool propagate() const
{
return propagate_;
}

bool& propagate()
{
return propagate_;
}

private:

std::string name_;

std::vector<uint8_t> value_;

bool propagate_;
public:

BinaryProperty()
: propagate_(false)
{
}

BinaryProperty(
const BinaryProperty& property)
: name_(property.name_)
, value_(property.value_)
, propagate_(property.propagate_)
{
}

BinaryProperty(
BinaryProperty&& property)
: name_(std::move(property.name_))
, value_(std::move(property.value_))
, propagate_(property.propagate_)
{
}

BinaryProperty(
const std::string& name,
const std::vector<uint8_t>& value)
: name_(name)
, value_(value)
{
}

BinaryProperty(
std::string&& name,
std::vector<uint8_t>&& value)
: name_(std::move(name))
, value_(std::move(value))
{
}

BinaryProperty& operator =(
const BinaryProperty& property)
{
name_ = property.name_;
value_ = property.value_;
propagate_ = property.propagate_;
return *this;
}

BinaryProperty& operator =(
BinaryProperty&& property)
{
name_ = std::move(property.name_);
value_ = std::move(property.value_);
propagate_ = property.propagate_;
return *this;
}

bool operator ==(
const BinaryProperty& b) const
{
return (this->name_ == b.name_) &&
(this->value_ == b.value_);
}

void name(
const std::string& name)
{
name_ = name;
}

void name(
std::string&& name)
{
name_ = std::move(name);
}

const std::string& name() const
{
return name_;
}

std::string& name()
{
return name_;
}

void value(
const std::vector<uint8_t>& value)
{
value_ = value;
}

void value(
std::vector<uint8_t>&& value)
{
value_ = std::move(value);
}

const std::vector<uint8_t>& value() const
{
return value_;
}

std::vector<uint8_t>& value()
{
return value_;
}

void propagate(
bool propagate)
{
propagate_ = propagate;
}

bool propagate() const
{
return propagate_;
}

bool& propagate()
{
return propagate_;
}

private:

std::string name_;

std::vector<uint8_t> value_;

bool propagate_;
};

typedef std::vector<BinaryProperty> BinaryPropertySeq;

class BinaryPropertyHelper
{
public:
public:

static size_t serialized_size(const BinaryProperty& binary_property, size_t current_alignment = 0)
static size_t serialized_size(
const BinaryProperty& binary_property,
size_t current_alignment = 0)
{
if (binary_property.propagate())
{
if(binary_property.propagate())
{
size_t initial_alignment = current_alignment;
size_t initial_alignment = current_alignment;

current_alignment += 4 + alignment(current_alignment, 4) + binary_property.name().size() + 1;
current_alignment += 4 + alignment(current_alignment, 4) + binary_property.value().size();
current_alignment += 4 + alignment(current_alignment, 4) + binary_property.name().size() + 1;
current_alignment += 4 + alignment(current_alignment, 4) + binary_property.value().size();

return current_alignment - initial_alignment;
}
else
return 0;
return current_alignment - initial_alignment;
}

static size_t serialized_size(const BinaryPropertySeq& binary_properties, size_t current_alignment = 0)
else
{
size_t initial_alignment = current_alignment;
return 0;
}
}

current_alignment += 4 + alignment(current_alignment, 4);
for(auto binary_property = binary_properties.begin(); binary_property != binary_properties.end(); ++binary_property)
current_alignment += serialized_size(*binary_property, current_alignment);
static size_t serialized_size(
const BinaryPropertySeq& binary_properties,
size_t current_alignment = 0)
{
size_t initial_alignment = current_alignment;

return current_alignment - initial_alignment;
current_alignment += 4 + alignment(current_alignment, 4);
for (auto binary_property = binary_properties.begin(); binary_property != binary_properties.end();
++binary_property)
{
current_alignment += serialized_size(*binary_property, current_alignment);
}

private:
return current_alignment - initial_alignment;
}

private:

inline static size_t alignment(
size_t current_alignment,
size_t dataSize)
{
return (dataSize - (current_alignment % dataSize)) & (dataSize - 1);
}

inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);}
};

} //namespace rtps
Expand Down
2 changes: 1 addition & 1 deletion include/fastdds/rtps/reader/ReaderDiscoveryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct ReaderDiscoveryInfo
CHANGED_QOS_READER,
REMOVED_READER,
IGNORED_READER
};
}

ReaderDiscoveryInfo(
const ReaderProxyData& data)
Expand Down
13 changes: 7 additions & 6 deletions include/fastdds/rtps/resources/ResourceManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
#define _FASTDDS_RTPS_RESOURCE_MANAGEMENT_H_


namespace eprosima{
namespace fastdds{
namespace rtps{
namespace eprosima {
namespace fastdds {
namespace rtps {

/**
* Enum MemoryuManagementPolicy_t, indicated the way memory is managed in terms of dealing with CacheChanges
*/

typedef enum MemoryManagementPolicy{
typedef enum MemoryManagementPolicy
{
PREALLOCATED_MEMORY_MODE, //!< Preallocated memory. Size set to the data type maximum. Largest memory footprint but smallest allocation count.
PREALLOCATED_WITH_REALLOC_MEMORY_MODE, //!< Default size preallocated, requires reallocation when a bigger message arrives. Smaller memory footprint at the cost of an increased allocation count.
DYNAMIC_RESERVE_MEMORY_MODE, //< Dynamic allocation at the time of message arrival. Least memory footprint but highest allocation count.
Expand All @@ -38,7 +39,7 @@ typedef enum MemoryManagementPolicy{


} // end namespaces
}
}
} // namespace fastdds
} // namespace eprosima

#endif /* _FASTDDS_RTPS_RESOURCE_MANAGEMENT_H_ */
2 changes: 1 addition & 1 deletion include/fastdds/rtps/writer/WriterDiscoveryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct WriterDiscoveryInfo
CHANGED_QOS_WRITER,
REMOVED_WRITER,
IGNORED_WRITER
};
}

WriterDiscoveryInfo(
const WriterProxyData& data)
Expand Down
7 changes: 4 additions & 3 deletions include/fastrtps/common/KeyedChanges.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <fastdds/rtps/common/CacheChange.h>
#include <chrono>

namespace eprosima{
namespace fastdds{
namespace eprosima {
namespace fastdds {

/**
* @brief A struct storing a vector of cache changes and the next deadline in the group
Expand All @@ -40,7 +40,8 @@ struct KeyedChanges
}

//! Copy constructor
KeyedChanges(const KeyedChanges& other)
KeyedChanges(
const KeyedChanges& other)
: cache_changes(other.cache_changes)
, next_deadline_us(other.next_deadline_us)
{
Expand Down
Loading

0 comments on commit 5590928

Please sign in to comment.