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 11, 2024
1 parent 603a465 commit 0693f61
Show file tree
Hide file tree
Showing 17 changed files with 361 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
4 changes: 3 additions & 1 deletion include/fastdds/rtps/reader/ReaderDiscoveryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct ReaderDiscoveryInfo

//!Enum DISCOVERY_STATUS, four different status for discovered readers.
//!@ingroup RTPS_MODULE
// *INDENT-OFF* : Does not understand the #if correctly and ends up removing the ;
// at the end of the enum, which does not build.
#if defined(_WIN32)
enum FASTDDS_EXPORTED_API DISCOVERY_STATUS
#else
Expand All @@ -48,7 +50,7 @@ struct ReaderDiscoveryInfo
REMOVED_READER,
IGNORED_READER
};

// *INDENT-ON*
ReaderDiscoveryInfo(
const ReaderProxyData& data)
: status(DISCOVERED_READER)
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_ */
4 changes: 3 additions & 1 deletion include/fastdds/rtps/writer/WriterDiscoveryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct WriterDiscoveryInfo

//!Enum DISCOVERY_STATUS, four different status for discovered writers.
//!@ingroup RTPS_MODULE
// *INDENT-OFF* : Does not understand the #if correctly and ends up removing the ;
// at the end of the enum, which does not build.
#if defined(_WIN32)
enum FASTDDS_EXPORTED_API DISCOVERY_STATUS
#else
Expand All @@ -46,7 +48,7 @@ struct WriterDiscoveryInfo
REMOVED_WRITER,
IGNORED_WRITER
};

// *INDENT-ON*
WriterDiscoveryInfo(
const WriterProxyData& data)
: status(DISCOVERED_WRITER)
Expand Down
Loading

0 comments on commit 0693f61

Please sign in to comment.