Skip to content

Commit

Permalink
[clang-tidy]
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jun 26, 2024
1 parent 08c4957 commit 834509b
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 58 deletions.
6 changes: 3 additions & 3 deletions include/mementar/API/mementar/ActionsPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ namespace mementar {
explicit ActionsPublisher(const std::string& name = "");

void insert(const std::string& name, time_t start_stamp = time(nullptr), time_t end_stamp = 0);
void insert(const std::string& name, compat::mem_ros::Time start_stamp = compat::mem_ros::Node::get().currentTime(), compat::mem_ros::Time end_stamp = compat::mem_ros::Time(0));
void insert(const std::string& name, const compat::mem_ros::Time& start_stamp = compat::mem_ros::Node::get().currentTime(), const compat::mem_ros::Time& end_stamp = compat::mem_ros::Time(0));

void insertEnd(const std::string& name, time_t end_stamp = time(nullptr));
void insertEnd(const std::string& name, compat::mem_ros::Time end_stamp = compat::mem_ros::Node::get().currentTime());
void insertEnd(const std::string& name, const compat::mem_ros::Time& end_stamp = compat::mem_ros::Node::get().currentTime());

/// @brief Register a callback function to get notifications from the feeder.
/// @param callback is the callback function taking a string.
Expand All @@ -29,7 +29,7 @@ namespace mementar {
compat::mem_ros::Subscriber<std_msgs_compat::String> feeder_notif_sub_;

void publish(const std::string& name, time_t start_stamp, time_t end_stamp);
void publish(const std::string& name, compat::mem_ros::Time start_stamp, compat::mem_ros::Time end_stamp);
void publish(const std::string& name, const compat::mem_ros::Time& start_stamp, const compat::mem_ros::Time& end_stamp);

void feederNotificationCallback(const compat::mem_ros::MessageWrapper<std_msgs_compat::String>& msg);
};
Expand Down
4 changes: 2 additions & 2 deletions include/mementar/API/mementar/OccasionsPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace mementar {
public:
OccasionsPublisher(const std::string& name = "");

void insert(const Fact& fact, mementar::compat::mem_ros::Time stamp = compat::mem_ros::Node::get().currentTime());
void insert(const Fact& fact, const mementar::compat::mem_ros::Time& stamp = compat::mem_ros::Node::get().currentTime());
void insert(const Fact& fact, time_t end_stamp);

/// @brief Register a callback function to get notifications from the feeder.
Expand All @@ -27,7 +27,7 @@ namespace mementar {
compat::mem_ros::Publisher<compat::StampedString> pub_;
compat::mem_ros::Subscriber<std_msgs_compat::String> feeder_notif_sub_;

void publish(const std::string& str, mementar::compat::mem_ros::Time stamp = compat::mem_ros::Node::get().currentTime());
void publish(const std::string& str, const mementar::compat::mem_ros::Time& stamp = compat::mem_ros::Node::get().currentTime());
void publish(const std::string& str, time_t end_stamp);

void feederNotificationCallback(const compat::mem_ros::MessageWrapper<std_msgs_compat::String>& msg);
Expand Down
2 changes: 1 addition & 1 deletion include/mementar/RosInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace mementar {
return (onto_name.empty()) ? "/ontologenius/" + topic_name : "/ontologenius/" + topic_name + "/" + onto_name;
}

double rosTime2Double(double s, int ns);
double rosTime2Double(double s, uint32_t ns);
};

} // namespace mementar
Expand Down
8 changes: 7 additions & 1 deletion include/mementar/compat/ros.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,15 @@ namespace mementar::compat {
class Time : public RosTime
{
public:
#if MEME_ROS_VERSION == 1
Time(uint32_t sec, uint32_t nsec) : RosTime(sec, nsec) {}

explicit Time(double t) : RosTime((uint32_t)t, (uint32_t)((t - std::floor(t)) * 1'000'000'000.)) {}
#elif MEME_ROS_VERSION == 2
Time(uint32_t sec, uint32_t nsec) : RosTime((int32_t)sec, nsec) {}

explicit Time(double t) : RosTime((int32_t)t, (uint32_t)((t - std::floor(t)) * 1'000'000'000.)) {}
#endif

Time(const RosTime& time) : RosTime(time) {} // do not put it as explicit

Expand All @@ -174,7 +180,7 @@ namespace mementar::compat {
#if MEME_ROS_VERSION == 1
return sec;
#elif MEME_ROS_VERSION == 2
return RosTime::seconds();
return (uint32_t)RosTime::seconds();
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace mementar {
std::vector<CompressedLeafNode*> compressed_childs_;
std::vector<ArchivedLeaf> archived_childs_;
std::vector<CompressedLeafNodeSession*> archived_sessions_tree_;
std::vector<int> archived_sessions_timeout_; // ms
std::vector<long> archived_sessions_timeout_; // ms
std::vector<bool> modified_;

SoftPoint::Ttime earlier_key_;
Expand Down
1 change: 0 additions & 1 deletion include/mementar/core/Occasions/OccasionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace mementar {
bool isRunning() const { return run_; }

private:
onto::OntologyManipulator* onto_;
Subscription subscription_;
std::atomic<bool> run_;

Expand Down
2 changes: 1 addition & 1 deletion include/mementar/core/feeder/FeederEcho.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace mementar {
ros_msg.subject = message->subject_;
ros_msg.predicat = message->predicat_;
ros_msg.object = message->object_;
ros_msg.added = message->add_ ? 1 : 0;
ros_msg.added = message->add_;
feeder_echo_pub_.publish(ros_msg);
}
echo_messages_.clear();
Expand Down
6 changes: 3 additions & 3 deletions src/API/mementar/ActionsPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace mementar {
publish(name, start_stamp, end_stamp);
}

void ActionsPublisher::insert(const std::string& name, compat::mem_ros::Time start_stamp, compat::mem_ros::Time end_stamp)
void ActionsPublisher::insert(const std::string& name, const compat::mem_ros::Time& start_stamp, const compat::mem_ros::Time& end_stamp)
{
publish(name, start_stamp, end_stamp);
}
Expand All @@ -27,7 +27,7 @@ namespace mementar {
publish(name, 0, end_stamp);
}

void ActionsPublisher::insertEnd(const std::string& name, compat::mem_ros::Time end_stamp)
void ActionsPublisher::insertEnd(const std::string& name, const compat::mem_ros::Time& end_stamp)
{
publish(name, compat::mem_ros::Time(0), end_stamp);
}
Expand All @@ -41,7 +41,7 @@ namespace mementar {
pub_.publish(msg);
}

void ActionsPublisher::publish(const std::string& name, compat::mem_ros::Time start_stamp, compat::mem_ros::Time end_stamp)
void ActionsPublisher::publish(const std::string& name, const compat::mem_ros::Time& start_stamp, const compat::mem_ros::Time& end_stamp)
{
compat::MementarAction msg;
msg.name = name;
Expand Down
4 changes: 2 additions & 2 deletions src/API/mementar/OccasionsPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace mementar {
feeder_notif_sub_(name.empty() ? "mementar/feeder_notifications" : "mementar/feeder_notifications/" + name, 1000, &OccasionsPublisher::feederNotificationCallback, this)
{}

void OccasionsPublisher::insert(const Fact& fact, compat::mem_ros::Time stamp)
void OccasionsPublisher::insert(const Fact& fact, const compat::mem_ros::Time& stamp)
{
publish(fact(), stamp);
}
Expand All @@ -23,7 +23,7 @@ namespace mementar {
publish(fact(), stamp);
}

void OccasionsPublisher::publish(const std::string& str, compat::mem_ros::Time stamp)
void OccasionsPublisher::publish(const std::string& str, const compat::mem_ros::Time& stamp)
{
compat::StampedString msg;
msg.data = str;
Expand Down
4 changes: 2 additions & 2 deletions src/API/mementar/OccasionsSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace mementar {
}

if(done)
ids_.erase(ids_.begin() + i);
ids_.erase(ids_.begin() + (int)i);
else
i++;
}
Expand All @@ -84,7 +84,7 @@ namespace mementar {
if(it != ids_.end())
{
callback_(Fact(msg.data));
if(msg.last != 0)
if(msg.last)
ids_.erase(it);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/RosInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace mementar {
*
****************/

double RosInterface::rosTime2Double(double s, int ns)
double RosInterface::rosTime2Double(double s, uint32_t ns)
{
ns = ns / 100000000;
double res = (double)ns / 10.;
Expand All @@ -181,7 +181,7 @@ namespace mementar {

void RosInterface::knowledgeCallback(const compat::mem_ros::MessageWrapper<compat::StampedString>& msg)
{
feeder_.storeFact(msg->data, std::time(nullptr));
feeder_.storeFact(msg->data, (SoftPoint::Ttime)std::time(nullptr));
}

void RosInterface::stampedKnowledgeCallback(const compat::mem_ros::MessageWrapper<compat::StampedString>& msg)
Expand Down
1 change: 1 addition & 0 deletions src/compat/ros.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mementar/compat/ros.h"

#include <string>
#include <thread>

namespace mementar::compat::mem_ros {

Expand Down
5 changes: 2 additions & 3 deletions src/core/LtManagement/EpisodicTree/ArchivedLeafNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ namespace mementar {
order_(order),
earlier_key_(0),
ask_for_new_tree_(false),
running_(false)
running_(true)
{
loadStoredData();

running_ = true;
session_cleaner_ = std::move(std::thread(&ArchivedLeafNode::clean, this));
}

Expand Down Expand Up @@ -400,7 +399,7 @@ namespace mementar {
if(cpt-- == 0)
{
cpt = rate;
SoftPoint::Ttime now = std::time(nullptr);
time_t now = std::time(nullptr);
for(size_t i = 0; i < archived_sessions_timeout_.size(); i++)
{
if((archived_sessions_tree_[i] != nullptr) &&
Expand Down
4 changes: 2 additions & 2 deletions src/core/LtManagement/EpisodicTree/CompressedLeafNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace mementar {
if(compressed_sessions_tree_[i] != nullptr)
{
if(modified_[i])
compressed_childs_[i] = std::move(CompressedLeaf(compressed_sessions_tree_[i], directory_));
compressed_childs_[i] = CompressedLeaf(compressed_sessions_tree_[i], directory_);
delete compressed_sessions_tree_[i];
}
Display::percent((++leafs_cpt) * 100 / nb_leafs);
Expand Down Expand Up @@ -467,7 +467,7 @@ namespace mementar {
{
mut_.lock();
if(modified_[i])
compressed_childs_[i] = std::move(CompressedLeaf(compressed_sessions_tree_[i], directory_));
compressed_childs_[i] = CompressedLeaf(compressed_sessions_tree_[i], directory_);
delete compressed_sessions_tree_[i];
compressed_sessions_tree_[i] = nullptr;
mut_.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ namespace mementar {
int8_t to_add = (int8_t)type_1_size_;
do
{
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_);
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_); // NOLINT

const uint8_t added = 8 - minor_index_;

value >>= (uint8_t)added;
to_add -= (int8_t)added;
to_add -= (int8_t)added; // NOLINT
if(to_add >= 0)
{
if(data_.size() <= ++major_index_)
Expand All @@ -45,12 +45,12 @@ namespace mementar {
int8_t to_add = (int8_t)type_2_size_;
do
{
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_);
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_); // NOLINT

const uint8_t added = 8 - minor_index_;

value >>= (uint8_t)added;
to_add -= (int8_t)added;
to_add -= (int8_t)added; // NOLINT
if(to_add >= 0)
{
if(data_.size() <= ++major_index_)
Expand All @@ -70,12 +70,12 @@ namespace mementar {
int8_t to_add = (int8_t)type_3_size_;
do
{
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_);
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_); // NOLINT

const uint8_t added = 8 - minor_index_;

value >>= (uint8_t)added;
to_add -= (int8_t)added;
to_add -= (int8_t)added; // NOLINT
if(to_add >= 0)
{
if(data_.size() <= ++major_index_)
Expand All @@ -95,12 +95,12 @@ namespace mementar {
int8_t to_add = (int8_t)type_4_size_;
do
{
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_);
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_); // NOLINT

const uint8_t added = 8 - minor_index_;

value >>= (uint8_t)added;
to_add -= (int8_t)added;
to_add -= (int8_t)added; // NOLINT
if(to_add >= 0)
{
if(data_.size() <= ++major_index_)
Expand All @@ -120,12 +120,12 @@ namespace mementar {
int8_t to_add = (int8_t)size;
do
{
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_);
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_); // NOLINT

const uint8_t added = 8 - minor_index_;

value >>= (uint8_t)added;
to_add -= (int8_t)added;
to_add -= (int8_t)added; // NOLINT
if(to_add >= 0)
{
if(data_.size() <= ++major_index_)
Expand All @@ -145,7 +145,7 @@ namespace mementar {
for(uint32_t i = 1 << (size - 1); i > 0; i >>= 1)
{
if((value & i) != 0)
data_[major_index_] |= (1 << minor_index_);
data_[major_index_] |= (1 << minor_index_); // NOLINT

minor_index_++;
if(minor_index_ > 7)
Expand All @@ -162,12 +162,12 @@ namespace mementar {
int8_t to_add = 7;
do
{
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_);
data_[major_index_] |= ((value & ~(0xffffffff << to_add)) << minor_index_); // NOLINT

const uint8_t added = 8 - minor_index_;

value >>= added; // NOLINT
to_add -= (int8_t)added;
value >>= added; // NOLINT
to_add -= (int8_t)added; // NOLINT
if(to_add >= 0)
{
if(data_.size() <= ++major_index_)
Expand All @@ -184,7 +184,7 @@ namespace mementar {

void BitFileGenerator::writeBitTrue()
{
data_[major_index_] |= (1 << minor_index_);
data_[major_index_] |= (1 << minor_index_); // NOLINT
if((7 - minor_index_) != 0)
{
++minor_index_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace mementar {

const uint8_t getted = (minor_index_ + to_get > 7) ? 8 - minor_index_ : to_get;

to_get -= (int8_t)getted;
to_get -= (int8_t)getted; // NOLINT
if(to_get > 0)
{
current_data_ = data_[++major_index_];
Expand Down Expand Up @@ -61,7 +61,7 @@ namespace mementar {

const uint8_t getted = (minor_index_ + to_get > 7) ? 8 - minor_index_ : to_get;

to_get -= (int8_t)getted;
to_get -= (int8_t)getted; // NOLINT
if(to_get > 0)
{
current_data_ = data_[++major_index_];
Expand Down Expand Up @@ -94,7 +94,7 @@ namespace mementar {

const uint8_t getted = (minor_index_ + to_get > 7) ? 8 - minor_index_ : to_get;

to_get -= (int8_t)getted;
to_get -= (int8_t)getted; // NOLINT
if(to_get > 0)
{
current_data_ = data_[++major_index_];
Expand Down Expand Up @@ -127,7 +127,7 @@ namespace mementar {

const uint8_t getted = (minor_index_ + to_get > 7) ? 8 - minor_index_ : to_get;

to_get -= (int8_t)getted;
to_get -= (int8_t)getted; // NOLINT
if(to_get > 0)
{
current_data_ = data_[++major_index_];
Expand Down Expand Up @@ -160,7 +160,7 @@ namespace mementar {

const uint8_t getted = (minor_index_ + to_get > 7) ? 8 - minor_index_ : to_get;

to_get -= (int8_t)getted;
to_get -= (int8_t)getted; // NOLINT
if(to_get > 0)
{
current_data_ = data_[++major_index_];
Expand Down
Loading

0 comments on commit 834509b

Please sign in to comment.