Skip to content

Commit

Permalink
run uncrustify
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannkar committed Aug 29, 2024
1 parent 3480d23 commit eca78b5
Show file tree
Hide file tree
Showing 14 changed files with 622 additions and 557 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ jobs:
run: docker compose -f docker/docker-compose.yaml run test-jazzy
- name: Test Rolling
run: docker compose -f docker/docker-compose.yaml run test-rolling
- name: Run Colcon Test
run: docker compose -f docker/docker-compose.yaml run colcon-test
8 changes: 8 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ services:

command: bash -c "cd /home/user/ros2_ws/src/turtle_nest_tests/build/ && make && ./turtle_nest_tests"

colcon-test:
image: turtle_nest
container_name: turtle_nest_colcon_test
profiles: ["colcon-test"]
stdin_open: true
tty: true
command: bash -c "cd /home/user/ros2_ws/ && colcon test && colcon test-result --all --verbose"

test-jazzy:
image: turtle_nest_jazzy
build:
Expand Down
9 changes: 5 additions & 4 deletions turtle_nest/include/turtle_nest/build_type_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#define BUILD_TYPE_ENUM_H


enum BuildType{
CPP,
PYTHON,
CPP_AND_PYTHON,
enum BuildType
{
CPP,
PYTHON,
CPP_AND_PYTHON,
};

#endif // BUILD_TYPE_ENUM_H
5 changes: 4 additions & 1 deletion turtle_nest/include/turtle_nest/generate_launch.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include <QString>


void generate_launch_file(QString workspace_path, QString package_name, QString launch_file_name, QString node_name_cpp = "", QString node_name_python = "", BuildType build_type = CPP);
void generate_launch_file(
QString workspace_path, QString package_name, QString launch_file_name,
QString node_name_cpp = "", QString node_name_python = "",
BuildType build_type = CPP);
QString generate_launch_text(QString package_name, QString node_name_cpp, QString node_name_python);
void append_launch_to_cmake(QString c_make_path);
void save_launch_file(QString file_name, QString launch_text);
Expand Down
56 changes: 28 additions & 28 deletions turtle_nest/include/turtle_nest/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,66 +25,66 @@

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
class MainWindow;
}
QT_END_NAMESPACE


void show_tooltip(QToolButton *button);
void show_tooltip(QToolButton * button);

class MainWindow : public QMainWindow
class MainWindow: public QMainWindow
{
Q_OBJECT
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
MainWindow(QWidget * parent = nullptr);
~MainWindow();

private slots:
void on_nextButton_clicked();
void on_nextButton_clicked();

void on_backButton_clicked();
void on_backButton_clicked();

void on_browseButton_clicked();
void on_browseButton_clicked();

void on_createPackageButton_clicked();
void on_createPackageButton_clicked();

void on_packageNameEdit_textEdited(const QString &arg1);
void on_packageNameEdit_textEdited(const QString & arg1);

void on_packageNameEdit_editingFinished();
void on_packageNameEdit_editingFinished();

void on_checkboxCreateLaunch_toggled(bool checked);
void on_checkboxCreateLaunch_toggled(bool checked);

void change_package_type();
void change_package_type();

void on_checkboxCpp_clicked();
void on_checkboxCpp_clicked();

void on_checkboxPython_clicked();
void on_checkboxPython_clicked();

void on_lineEditNodeNameCpp_textEdited(const QString &arg1);
void on_lineEditNodeNameCpp_textEdited(const QString & arg1);

void on_lineEditNodeNamePython_textEdited(const QString &arg1);
void on_lineEditNodeNamePython_textEdited(const QString & arg1);

void on_lineEditLaunchName_textEdited(const QString &arg1);
void on_lineEditLaunchName_textEdited(const QString & arg1);

void on_lineEditLaunchName_editingFinished();
void on_lineEditLaunchName_editingFinished();

QString get_license();
QString get_license();

void on_emailEdit_textEdited(const QString &arg1);
void on_emailEdit_textEdited(const QString & arg1);

void on_emailEdit_editingFinished();
void on_emailEdit_editingFinished();

void on_pkgNameInfoButton_clicked();
void on_pkgNameInfoButton_clicked();

void on_cppNodeNameInfoButton_clicked();
void on_cppNodeNameInfoButton_clicked();

void on_pythonNodeNameInfoButton_clicked();
void on_pythonNodeNameInfoButton_clicked();

void on_launchNameInfoButton_clicked();
void on_launchNameInfoButton_clicked();

private:
Ui::MainWindow *ui;
Ui::MainWindow * ui;
};

#endif // MAINWINDOW_H
55 changes: 28 additions & 27 deletions turtle_nest/include/turtle_nest/rospkgcreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,35 @@
class RosPkgCreator
{
private:
QStringList create_command() const;
void run_command(QStringList command) const;
QStringList create_command() const;
void run_command(QStringList command) const;

public:
QString workspace_path;
QString package_name;
BuildType build_type;
QString description = "";
QString maintainer_name = "";

// ROS automatically populates the email from maintainer name, if email is not provided.
// If the name contains invalid characters (or spaces) for email, the package building
// will fail. This is why we need to set this default email instead of leaving it empty.
QString maintainer_email = "todo@todo.todo";
QString node_name_cpp = "";
QString node_name_python = "";
QString launch_name = "";
QString license = "TODO: License declaration";
QString package_path;

RosPkgCreator(QString workspace_path, QString package_name, BuildType build_type) {
this->workspace_path = workspace_path;
this->package_name = package_name;
this->build_type = build_type;
this->package_path = QDir(workspace_path).filePath(package_name);
};

void create_package() const;
void build_package() const;
QString workspace_path;
QString package_name;
BuildType build_type;
QString description = "";
QString maintainer_name = "";

// ROS automatically populates the email from maintainer name, if email is not provided.
// If the name contains invalid characters (or spaces) for email, the package building
// will fail. This is why we need to set this default email instead of leaving it empty.
QString maintainer_email = "todo@todo.todo";
QString node_name_cpp = "";
QString node_name_python = "";
QString launch_name = "";
QString license = "TODO: License declaration";
QString package_path;

RosPkgCreator(QString workspace_path, QString package_name, BuildType build_type) {
this->workspace_path = workspace_path;
this->package_name = package_name;
this->build_type = build_type;
this->package_path = QDir(workspace_path).filePath(package_name);
};

void create_package() const;
void build_package() const;
};

#endif // ROSPKGCREATOR_H
4 changes: 2 additions & 2 deletions turtle_nest/include/turtle_nest/string_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

QString escape_xml(QString input);
bool is_valid_alphanumeric(QString string);
QString autocorrect_line_edit(QString text, QLineEdit* line_edit);
QString autocorrect_line_edit(QString text, QLineEdit * line_edit);
QString autocorrect_string(QString string);
bool is_valid_email(QString email);
QString to_camel_case(const QString& snake_case);
QString to_camel_case(const QString & snake_case);

#endif // STRING_TOOLS_H
120 changes: 63 additions & 57 deletions turtle_nest/src/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,75 +21,81 @@
#include <QDebug>


void create_directory(QString path){
QDir dir(path);
if (dir.exists()) {
qInfo() << "Skipping creation of directory: " + path + " (already exists).";
return;
}
void create_directory(QString path)
{
QDir dir(path);
if (dir.exists()) {
qInfo() << "Skipping creation of directory: " + path + " (already exists).";
return;
}

if (!dir.mkpath(".")) {
QString error_msg = QString("Failed to create directory \"%1\". Do you have sufficient permissions?").arg(path);
qCritical() << error_msg;
throw std::runtime_error(error_msg.toStdString());
}
if (!dir.mkpath(".")) {
QString error_msg = QString(
"Failed to create directory \"%1\". Do you have sufficient permissions?").arg(path);
qCritical() << error_msg;
throw std::runtime_error(error_msg.toStdString());
}
}

void write_file(QString path, QString content){
QFile file(path);
if (!file.open(QFile::WriteOnly | QFile::Text | QFile::Truncate)) {
QString error_msg = QString("Cannot open file %1 for writing: " + file.errorString()).arg(path);
qCritical() << error_msg;
throw std::runtime_error(error_msg.toStdString());
}
QTextStream out(&file);
out << content;
file.close();
void write_file(QString path, QString content)
{
QFile file(path);
if (!file.open(QFile::WriteOnly | QFile::Text | QFile::Truncate)) {
QString error_msg = QString("Cannot open file %1 for writing: " + file.errorString()).arg(path);
qCritical() << error_msg;
throw std::runtime_error(error_msg.toStdString());
}
QTextStream out(&file);
out << content;
file.close();
}

QString read_file(QString path){
QFile file(path);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QString error_msg = QString("Cannot open file %1 for reading: " + file.errorString()).arg(path);
qCritical() << error_msg;
throw std::runtime_error(error_msg.toStdString());
}
QTextStream in(&file);
QString content = in.readAll();
file.close();
return content;
QString read_file(QString path)
{
QFile file(path);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QString error_msg = QString("Cannot open file %1 for reading: " + file.errorString()).arg(path);
qCritical() << error_msg;
throw std::runtime_error(error_msg.toStdString());
}
QTextStream in(&file);
QString content = in.readAll();
file.close();
return content;
}

void append_to_file_before(QString file_path, QString lines_to_append, QString append_before_text){
QString content = read_file(file_path);
void append_to_file_before(QString file_path, QString lines_to_append, QString append_before_text)
{
QString content = read_file(file_path);

// Find the position to insert the lines before 'append_before_text'
int index = content.indexOf(append_before_text);
if (index != -1) {
content.insert(index, lines_to_append);
} else {
QString error_msg = "Line " + append_before_text + " not found in the file " + file_path;
throw std::runtime_error(error_msg.toStdString());
}
// Find the position to insert the lines before 'append_before_text'
int index = content.indexOf(append_before_text);
if (index != -1) {
content.insert(index, lines_to_append);
} else {
QString error_msg = "Line " + append_before_text + " not found in the file " + file_path;
throw std::runtime_error(error_msg.toStdString());
}

write_file(file_path, content);
write_file(file_path, content);
}

void append_to_file(QString file_path, QString lines_to_append, QString append_after_text){
QString content = read_file(file_path);
void append_to_file(QString file_path, QString lines_to_append, QString append_after_text)
{
QString content = read_file(file_path);

// Find the position of the 'append_after_text'
int index = content.indexOf(append_after_text);
if (index != -1) {
// Move the index to the end of the found text
index += append_after_text.length();
// Find the position of the 'append_after_text'
int index = content.indexOf(append_after_text);
if (index != -1) {
// Move the index to the end of the found text
index += append_after_text.length();

// Insert the new lines after the found text
content.insert(index, lines_to_append);
} else {
QString error_msg = "Line " + append_after_text + " not found in the file " + file_path;
throw std::runtime_error(error_msg.toStdString());
}
// Insert the new lines after the found text
content.insert(index, lines_to_append);
} else {
QString error_msg = "Line " + append_after_text + " not found in the file " + file_path;
throw std::runtime_error(error_msg.toStdString());
}

write_file(file_path, content);
write_file(file_path, content);
}
Loading

0 comments on commit eca78b5

Please sign in to comment.