Skip to content

Commit

Permalink
Changing clang-format to 'AllowShortFunctionsOnASingleLine: Empty'
Browse files Browse the repository at this point in the history
Signed-off-by: Remigiusz Kołłątaj <remigiusz.kollataj@mobica.com>
  • Loading branch information
Remigiusz Kołłątaj committed Aug 31, 2017
1 parent 2f6c164 commit 96e8fc9
Show file tree
Hide file tree
Showing 41 changed files with 421 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Expand Up @@ -11,7 +11,7 @@ AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
Expand Down
2 changes: 1 addition & 1 deletion src/common/cdswidget.h
@@ -1,7 +1,7 @@
#ifndef CDSWIDGET_H
#define CDSWIDGET_H
#include <QWidget>
#include <QCloseEvent>
#include <QWidget>

struct CDSWidget : public QWidget {
void closeEvent(QCloseEvent* e)
Expand Down
30 changes: 24 additions & 6 deletions src/common/datamodeltypes/candevicedata.h
Expand Up @@ -26,11 +26,17 @@ class CanDeviceDataIn : public NodeData {
* @brief Used to get data type id and displayed text for ports
* @return NodeDataType of rawsender
*/
NodeDataType type() const override { return NodeDataType{ "rawsender", "Raw" }; }
NodeDataType type() const override
{
return NodeDataType{ "rawsender", "Raw" };
}
/**
* @brief Used to get frame
*/
QCanBusFrame frame() const { return _frame; };
QCanBusFrame frame() const
{
return _frame;
};

private:
QCanBusFrame _frame;
Expand All @@ -52,22 +58,34 @@ class CanDeviceDataOut : public NodeData {
* @brief Used to get data type id and displayed text for ports
* @return NodeDataType of rawview
*/
NodeDataType type() const override { return NodeDataType{ "rawview", "Raw" }; }
NodeDataType type() const override
{
return NodeDataType{ "rawview", "Raw" };
}

/**
* @brief Used to get frame
*/
QCanBusFrame frame() const { return _frame; };
QCanBusFrame frame() const
{
return _frame;
};

/**
* @brief Used to get direction
*/
Direction direction() const { return _direction; };
Direction direction() const
{
return _direction;
};

/**
* @brief Used to get status
*/
bool status() const { return _status; };
bool status() const
{
return _status;
};

private:
QCanBusFrame _frame;
Expand Down
4 changes: 3 additions & 1 deletion src/common/guiinterface/checkboxinterface.hpp
Expand Up @@ -5,7 +5,9 @@
class QWidget;

struct CheckBoxInterface {
virtual ~CheckBoxInterface() {}
virtual ~CheckBoxInterface()
{
}

typedef std::function<void()> released_t;
virtual void releasedCbk(const released_t& cb) = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/common/guiinterface/lineeditinterface.hpp
Expand Up @@ -6,7 +6,9 @@
class QWidget;

struct LineEditInterface {
virtual ~LineEditInterface() {}
virtual ~LineEditInterface()
{
}

typedef std::function<void()> textChanged_t;
virtual void textChangedCbk(const textChanged_t& cb) = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/common/guiinterface/pushbuttoninterface.hpp
Expand Up @@ -6,7 +6,9 @@
class QWidget;

struct PushButtonInterface {
virtual ~PushButtonInterface() {}
virtual ~PushButtonInterface()
{
}

typedef std::function<void()> pressed_t;
virtual void pressedCbk(const pressed_t& cb) = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/common/log.hpp
Expand Up @@ -10,17 +10,17 @@ extern std::shared_ptr<spdlog::logger> kDefaultLogger;

#define cds_debug(fmt, ...) \
do { \
kDefaultLogger->debug("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
kDefaultLogger->debug("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
} while (0)
#define cds_warn(fmt, ...) \
do { \
kDefaultLogger->warn("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
kDefaultLogger->warn("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
} while (0)
#define cds_error(fmt, ...) \
do { \
kDefaultLogger->error("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
kDefaultLogger->error("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
} while (0)
#define cds_info(fmt, ...) \
do { \
kDefaultLogger->info("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
kDefaultLogger->info("[{}():{}@{}] " fmt, __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
} while (0)
81 changes: 38 additions & 43 deletions src/common/modelvisitor.h
Expand Up @@ -9,11 +9,10 @@

#include "visitablewith.h" // VisitableWith


class CanRawViewModel;
class CanRawSenderModel;
class CanDeviceModel;
//class FooModel;
// class FooModel;

/**
* Example usage with @c VisitableWith<CanNodeDataModelVisitor>:
Expand All @@ -31,65 +30,61 @@ class CanDeviceModel;
* // or apply_model_visitor(*m, [](CanRawViewModel&) {}, [](CanRawSenderModel&) {});
* @endcode
*/
class CanNodeDataModelVisitor
{

public:

void operator()(CanRawViewModel& a) { _f(a); }
void operator()(CanRawSenderModel& a) { _g(a); }
void operator()(CanDeviceModel& a) { _h(a); }
// void operator()(FooModel& a) { _i(a); }
class CanNodeDataModelVisitor {

public:
void operator()(CanRawViewModel& a)
{
_f(a);
}
void operator()(CanRawSenderModel& a)
{
_g(a);
}
void operator()(CanDeviceModel& a)
{
_h(a);
}
// void operator()(FooModel& a) { _i(a); }

// TODO: make apply_* insensitive to order of actions (using tuple indexed by type?)

template<
class CanRawViewModelAction
, class CanRawSenderModelAction
, class CanDeviceModelAction
// , class FooModelAction
>
CanNodeDataModelVisitor(CanRawViewModelAction f
, CanRawSenderModelAction g
, CanDeviceModelAction h
// , FooModelAction i
)
:
_f{std::move(f)}
, _g{std::move(g)}
, _h{std::move(h)}
// , _i{std::move(i)}
{}

private:

std::function<void (CanRawViewModel&)> _f;
std::function<void (CanRawSenderModel&)> _g;
std::function<void (CanDeviceModel&)> _h;
// std::function<void (FooModel&)> _i;

template <class CanRawViewModelAction, class CanRawSenderModelAction, class CanDeviceModelAction
// , class FooModelAction
>
CanNodeDataModelVisitor(CanRawViewModelAction f, CanRawSenderModelAction g, CanDeviceModelAction h
// , FooModelAction i
)
: _f{ std::move(f) }
, _g{ std::move(g) }
, _h{ std::move(h) }
// , _i{std::move(i)}
{
}

private:
std::function<void(CanRawViewModel&)> _f;
std::function<void(CanRawSenderModel&)> _g;
std::function<void(CanDeviceModel&)> _h;
// std::function<void (FooModel&)> _i;
};



/** @throws bad_cast if object under @c m is not visitable with @c v. */
inline void apply_model_visitor(QtNodes::NodeDataModel& m, CanNodeDataModelVisitor v)
{
// NOTE: Cannot use static_cast since NodeDataModel and VisitableWith
// are not in direct inheritance relation, i.e. only type derived
// from NodeDataModel derives from VisitableWith.

dynamic_cast<VisitableWith<CanNodeDataModelVisitor>&>(m).visit(v); // throws!
dynamic_cast<VisitableWith<CanNodeDataModelVisitor>&>(m).visit(v); // throws!
}

/** @throws bad_cast if object under @c m is not visitable with @c v. */
template<class... Actions>
inline void apply_model_visitor(QtNodes::NodeDataModel& m, Actions... actions)
template <class... Actions> inline void apply_model_visitor(QtNodes::NodeDataModel& m, Actions... actions)
{
CanNodeDataModelVisitor v{std::move(actions)...};
CanNodeDataModelVisitor v{ std::move(actions)... };

apply_model_visitor(m, std::move(v));
}

#endif

5 changes: 1 addition & 4 deletions src/common/visitablewith.h
Expand Up @@ -46,13 +46,10 @@
* B
*
*/
template<class Visitor>
struct VisitableWith
{
template <class Visitor> struct VisitableWith {
virtual void visit(Visitor& visitor) = 0;

virtual ~VisitableWith() = default;
};

#endif

4 changes: 3 additions & 1 deletion src/components/candevice/candevice.cpp
Expand Up @@ -14,7 +14,9 @@ CanDevice::CanDevice(CanFactoryInterface& factory)
{
}

CanDevice::~CanDevice() {}
CanDevice::~CanDevice()
{
}

bool CanDevice::init(const QString& backend, const QString& interface)
{
Expand Down
4 changes: 3 additions & 1 deletion src/components/candevice/candeviceinterface.hpp
Expand Up @@ -6,7 +6,9 @@
#include <functional>

struct CanDeviceInterface {
virtual ~CanDeviceInterface() {}
virtual ~CanDeviceInterface()
{
}

typedef std::function<void(qint64)> framesWritten_t;
typedef std::function<void()> framesReceived_t;
Expand Down
42 changes: 30 additions & 12 deletions src/components/candevice/candevicemodel.h
@@ -1,7 +1,7 @@
#ifndef CANDEVICEMODEL_H
#define CANDEVICEMODEL_H

#include "modelvisitor.h" // CanNodeDataModelVisitor
#include "modelvisitor.h" // CanNodeDataModelVisitor
#include "visitablewith.h"

#include <QtCore/QObject>
Expand All @@ -25,39 +25,51 @@ enum class Direction;
/**
* @brief The class provides node graphical representation of CanDevice
*/
class CanDeviceModel
: public NodeDataModel
, public VisitableWith<CanNodeDataModelVisitor>
{
class CanDeviceModel : public NodeDataModel, public VisitableWith<CanNodeDataModelVisitor> {
Q_OBJECT

public:
CanDeviceModel();

public:
/** @see VisitableWith */
virtual void visit(CanNodeDataModelVisitor& v) override { v(*this); }
virtual void visit(CanNodeDataModelVisitor& v) override
{
v(*this);
}

/**
* @brief Used to get node caption
* @return Node caption
*/
QString caption() const override { return QString("CanDevice Node"); } // TODO
QString caption() const override
{
return QString("CanDevice Node");
} // TODO

/**
* @brief Used to identify model by data model name
* @return Node model name
*/
QString name() const override { return QString("CanDeviceModel"); }
QString name() const override
{
return QString("CanDeviceModel");
}

std::unique_ptr<NodeDataModel> clone() const override { return std::make_unique<CanDeviceModel>(); }
std::unique_ptr<NodeDataModel> clone() const override
{
return std::make_unique<CanDeviceModel>();
}

public:
/**
* @brief Used to get model name
* @return Model name
*/
virtual QString modelName() const { return QString("CAN device"); }
virtual QString modelName() const
{
return QString("CAN device");
}

/**
* @brief Used to get number of ports of each type used by model
Expand Down Expand Up @@ -92,13 +104,19 @@ class CanDeviceModel
* @brief Used to get widget embedded in Node
* @return QLabel
*/
QWidget* embeddedWidget() override { return label; }
QWidget* embeddedWidget() override
{
return label;
}

/**
* @brief Used to get information if node is resizable
* @return false
*/
bool resizable() const override { return false; }
bool resizable() const override
{
return false;
}

/**
* @brief Used to send frames that were put in queue
Expand Down

0 comments on commit 96e8fc9

Please sign in to comment.