Skip to content

Commit

Permalink
Uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed May 17, 2024
1 parent acf9e7b commit ab73b8d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void McapWriter::write(
on_mcap_full_nts_(e);
write_nts_(data);
}
catch(const FullDiskException& e)
catch (const FullDiskException& e)
{
logError(DDSRECORDER_MCAP_HANDLER, "FAIL_MCAP_WRITE | Disk is full. Error message:\n " << e.what());
on_disk_full_();
Expand Down
38 changes: 18 additions & 20 deletions ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ void McapHandler::add_data(
else
{
throw utils::InconsistencyException(
STR_ENTRY << "Payload owner not found in data received."
);
STR_ENTRY << "Payload owner not found in data received."
);
}
}
else
{
throw utils::InconsistencyException(
STR_ENTRY << "Received sample with no payload."
);
STR_ENTRY << "Received sample with no payload."
);
}

if (received_types_.count(topic.type_name) != 0)
Expand All @@ -267,20 +267,18 @@ void McapHandler::add_data(
}
else
{
logInfo(
DDSRECORDER_MCAP_HANDLER,
"MCAP_WRITE | Schema for topic " << topic << " not yet available. "
"Inserting to pending samples queue.");
logInfo(DDSRECORDER_MCAP_HANDLER,
"MCAP_WRITE | Schema for topic " << topic << " not yet available. "
"Inserting to pending samples queue.");

add_to_pending_nts_(msg, topic);
}
}
else if (state_ == McapHandlerStateCode::PAUSED)
{
logInfo(
DDSRECORDER_MCAP_HANDLER,
"MCAP_WRITE | Schema for topic " << topic << " not yet available. "
"Inserting to (paused) pending samples queue.");
logInfo(DDSRECORDER_MCAP_HANDLER,
"MCAP_WRITE | Schema for topic " << topic << " not yet available. "
"Inserting to (paused) pending samples queue.");

pending_samples_paused_[topic.type_name].push_back({topic, msg});
}
Expand Down Expand Up @@ -314,7 +312,7 @@ void McapHandler::start()
if (prev_state == McapHandlerStateCode::RUNNING)
{
logWarning(DDSRECORDER_MCAP_HANDLER,
"MCAP_STATE | Ignoring start command, instance already started.");
"MCAP_STATE | Ignoring start command, instance already started.");
}
else
{
Expand Down Expand Up @@ -356,7 +354,7 @@ void McapHandler::stop(
if (!on_destruction)
{
logWarning(DDSRECORDER_MCAP_HANDLER,
"MCAP_STATE | Ignoring stop command, instance already stopped.");
"MCAP_STATE | Ignoring stop command, instance already stopped.");
}
}
else
Expand All @@ -381,7 +379,7 @@ void McapHandler::stop(
pending_samples_.clear();
}
dump_data_nts_(); // if prev_state == RUNNING -> writes buffer + added pending samples (if !only_with_schema)
// if prev_state == PAUSED -> writes added pending samples (if !only_with_schema)
// if prev_state == PAUSED -> writes added pending samples (if !only_with_schema)

mcap_writer_.disable();
}
Expand All @@ -401,7 +399,7 @@ void McapHandler::pause()
if (prev_state == McapHandlerStateCode::PAUSED)
{
logWarning(DDSRECORDER_MCAP_HANDLER,
"MCAP_STATE | Ignoring pause command, instance already paused.");
"MCAP_STATE | Ignoring pause command, instance already paused.");
}
else
{
Expand Down Expand Up @@ -444,7 +442,7 @@ void McapHandler::trigger_event()
if (state_ != McapHandlerStateCode::PAUSED)
{
logWarning(DDSRECORDER_MCAP_HANDLER,
"MCAP_STATE | Ignoring trigger event command, instance is not paused.");
"MCAP_STATE | Ignoring trigger event command, instance is not paused.");
}
else
{
Expand Down Expand Up @@ -512,7 +510,7 @@ void McapHandler::add_data_nts_(
catch (const utils::InconsistencyException& e)
{
logWarning(DDSRECORDER_MCAP_HANDLER,
"MCAP_WRITE | Error adding message in topic " << topic << ". Error message:\n " << e.what());
"MCAP_WRITE | Error adding message in topic " << topic << ". Error message:\n " << e.what());
return;
}

Expand All @@ -532,8 +530,8 @@ void McapHandler::add_to_pending_nts_(
{
// Discard oldest message in pending samples
logWarning(DDSRECORDER_MCAP_HANDLER,
"MCAP_WRITE | Dropping pending sample in type " << topic.type_name << ": buffer limit (" <<
configuration_.max_pending_samples << ") reached.");
"MCAP_WRITE | Dropping pending sample in type " << topic.type_name << ": buffer limit (" <<
configuration_.max_pending_samples << ") reached.");
}
else
{
Expand Down
24 changes: 12 additions & 12 deletions ddsrecorder_participants/src/cpp/recorder/mcap/McapSizeTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void McapSizeTracker::init(
if (enabled_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to initialize already enabled tracker.");
"MCAP_WRITE | Attempting to initialize already enabled tracker.");
return;
}

Expand All @@ -76,7 +76,7 @@ void McapSizeTracker::reset(
if (!enabled_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to reset disabled tracker.");
"MCAP_WRITE | Attempting to reset disabled tracker.");
return;
}

Expand All @@ -85,13 +85,13 @@ void McapSizeTracker::reset(
if (written_mcap_size_ > space_available_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Written size exceeds available space in disk.");
"MCAP_WRITE | Written size exceeds available space in disk.");
// assert(false); // TODO: uncomment when estimation is exact
}
else if (potential_mcap_size_ != written_mcap_size_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Written size exceeds potential one.");
"MCAP_WRITE | Written size exceeds potential one.");
// assert(false); // TODO: uncomment when estimation is exact
}

Expand Down Expand Up @@ -169,7 +169,7 @@ void McapSizeTracker::attachment_to_write(
}

static constexpr bool DECREASE_MIN_MCAP_SIZE = true;
decrease_potential_mcap_size_(get_attachment_size_(payload_size_to_remove), DECREASE_MIN_MCAP_SIZE);
decrease_psizeotential_mcap_size_(get_attachment_size_(payload_size_to_remove), DECREASE_MIN_MCAP_SIZE);

attachment_to_write(payload_size_to_write);
}
Expand Down Expand Up @@ -231,7 +231,7 @@ bool McapSizeTracker::can_increase_potential_mcap_size_(
if (potential_mcap_size_ < size_to_remove)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to decrease potential size more than possible.");
"MCAP_WRITE | Attempting to decrease potential size more than possible.");
// assert(false); // TODO: uncomment when estimation is exact
return false;
}
Expand All @@ -246,7 +246,7 @@ void McapSizeTracker::check_and_increase_potential_mcap_size_(
if (!enabled_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to increase potential size in disabled tracker.");
"MCAP_WRITE | Attempting to increase potential size in disabled tracker.");
return;
}

Expand Down Expand Up @@ -276,14 +276,14 @@ void McapSizeTracker::decrease_potential_mcap_size_(
if (!enabled_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to decrease potential size in disabled tracker.");
"MCAP_WRITE | Attempting to decrease potential size in disabled tracker.");
return;
}

if (potential_mcap_size_ < size)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to decrease potential size more than possible.");
"MCAP_WRITE | Attempting to decrease potential size more than possible.");
// assert(false); // TODO: uncomment when estimation is exact
return;
}
Expand All @@ -302,22 +302,22 @@ void McapSizeTracker::check_and_increase_written_mcap_size_(
if (!enabled_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Attempting to increase written size in disabled tracker.");
"MCAP_WRITE | Attempting to increase written size in disabled tracker.");
return;
}

if ((written_mcap_size_ + size) > space_available_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Written size exceeds available space in disk.");
"MCAP_WRITE | Written size exceeds available space in disk.");
// assert(false); // TODO: uncomment when estimation is exact
return;
}

if ((written_mcap_size_ + size) > potential_mcap_size_)
{
logWarning(DDSRECORDER_MCAP_SIZE_TRACKER,
"MCAP_WRITE | Written size exceeds potential one.");
"MCAP_WRITE | Written size exceeds potential one.");
// assert(false); // TODO: uncomment when estimation is exact
return;
}
Expand Down
58 changes: 29 additions & 29 deletions ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void McapWriter::enable()
catch (const FullDiskException& e)
{
logError(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Error opening a new MCAP file: " << e.what());
"MCAP_WRITE | Error opening a new MCAP file: " << e.what());
on_disk_full_();
}

Expand Down Expand Up @@ -104,25 +104,25 @@ void McapWriter::update_dynamic_types(
std::lock_guard<std::mutex> lock(mutex_);

const auto& update_dynamic_types_payload = [&]()
{
if (dynamic_types_payload_ == nullptr)
{
logInfo(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Setting the dynamic types payload to " <<
utils::from_bytes(dynamic_types_payload.length) << ".");

size_tracker_.attachment_to_write(dynamic_types_payload.length);
}
else
{
logInfo(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Updating the dynamic types payload from " <<
utils::from_bytes(dynamic_types_payload_->length) << " to " <<
utils::from_bytes(dynamic_types_payload.length) << ".");

size_tracker_.attachment_to_write(dynamic_types_payload.length, dynamic_types_payload_->length);
}
};
{
if (dynamic_types_payload_ == nullptr)
{
logInfo(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Setting the dynamic types payload to " <<
utils::from_bytes(dynamic_types_payload.length) << ".");

size_tracker_.attachment_to_write(dynamic_types_payload.length);
}
else
{
logInfo(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Updating the dynamic types payload from " <<
utils::from_bytes(dynamic_types_payload_->length) << " to " <<
utils::from_bytes(dynamic_types_payload.length) << ".");

size_tracker_.attachment_to_write(dynamic_types_payload.length, dynamic_types_payload_->length);
}
};

try
{
Expand All @@ -135,10 +135,10 @@ void McapWriter::update_dynamic_types(
on_mcap_full_nts_(e);
update_dynamic_types_payload();
}
catch(const FullDiskException& e)
catch (const FullDiskException& e)
{
logError(DDSRECORDER_MCAP_HANDLER,
"FAIL_MCAP_WRITE | Disk is full. Error message:\n " << e.what());
"FAIL_MCAP_WRITE | Disk is full. Error message:\n " << e.what());
on_disk_full_();
}
}
Expand All @@ -163,8 +163,8 @@ void McapWriter::open_new_file_nts_(
catch (const std::invalid_argument& e)
{
throw FullDiskException(
"The minimum MCAP size (" + utils::from_bytes(min_file_size) + ") is greater than the maximum MCAP "
"size (" + utils::from_bytes(configuration_.max_file_size) + ").");
"The minimum MCAP size (" + utils::from_bytes(min_file_size) + ") is greater than the maximum MCAP "
"size (" + utils::from_bytes(configuration_.max_file_size) + ").");
}

const auto filename = file_tracker_->get_current_filename();
Expand All @@ -175,7 +175,7 @@ void McapWriter::open_new_file_nts_(
const auto error_msg = "Failed to open MCAP file " + filename + " for writing: " + status.message;

logError(DDSRECORDER_MCAP_WRITER,
"FAIL_MCAP_OPEN | " << error_msg);
"FAIL_MCAP_OPEN | " << error_msg);
throw utils::InitializationException(error_msg);
}

Expand Down Expand Up @@ -228,7 +228,7 @@ void McapWriter::write_nts_(
if (!status.ok())
{
logError(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Error writing in MCAP. Error message: " << status.message);
"MCAP_WRITE | Error writing in MCAP. Error message: " << status.message);
return;
}

Expand Down Expand Up @@ -260,7 +260,7 @@ void McapWriter::write_nts_(
if (!enabled_)
{
logWarning(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Attempting to write a message in a disabled writer.");
"MCAP_WRITE | Attempting to write a message in a disabled writer.");
return;
}

Expand All @@ -272,7 +272,7 @@ void McapWriter::write_nts_(
if (!status.ok())
{
logError(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Error writing in MCAP. Error message: " << status.message);
"MCAP_WRITE | Error writing in MCAP. Error message: " << status.message);
return;
}

Expand All @@ -293,7 +293,7 @@ void McapWriter::write_nts_(
if (!status.ok())
{
logError(DDSRECORDER_MCAP_WRITER,
"MCAP_WRITE | Error writing in MCAP. Error message: " << status.message);
"MCAP_WRITE | Error writing in MCAP. Error message: " << status.message);
return;
}

Expand Down
16 changes: 9 additions & 7 deletions ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ void FileTracker::new_file(
if (min_file_size > configuration_.max_file_size)
{
throw utils::InconsistencyException(utils::Formatter() <<
"The minimum file size (" + utils::from_bytes(min_file_size) + ") is greater than the maximum file "
"size (" + utils::from_bytes(configuration_.max_file_size) + ").");
"The minimum file size (" <<
utils::from_bytes(min_file_size) << ") is greater than the maximum file size (" <<
utils::from_bytes(configuration_.max_file_size) << ").");
}

const std::uint64_t free_space = configuration_.max_size - size_;
Expand Down Expand Up @@ -139,7 +140,7 @@ void FileTracker::close_file() noexcept
{
std::filesystem::rename(get_current_filename(), current_file_.name);
}
catch(const std::filesystem::filesystem_error& e)
catch (const std::filesystem::filesystem_error& e)
{
logError(DDSRECORDER_FILE_TRACKER,
"Error renaming " + get_current_filename() + ": " << e.what());
Expand All @@ -164,17 +165,18 @@ void FileTracker::set_current_file_size(
if (file_size > configuration_.max_file_size)
{
logWarning(DDSRECORDER_FILE_TRACKER,
"The file's size (" << utils::from_bytes(file_size) << ") is greater than the maximum file size (" <<
utils::from_bytes(configuration_.max_file_size) << ").");
"The file's size (" << utils::from_bytes(file_size) << ") is greater than the maximum file size (" <<
utils::from_bytes(configuration_.max_file_size) << ").");
}

const auto size_diff = file_size - current_file_.size;

if (size_ + size_diff > configuration_.max_size)
{
logWarning(DDSRECORDER_FILE_TRACKER,
"The aggregate output size (" << utils::from_bytes(file_size) << ") is greater than the maximum size (" <<
utils::from_bytes(configuration_.max_file_size) << ").");
"The aggregate output size (" <<
utils::from_bytes(file_size) << ") is greater than the maximum size (" <<
utils::from_bytes(configuration_.max_file_size) << ").");
}

current_file_.size = file_size;
Expand Down

0 comments on commit ab73b8d

Please sign in to comment.