Const correctness, override keyword, a bunch of stuff..

This commit is contained in:
Murat
2020-08-08 23:12:43 +02:00
parent 4099d12d9a
commit 4a688b932a
144 changed files with 622 additions and 566 deletions

View File

@@ -25,7 +25,7 @@ namespace hyperion
Q_OBJECT
public:
BlackBorderProcessor(Hyperion* hyperion, QObject* parent);
~BlackBorderProcessor();
~BlackBorderProcessor() override;
///
/// Return the current (detected) border
/// @return The current border

View File

@@ -32,7 +32,7 @@ public:
/// @param port port number on which to start listening for connections
///
BoblightServer(Hyperion* hyperion, const QJsonDocument& config);
~BoblightServer();
~BoblightServer() override;
///
/// @return the port number on which this TCP listens for incoming connections
@@ -41,7 +41,7 @@ public:
/// @return true if server is active (bind to a port)
///
bool active();
bool active() const;
public slots:
///

View File

@@ -44,7 +44,7 @@ class BonjourServiceBrowser : public QObject
Q_OBJECT
public:
BonjourServiceBrowser(QObject *parent = 0);
~BonjourServiceBrowser();
~BonjourServiceBrowser() override;
void browseForServiceType(const QString &serviceType);
inline QList<BonjourRecord> currentRecords() const { return bonjourRecords; }
inline QString serviceType() const { return browsingType; }

View File

@@ -45,13 +45,13 @@ class BonjourServiceRegister : public QObject
Q_OBJECT
public:
BonjourServiceRegister(QObject *parent = 0);
~BonjourServiceRegister();
~BonjourServiceRegister() override;
void registerService(const QString& service, int port);
void registerService(const BonjourRecord &record, quint16 servicePort, std::vector<std::pair<std::string, std::string>> txt = std::vector<std::pair<std::string, std::string>>());
inline BonjourRecord registeredRecord() const {return finalRecord; }
void registerService(const QString& service, int port);
void registerService(const BonjourRecord &record, quint16 servicePort, const std::vector<std::pair<std::string, std::string>>& txt = {});
inline BonjourRecord registeredRecord() const { return finalRecord; }
quint16 getPort() const { return _port; };
quint16 getPort() const { return _port; }
signals:
void error(DNSServiceErrorType error);
@@ -69,8 +69,8 @@ private:
QSocketNotifier *bonjourSocket;
BonjourRecord finalRecord;
// current port
quint16 _port = 0;
// current port
quint16 _port = 0;
};
#endif // BONJOURSERVICEREGISTER_H

View File

@@ -44,8 +44,8 @@ class BonjourServiceResolver : public QObject
{
Q_OBJECT
public:
BonjourServiceResolver(QObject *parent);
~BonjourServiceResolver();
BonjourServiceResolver(QObject *parent);
~BonjourServiceResolver() override;
bool resolveBonjourRecord(const BonjourRecord &record);

View File

@@ -12,6 +12,7 @@ class ColorOption: public Option
{
protected:
QColor _color;
public:
ColorOption(const QString &name,
const QString &description = QString(),
@@ -31,9 +32,8 @@ public:
: Option(other)
{}
virtual bool validate(Parser & parser, QString & value) override;
QColor getColor(Parser &parser)
{ return _color; }
bool validate(Parser & parser, QString & value) override;
QColor getColor(Parser &parser) const { return _color; }
};
}

View File

@@ -12,6 +12,7 @@ class ColorsOption: public Option
{
protected:
QList<QColor> _colors;
public:
ColorsOption(const QString &name,
const QString &description = QString(),
@@ -20,6 +21,7 @@ public:
)
: Option(name, description, valueName, defaultValue)
{}
ColorsOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
@@ -27,13 +29,13 @@ public:
)
: Option(names, description, valueName, defaultValue)
{}
ColorsOption(const QCommandLineOption &other)
: Option(other)
{}
virtual bool validate(Parser & parser, QString & value) override;
QList<QColor> &getColors(Parser &parser)
{ return _colors; }
QList<QColor> getColors(Parser &parser) const { return _colors; }
};
}

View File

@@ -12,6 +12,7 @@ class ImageOption: public Option
{
protected:
QImage _image;
public:
ImageOption(const QString &name,
const QString &description = QString(),
@@ -20,6 +21,7 @@ public:
)
: Option(name, description, valueName, defaultValue)
{}
ImageOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
@@ -27,13 +29,13 @@ public:
)
: Option(names, description, valueName, defaultValue)
{}
ImageOption(const QCommandLineOption &other)
: Option(other)
{}
virtual bool validate(Parser & parser, QString & value) override;
QImage &getImage(Parser &parser)
{ return _image; }
bool validate(Parser & parser, QString & value) override;
QImage& getImage(Parser &parser) { return _image; }
};
}

View File

@@ -12,6 +12,7 @@ class IntOption: public ValidatorOption
{
protected:
int _int;
public:
IntOption(const QString &name,
const QString &description = QString(),
@@ -19,18 +20,26 @@ public:
const QString &defaultValue = QString(),
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
: ValidatorOption(name, description, valueName, defaultValue)
{ setValidator(new QIntValidator(minimum, maximum)); }
{
setValidator(new QIntValidator(minimum, maximum));
}
IntOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
: ValidatorOption(names, description, valueName, defaultValue)
{ setValidator(new QIntValidator(minimum, maximum)); }
{
setValidator(new QIntValidator(minimum, maximum));
}
IntOption(const QCommandLineOption &other,
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
: ValidatorOption(other)
{ setValidator(new QIntValidator(minimum, maximum)); }
{
setValidator(new QIntValidator(minimum, maximum));
}
int getInt(Parser &parser, bool *ok = 0, int base = 10);
int *getIntPtr(Parser &parser, bool *ok = 0, int base = 10);

View File

@@ -26,13 +26,12 @@ public:
);
Option(const QCommandLineOption &other);
virtual ~Option() = default;
virtual bool validate(Parser &parser, QString &value);
QString name();
QString getError();
QString value(Parser &parser);
const char* getCString(Parser &parser);
QString name() const;
QString getError() const;
QString value(Parser &parser) const;
const char* getCString(Parser &parser) const;
protected:
QString _error;

View File

@@ -93,76 +93,108 @@ public:
return *option;
}
Parser(QString description=QString())
Parser(const QString& description = QString())
{
if(description.size())setApplicationDescription(description);
if(description.size())
setApplicationDescription(description);
};
QCommandLineOption addHelpOption()
{
return _parser.addHelpOption();
};
bool addOption(Option &option);
bool addOption(Option *option);
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
{
_parser.addPositionalArgument(name, description, syntax);
};
QCommandLineOption addVersionOption()
{
{
return _parser.addVersionOption();
};
QString applicationDescription() const
{ return _parser.applicationDescription(); }
void clearPositionalArguments()
{ _parser.clearPositionalArguments(); }
QString helpText() const
{ return _parser.helpText(); }
bool isSet(const QString &name) const
{ return _parser.isSet(name); }
bool isSet(const Option &option) const
{ return _parser.isSet(option); }
bool isSet(const Option *option) const
{ return _parser.isSet(*option); }
QStringList optionNames() const
{ return _parser.optionNames(); }
QStringList positionalArguments() const
{ return _parser.positionalArguments(); }
void setApplicationDescription(const QString &description)
{ _parser.setApplicationDescription(description); }
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
{ _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); }
void showHelp(int exitCode = 0)
{ _parser.showHelp(exitCode); }
QStringList unknownOptionNames() const
{ return _parser.unknownOptionNames(); }
QString value(const QString &optionName) const
{ return _parser.value(optionName); }
QString value(const Option &option) const
{ return _parser.value(option); }
QStringList values(const QString &optionName) const
{ return _parser.values(optionName); }
QStringList values(const Option &option) const
{ return _parser.values(option); }
QString applicationDescription() const
{
return _parser.applicationDescription();
}
void clearPositionalArguments()
{
_parser.clearPositionalArguments();
}
QString helpText() const
{
return _parser.helpText();
}
bool isSet(const QString &name) const
{
return _parser.isSet(name);
}
bool isSet(const Option &option) const
{
return _parser.isSet(option);
}
bool isSet(const Option *option) const
{
return _parser.isSet(*option);
}
QStringList optionNames() const
{
return _parser.optionNames();
}
QStringList positionalArguments() const
{
return _parser.positionalArguments();
}
void setApplicationDescription(const QString &description)
{
_parser.setApplicationDescription(description);
}
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
{
_parser.setSingleDashWordOptionMode(singleDashWordOptionMode);
}
void showHelp(int exitCode = 0)
{
_parser.showHelp(exitCode);
}
QStringList unknownOptionNames() const
{
return _parser.unknownOptionNames();
}
QString value(const QString &optionName) const
{
return _parser.value(optionName);
}
QString value(const Option &option) const
{
return _parser.value(option);
}
QStringList values(const QString &optionName) const
{
return _parser.values(optionName);
}
QStringList values(const Option &option) const
{
return _parser.values(option);
}
};
}

View File

@@ -17,12 +17,14 @@ public:
const QString &defaultValue = QString())
: ValidatorOption(name, description, valueName, defaultValue)
{}
RegularExpressionOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString())
: ValidatorOption(names, description, valueName, defaultValue)
{}
RegularExpressionOption(const QCommandLineOption &other)
: ValidatorOption(other)
{}
@@ -33,18 +35,26 @@ public:
const QString &defaultValue = QString(),
const QRegularExpression &expression = QRegularExpression())
: ValidatorOption(name, description, valueName, defaultValue)
{ setValidator(new QRegularExpressionValidator(expression)); }
{
setValidator(new QRegularExpressionValidator(expression));
}
RegularExpressionOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
const QRegularExpression &expression = QRegularExpression())
: ValidatorOption(names, description, valueName, defaultValue)
{ setValidator(new QRegularExpressionValidator(expression)); }
{
setValidator(new QRegularExpressionValidator(expression));
}
RegularExpressionOption(const QCommandLineOption &other,
const QRegularExpression &expression = QRegularExpression())
: ValidatorOption(other)
{ setValidator(new QRegularExpressionValidator(expression)); }
{
setValidator(new QRegularExpressionValidator(expression));
}
RegularExpressionOption(const QString &name,
const QString &description = QString(),
@@ -52,18 +62,26 @@ public:
const QString &defaultValue = QString(),
const QString &expression = QString())
: ValidatorOption(name, description, valueName, defaultValue)
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
{
setValidator(new QRegularExpressionValidator(QRegularExpression(expression)));
}
RegularExpressionOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
const QString &expression = QString())
: ValidatorOption(names, description, valueName, defaultValue)
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
{
setValidator(new QRegularExpressionValidator(QRegularExpression(expression)));
}
RegularExpressionOption(const QCommandLineOption &other,
const QString &expression = QString())
: ValidatorOption(other)
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
{
setValidator(new QRegularExpressionValidator(QRegularExpression(expression)));
}
};
}

View File

@@ -30,8 +30,6 @@ public:
: Option(other), _switches(switches)
{}
virtual ~SwitchOption() {}
const QMap<QString, T> &getSwitches() const { return _switches; }
virtual bool validate(Parser &parser, QString &switch_) override { return hasSwitch(switch_); }
bool hasSwitch(const QString &switch_) { return _switches.contains(switch_.toLower()); }

View File

@@ -13,6 +13,7 @@ class ValidatorOption: public Option
protected:
const QValidator *validator;
virtual void setValidator(const QValidator *validator);
public:
ValidatorOption(const QString &name,
const QString &description = QString(),
@@ -21,6 +22,7 @@ public:
const QValidator *validator = nullptr)
: Option(name, description, valueName, defaultValue), validator(validator)
{}
ValidatorOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
@@ -28,6 +30,7 @@ public:
const QValidator *validator = nullptr)
: Option(names, description, valueName, defaultValue), validator(validator)
{}
ValidatorOption(const QCommandLineOption &other,
const QValidator *validator = nullptr)
: Option(other), validator(validator)

View File

@@ -29,7 +29,6 @@ public:
// create table columns
createTable(QStringList()<<"user TEXT"<<"password BLOB"<<"token BLOB"<<"salt BLOB"<<"comment TEXT"<<"id TEXT"<<"created_at TEXT"<<"last_use TEXT");
};
~AuthTable(){};
///
/// @brief Create a user record, if called on a existing user the auth is recreated

View File

@@ -27,7 +27,7 @@ class DBManager : public QObject
public:
DBManager(QObject* parent = nullptr);
~DBManager();
~DBManager() override;
/// set root path
void setRootPath(const QString& rootPath);

View File

@@ -27,9 +27,7 @@ public:
// start/create the first Hyperion instance index 0
createInstance();
};
~InstanceTable(){};
///
/// @brief Create a new Hyperion instance entry, the name needs to be unique

View File

@@ -23,13 +23,12 @@ public:
setTable("meta");
createTable(QStringList()<<"uuid TEXT"<<"created_at TEXT");
};
~MetaTable(){};
///
/// @brief Get the uuid, if the uuid is not set it will be created
/// @return The uuid
///
inline const QString getUUID()
inline QString getUUID() const
{
QVector<QVariantMap> results;
getRecords(results, QStringList() << "uuid");

View File

@@ -23,7 +23,6 @@ public:
// create table columns
createTable(QStringList()<<"type TEXT"<<"config TEXT"<<"hyperion_inst INTEGER"<<"updated_at TEXT");
};
~SettingsTable(){};
///
/// @brief Create or update a settings record

View File

@@ -38,23 +38,23 @@ public:
, const QJsonObject &args = QJsonObject()
, const QString &imageData = ""
);
virtual ~Effect();
~Effect() override;
virtual void run();
void run() override;
int getPriority() const { return _priority; };
int getPriority() const { return _priority; }
///
/// @brief Set manual interuption to true,
/// Note: DO NOT USE QThread::interuption!
///
void requestInterruption() { _interupt = true; };
void requestInterruption() { _interupt = true; }
///
/// @brief Check if the interuption flag has been set
/// @return The flag state
///
bool isInterruptionRequested() { return _interupt; };
bool isInterruptionRequested() { return _interupt; }
QString getScript() const { return _script; }
QString getName() const { return _name; }

View File

@@ -27,17 +27,17 @@ class EffectEngine : public QObject
public:
EffectEngine(Hyperion * hyperion);
virtual ~EffectEngine();
~EffectEngine() override;
const std::list<EffectDefinition> & getEffects() const { return _availableEffects; };
std::list<EffectDefinition> getEffects() const { return _availableEffects; }
const std::list<ActiveEffectDefinition> & getActiveEffects();
std::list<ActiveEffectDefinition> getActiveEffects() const;
///
/// Get available schemas from EffectFileHandler
/// @return all schemas
///
const std::list<EffectSchema> & getEffectSchemas();
std::list<EffectSchema> getEffectSchemas() const;
///
/// @brief Save an effect with EffectFileHandler
@@ -115,8 +115,6 @@ private:
std::list<Effect *> _activeEffects;
std::list<ActiveEffectDefinition> _availableActiveEffects;
std::list<ActiveEffectDefinition> _cachedActiveEffects;
Logger * _log;

View File

@@ -20,12 +20,12 @@ public:
///
/// @brief Get all available effects
///
const std::list<EffectDefinition> & getEffects() const { return _availableEffects; };
std::list<EffectDefinition> getEffects() const { return _availableEffects; }
///
/// @brief Get all available schemas
///
const std::list<EffectSchema> & getEffectSchemas() { return _effectSchemas; };
std::list<EffectSchema> getEffectSchemas() const { return _effectSchemas; }
///
/// @brief Save an effect

View File

@@ -40,7 +40,7 @@ public:
///
/// @brief Destructor
///
~FlatBufferConnection();
~FlatBufferConnection() override;
/// @brief Do not read reply messages from Hyperion if set to true
void setSkipReply(bool skip);

View File

@@ -21,7 +21,7 @@ class FlatBufferServer : public QObject
Q_OBJECT
public:
FlatBufferServer(const QJsonDocument& config, QObject* parent = nullptr);
~FlatBufferServer();
~FlatBufferServer() override;
public slots:
///

View File

@@ -62,13 +62,13 @@ public:
);
~V4L2Grabber() override;
QRectF getSignalDetectionOffset()
QRectF getSignalDetectionOffset() const
{
return QRectF(_x_frac_min, _y_frac_min, _x_frac_max, _y_frac_max);
}
bool getSignalDetectionEnabled() { return _signalDetectionEnabled; }
bool getCecDetectionEnabled() { return _cecDetectionEnabled; }
bool getSignalDetectionEnabled() const { return _signalDetectionEnabled; }
bool getCecDetectionEnabled() const { return _cecDetectionEnabled; }
int grabFrame(Image<ColorRgb> &);
@@ -128,27 +128,27 @@ public:
///
/// @brief overwrite Grabber.h implementation
///
QStringList getV4L2devices() override;
QStringList getV4L2devices() const override;
///
/// @brief overwrite Grabber.h implementation
///
QString getV4L2deviceName(QString devicePath) override;
QString getV4L2deviceName(const QString& devicePath) const override;
///
/// @brief overwrite Grabber.h implementation
///
QMultiMap<QString, int> getV4L2deviceInputs(QString devicePath) override;
QMultiMap<QString, int> getV4L2deviceInputs(const QString& devicePath) const override;
///
/// @brief overwrite Grabber.h implementation
///
QStringList getResolutions(QString devicePath) override;
QStringList getResolutions(const QString& devicePath) const override;
///
/// @brief overwrite Grabber.h implementation
///
QStringList getFramerates(QString devicePath) override;
QStringList getFramerates(const QString& devicePath) const override;
public slots:
@@ -169,6 +169,7 @@ private:
void getV4Ldevices();
bool init();
void uninit();
bool open_device();
@@ -250,12 +251,13 @@ private:
private:
QString _deviceName;
std::map<QString, QString> _v4lDevices;
QMap<QString, V4L2Grabber::DeviceProperties> _deviceProperties;
VideoStandard _videoStandard;
io_method _ioMethod;
int _fileDescriptor;
std::vector<buffer> _buffers;
std::map<QString, QString> _v4lDevices;
QMap<QString, V4L2Grabber::DeviceProperties> _deviceProperties;
VideoStandard _videoStandard;
io_method _ioMethod;
int _fileDescriptor;
std::vector<buffer> _buffers;
PixelFormat _pixelFormat;
int _pixelDecimation;

View File

@@ -18,8 +18,8 @@ public:
int pixelDecimation );
~V4L2Wrapper() override;
bool getSignalDetectionEnable();
bool getCecDetectionEnable();
bool getSignalDetectionEnable() const;
bool getCecDetectionEnable() const;
public slots:
bool start() override;
@@ -30,7 +30,7 @@ public slots:
void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax);
void setSignalDetectionEnable(bool enable);
void setCecDetectionEnable(bool enable);
void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
void setDeviceVideoStandard(const QString& device, VideoStandard videoStandard);
void handleCecEvent(CECEvent event);
void handleSettingsUpdate(settings::type type, const QJsonDocument& config) override;

View File

@@ -10,20 +10,20 @@ enum class VideoStandard {
NO_CHANGE
};
inline VideoStandard parseVideoStandard(QString videoStandard)
inline VideoStandard parseVideoStandard(const QString& videoStandard)
{
// convert to lower case
videoStandard = videoStandard.toLower();
QString standard = videoStandard.toLower();
if (videoStandard == "pal")
if (standard == "pal")
{
return VideoStandard::PAL;
}
else if (videoStandard == "ntsc")
else if (standard == "ntsc")
{
return VideoStandard::NTSC;
}
else if (videoStandard == "secam")
else if (standard == "secam")
{
return VideoStandard::SECAM;
}

View File

@@ -38,25 +38,25 @@ public:
/// @brief Get the unique id (imported from removed class 'Stats')
/// @return The unique id
///
const QString &getID() const { return _uuid; };
QString getID() const { return _uuid; }
///
/// @brief Check authorization is required according to the user setting
/// @return True if authorization required else false
///
bool isAuthRequired() const { return _authRequired; };
bool isAuthRequired() const { return _authRequired; }
///
/// @brief Check if authorization is required for local network connections
/// @return True if authorization required else false
///
bool isLocalAuthRequired() const { return _localAuthRequired; };
bool isLocalAuthRequired() const { return _localAuthRequired; }
///
/// @brief Check if authorization is required for local network connections for admin access
/// @return True if authorization required else false
///
bool isLocalAdminAuthRequired() const { return _localAdminAuthRequired; };
bool isLocalAdminAuthRequired() const { return _localAdminAuthRequired; }
///
/// @brief Reset Hyperion user
@@ -68,18 +68,18 @@ public:
/// @brief Check if user auth is temporary blocked due to failed attempts
/// @return True on blocked and no further Auth requests will be accepted
///
bool isUserAuthBlocked() { return (_userAuthAttempts.length() >= 10); };
bool isUserAuthBlocked() const { return (_userAuthAttempts.length() >= 10); }
///
/// @brief Check if token auth is temporary blocked due to failed attempts
/// @return True on blocked and no further Auth requests will be accepted
///
bool isTokenAuthBlocked() { return (_tokenAuthAttempts.length() >= 25); };
bool isTokenAuthBlocked() const { return (_tokenAuthAttempts.length() >= 25); }
/// Pointer of this instance
static AuthManager *manager;
/// Get Pointer of this instance
static AuthManager *getInstance() { return manager; };
static AuthManager *getInstance() { return manager; }
public slots:
@@ -164,19 +164,19 @@ public slots:
/// @brief Get pending requests
/// @return All pending requests
///
QVector<AuthManager::AuthDefinition> getPendingRequests();
QVector<AuthManager::AuthDefinition> getPendingRequests() const;
///
/// @brief Get the current valid token for user. Make sure this call is allowed!
/// @param usr the defined user
/// @return The token
///
const QString getUserToken(const QString &usr = "Hyperion");
QString getUserToken(const QString &usr = "Hyperion") const;
///
/// @brief Get all available token entries
///
QVector<AuthManager::AuthDefinition> getTokenList();
QVector<AuthManager::AuthDefinition> getTokenList() const;
///
/// @brief Handle settings update from Hyperion Settingsmanager emit

View File

@@ -13,7 +13,7 @@ public:
/// Unique identifier for this color transform
QString _id;
/// The BLACK (RGB-Channel) adjustment
RgbChannelAdjustment _rgbBlackAdjustment;
/// The WHITE (RGB-Channel) adjustment

View File

@@ -20,7 +20,7 @@ class ComponentRegister : public QObject
public:
ComponentRegister(Hyperion* hyperion);
~ComponentRegister();
~ComponentRegister() override;
///
/// @brief Check if a component is currently enabled
@@ -30,7 +30,7 @@ public:
int isComponentEnabled(hyperion::Components comp) const;
/// contains all components and their state
std::map<hyperion::Components, bool> getRegister() const { return _componentStates; };
std::map<hyperion::Components, bool> getRegister() const { return _componentStates; }
signals:
///

View File

@@ -22,7 +22,7 @@ class Grabber : public QObject
Q_OBJECT
public:
Grabber(QString grabberName = "", int width=0, int height=0, int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0);
Grabber(const QString& grabberName = "", int width=0, int height=0, int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0);
///
/// Set the video mode (2D/3D)
@@ -119,35 +119,35 @@ public:
/// @brief Get a list of all available V4L devices
/// @return List of all available V4L devices on success else empty List
///
virtual QStringList getV4L2devices() { return QStringList(); }
virtual QStringList getV4L2devices() const { return QStringList(); }
///
/// @brief Get the V4L device name
/// @param devicePath The device path
/// @return The name of the V4L device on success else empty String
///
virtual QString getV4L2deviceName(QString devicePath) { return QString(); }
virtual QString getV4L2deviceName(const QString& /*devicePath*/) const { return QString(); }
///
/// @brief Get a name/index pair of supported device inputs
/// @param devicePath The device path
/// @return multi pair of name/index on success else empty pair
///
virtual QMultiMap<QString, int> getV4L2deviceInputs(QString devicePath) { return QMultiMap<QString, int>(); }
virtual QMultiMap<QString, int> getV4L2deviceInputs(const QString& /*devicePath*/) const { return QMultiMap<QString, int>(); }
///
/// @brief Get a list of supported device resolutions
/// @param devicePath The device path
/// @return List of resolutions on success else empty List
///
virtual QStringList getResolutions(QString devicePath) { return QStringList(); }
virtual QStringList getResolutions(const QString& /*devicePath*/) const { return QStringList(); }
///
/// @brief Get a list of supported device framerates
/// @param devicePath The device path
/// @return List of framerates on success else empty List
///
virtual QStringList getFramerates(QString devicePath) { return QStringList(); }
virtual QStringList getFramerates(const QString& devicePath) const { return QStringList(); }
protected:
ImageResampler _imageResampler;

View File

@@ -29,9 +29,9 @@ class GrabberWrapper : public QObject
{
Q_OBJECT
public:
GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned width, unsigned height, unsigned updateRate_Hz = 0);
GrabberWrapper(const QString& grabberName, Grabber * ggrabber, unsigned width, unsigned height, unsigned updateRate_Hz = 0);
virtual ~GrabberWrapper();
~GrabberWrapper() override;
static GrabberWrapper* instance;
static GrabberWrapper* getInstance(){ return instance; }
@@ -60,35 +60,35 @@ public:
/// @brief Get a list of all available V4L devices
/// @return List of all available V4L devices on success else empty List
///
virtual QStringList getV4L2devices();
virtual QStringList getV4L2devices() const;
///
/// @brief Get the V4L device name
/// @param devicePath The device path
/// @return The name of the V4L device on success else empty String
///
virtual QString getV4L2deviceName(QString devicePath);
virtual QString getV4L2deviceName(const QString& devicePath) const;
///
/// @brief Get a name/index pair of supported device inputs
/// @param devicePath The device path
/// @return multi pair of name/index on success else empty pair
///
virtual QMultiMap<QString, int> getV4L2deviceInputs(QString devicePath);
virtual QMultiMap<QString, int> getV4L2deviceInputs(const QString& devicePath) const;
///
/// @brief Get a list of supported device resolutions
/// @param devicePath The device path
/// @return List of resolutions on success else empty List
///
virtual QStringList getResolutions(QString devicePath);
virtual QStringList getResolutions(const QString& devicePath) const;
///
/// @brief Get a list of supported device framerates
/// @param devicePath The device path
/// @return List of framerates on success else empty List
///
virtual QStringList getFramerates(QString devicePath);
virtual QStringList getFramerates(const QString& devicePath) const;
static QStringList availableGrabbers();

View File

@@ -168,7 +168,7 @@ public slots:
/// Returns the list with unique adjustment identifiers
/// @return The list with adjustment identifiers
///
const QStringList & getAdjustmentIds() const;
QStringList getAdjustmentIds() const;
///
/// Returns the ColorAdjustment with the given identifier
@@ -233,15 +233,15 @@ public slots:
/// Get the list of available effects
/// @return The list of available effects
const std::list<EffectDefinition> &getEffects() const;
std::list<EffectDefinition> getEffects() const;
/// Get the list of active effects
/// @return The list of active effects
const std::list<ActiveEffectDefinition> &getActiveEffects() const;
std::list<ActiveEffectDefinition> getActiveEffects() const;
/// Get the list of available effect schema files
/// @return The list of available effect schema files
const std::list<EffectSchema> &getEffectSchemas() const;
std::list<EffectSchema> getEffectSchemas() const;
/// #############
/// PRIORITYMUXER
@@ -266,7 +266,7 @@ public slots:
/// gets current state of automatic/priorized source selection
/// @return the state
bool sourceAutoSelectEnabled();
bool sourceAutoSelectEnabled() const;
///
/// Returns the current priority
@@ -309,7 +309,7 @@ public slots:
/// gets the current json config object from SettingsManager
/// @return json config
const QJsonObject& getQJsonConfig() const;
QJsonObject getQJsonConfig() const;
///
/// @brief Save a complete json config
@@ -317,7 +317,7 @@ public slots:
/// @param correct If true will correct json against schema before save
/// @return True on success else false
///
bool saveSettings(QJsonObject config, bool correct = false);
bool saveSettings(const QJsonObject& config, bool correct = false);
/// ############
/// COMPONENTREGISTER
@@ -345,7 +345,7 @@ public slots:
/// @param The component to test
/// @return Component state
///
int isComponentEnabled(hyperion::Components comp);
int isComponentEnabled(hyperion::Components comp) const;
/// sets the methode how image is maped to leds at ImageProcessor
void setLedMappingType(int mappingType);
@@ -402,10 +402,10 @@ signals:
void forwardJsonMessage(QJsonObject);
/// Signal which is emitted, when a new system proto image should be forwarded
void forwardSystemProtoMessage(const QString, const Image<ColorRgb>);
void forwardSystemProtoMessage(const QString&, const Image<ColorRgb>&);
/// Signal which is emitted, when a new V4l proto image should be forwarded
void forwardV4lProtoMessage(const QString, const Image<ColorRgb>);
void forwardV4lProtoMessage(const QString&, const Image<ColorRgb>&);
///
/// @brief Is emitted from clients who request a videoMode change

View File

@@ -38,7 +38,7 @@ public slots:
/// @param inst The instance to check
/// @return True when running else false
///
bool IsInstanceRunning(quint8 inst) { return _runningInstances.contains(inst); }
bool IsInstanceRunning(quint8 inst) const { return _runningInstances.contains(inst); }
///
/// @brief Get a Hyperion instance by index
@@ -50,7 +50,7 @@ public slots:
///
/// @brief Get instance data of all instaces in db + running state
///
const QVector<QVariantMap> getInstanceData();
QVector<QVariantMap> getInstanceData() const;
///
/// @brief Start a Hyperion instance
@@ -172,7 +172,7 @@ private:
/// @brief check if a instance is allowed for management. Instance 0 represents the root instance
/// @apram inst The instance to check
///
bool isInstAllowed(quint8 inst) { return (inst > 0); }
bool isInstAllowed(quint8 inst) const { return (inst > 0); }
private:
Logger* _log;

View File

@@ -36,7 +36,7 @@ public:
///
ImageProcessor(const LedString& ledString, Hyperion* hyperion);
~ImageProcessor();
~ImageProcessor() override;
///
/// Specifies the width and height of 'incomming' images. This will resize the buffer-image to
@@ -54,15 +54,15 @@ public:
void setLedString(const LedString& ledString);
/// Returns starte of black border detector
bool blackBorderDetectorEnabled();
bool blackBorderDetectorEnabled() const;
/// Returns the current _userMappingType, this may not be the current applied type!
int getUserLedMappingType() { return _userMappingType; };
int getUserLedMappingType() const { return _userMappingType; }
/// Returns the current _mappingType
int ledMappingType() { return _mappingType; };
int ledMappingType() const { return _mappingType; }
static int mappingTypeToInt(QString mappingType);
static int mappingTypeToInt(const QString& mappingType);
static QString mappingTypeToStr(int mappingType);
///

View File

@@ -57,8 +57,8 @@ namespace hyperion
///
unsigned height() const;
unsigned horizontalBorder() { return _horizontalBorder; };
unsigned verticalBorder() { return _verticalBorder; };
unsigned horizontalBorder() const { return _horizontalBorder; }
unsigned verticalBorder() const { return _verticalBorder; }
///
/// Determines the mean color for each led using the mapping the image given

View File

@@ -20,7 +20,7 @@ enum class ColorOrder
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
};
inline QString colorOrderToString(const ColorOrder colorOrder)
inline QString colorOrderToString(ColorOrder colorOrder)
{
switch (colorOrder)
{

View File

@@ -34,10 +34,10 @@ class MessageForwarder : public QObject
Q_OBJECT
public:
MessageForwarder(Hyperion* hyperion);
~MessageForwarder();
~MessageForwarder() override;
void addJsonSlave(QString slave);
void addFlatbufferSlave(QString slave);
void addJsonSlave(const QString& slave);
void addFlatbufferSlave(const QString& slave);
private slots:
///

View File

@@ -26,7 +26,7 @@ public:
*/
void addAdjustment(ColorAdjustment * adjustment);
void setAdjustmentForLed(const QString& id, const unsigned startLed, unsigned endLed);
void setAdjustmentForLed(const QString& id, unsigned startLed, unsigned endLed);
bool verifyAdjustments() const;
@@ -36,7 +36,7 @@ public:
/// Returns the identifier of all the unique ColorAdjustment
///
/// @return The list with unique id's of the ColorAdjustment
const QStringList & getAdjustmentIds();
QStringList getAdjustmentIds() const;
///
/// Returns the pointer to the ColorAdjustment with the given id

View File

@@ -68,7 +68,7 @@ public:
///
/// Destructor
///
~PriorityMuxer();
~PriorityMuxer() override;
///
/// @brief Start/Stop the PriorityMuxer update timer; On disabled no priority and timeout updates will be performend
@@ -185,7 +185,7 @@ public:
///
/// @brief Queue a manual push where muxer doesn't recognize them (e.g. continous single color pushes)
///
void queuePush(){ emit timeRunner(); };
void queuePush() { emit timeRunner(); }
signals:
///
@@ -253,7 +253,7 @@ private:
/// @brief Get the component of the given priority
/// @return The component
///
hyperion::Components getComponentOfPriority(int priority);
hyperion::Components getComponentOfPriority(int priority) const;
/// Logger instance
Logger* _log;

View File

@@ -29,7 +29,7 @@ public:
/// @param The configuration
///
JsonServer(const QJsonDocument& config);
~JsonServer();
~JsonServer() override;
///
/// @return the port number on which this TCP listens for incoming connections

View File

@@ -1,8 +1,8 @@
#ifndef LEDEVICEFACTORY_H
#define LEDEVICEFACTORY_H
// LedDevice includes
#include <leddevice/LedDevice.h>
class LedDevice;
class QJsonObject;
///
/// The LedDeviceFactory is responsible for constructing 'LedDevices'
@@ -10,7 +10,6 @@
class LedDeviceFactory
{
public:
///
/// Constructs a LedDevice based on the given configuration
///

View File

@@ -33,7 +33,7 @@ public:
/// @brief Get all available device schemas
/// @return device schemas
///
static const QJsonObject getLedDeviceSchemas();
static QJsonObject getLedDeviceSchemas();
///
/// @brief add all device constructors to the map
@@ -50,22 +50,22 @@ public:
/// @brief Get the current latch time of the ledDevice
/// @ return latch time in ms
///
int getLatchTime();
int getLatchTime() const;
///
/// @brief Get the current active ledDevice type
///
QString getActiveDeviceType();
QString getActiveDeviceType() const;
///
/// @brief Return the last enable state
///
bool enabled();
bool enabled() const;
///
/// @brief Get the current colorOrder from device
///
QString getColorOrder();
QString getColorOrder() const;
///
/// @brief Get the number of LEDs from device

View File

@@ -7,7 +7,7 @@ class PythonInit
{
private:
friend class HyperionDaemon;
PythonInit();
~PythonInit();
};

View File

@@ -58,7 +58,7 @@ public:
/// @param timeout_ms The timeout in ms
/// @return The address+port of web-server or empty if timed out
///
const QString getFirstService(const searchType &type = searchType::STY_WEBSERVER,const QString &st = "urn:hyperion-project.org:device:basic:1", int timeout_ms = 3000);
QString getFirstService(const searchType &type = searchType::STY_WEBSERVER,const QString &st = "urn:hyperion-project.org:device:basic:1", int timeout_ms = 3000);
///
/// @brief Discover services via ssdp.
@@ -115,7 +115,7 @@ public:
///
/// @return Discovered services as JSON-document
///
QJsonArray getServicesDiscoveredJson();
QJsonArray getServicesDiscoveredJson() const;
///
/// @brief Set the ssdp discovery address (HOST)

View File

@@ -16,11 +16,12 @@ class QNetworkConfigurationManager;
/// UPnP 1.0: spec: http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0.pdf
///
class SSDPHandler : public SSDPServer{
class SSDPHandler : public SSDPServer
{
Q_OBJECT
public:
SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 jsonServerPort, const QString &name, QObject * parent = nullptr);
~SSDPHandler();
~SSDPHandler() override;
///
/// @brief Sends BYE BYE and stop server

View File

@@ -7,7 +7,8 @@ class QUdpSocket;
///
/// @brief The SSDP Server sends and receives (parses) SSDP requests
///
class SSDPServer : public QObject {
class SSDPServer : public QObject
{
Q_OBJECT
public:
@@ -17,7 +18,7 @@ public:
/// @param parent The parent object
///
SSDPServer(QObject* parent = nullptr);
virtual ~SSDPServer();
~SSDPServer() override;
///
/// @brief Prepare server after thread start
@@ -81,7 +82,7 @@ public:
///
/// @brief Get current flatbuffer server port
///
quint16 getFlatBufPort() { return _fbsPort.toInt(); };
quint16 getFlatBufPort() const { return _fbsPort.toInt(); };
///
/// @brief set new jsonserver server port
@@ -91,7 +92,7 @@ public:
///
/// @brief get new jsonserver server port
///
quint16 getJsonServerPort() { return _jssPort.toInt(); };
quint16 getJsonServerPort() const { return _jssPort.toInt(); };
///
/// @brief set new hyperion name
@@ -101,7 +102,7 @@ public:
///
/// @brief get hyperion name
///
QString getHyperionName() { return _name; };
QString getHyperionName() const { return _name; };
signals:

View File

@@ -67,22 +67,22 @@ inline const char* componentToIdString(Components c)
}
}
inline Components stringToComponent(QString component)
inline Components stringToComponent(const QString& component)
{
component = component.toUpper();
if (component == "ALL") return COMP_ALL;
if (component == "SMOOTHING") return COMP_SMOOTHING;
if (component == "BLACKBORDER") return COMP_BLACKBORDER;
if (component == "FORWARDER") return COMP_FORWARDER;
if (component == "BOBLIGHTSERVER")return COMP_BOBLIGHTSERVER;
if (component == "GRABBER") return COMP_GRABBER;
if (component == "V4L") return COMP_V4L;
if (component == "COLOR") return COMP_COLOR;
if (component == "EFFECT") return COMP_EFFECT;
if (component == "IMAGE") return COMP_IMAGE;
if (component == "LEDDEVICE") return COMP_LEDDEVICE;
if (component == "FLATBUFSERVER") return COMP_FLATBUFSERVER;
if (component == "PROTOSERVER") return COMP_PROTOSERVER;
const QString cmp = component.toUpper();
if (cmp == "ALL") return COMP_ALL;
if (cmp == "SMOOTHING") return COMP_SMOOTHING;
if (cmp == "BLACKBORDER") return COMP_BLACKBORDER;
if (cmp == "FORWARDER") return COMP_FORWARDER;
if (cmp == "BOBLIGHTSERVER")return COMP_BOBLIGHTSERVER;
if (cmp == "GRABBER") return COMP_GRABBER;
if (cmp == "V4L") return COMP_V4L;
if (cmp == "COLOR") return COMP_COLOR;
if (cmp == "EFFECT") return COMP_EFFECT;
if (cmp == "IMAGE") return COMP_IMAGE;
if (cmp == "LEDDEVICE") return COMP_LEDDEVICE;
if (cmp == "FLATBUFSERVER") return COMP_FLATBUFSERVER;
if (cmp == "PROTOSERVER") return COMP_PROTOSERVER;
return COMP_INVALID;
}

View File

@@ -10,8 +10,8 @@
namespace FileUtils {
QString getBaseName(QString sourceFile);
QString getDirName(QString sourceFile);
QString getBaseName(const QString& sourceFile);
QString getDirName(const QString& sourceFile);
///
/// @brief remove directory recursive given by path

View File

@@ -67,7 +67,7 @@ public:
void Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...);
void setMinLevel(LogLevel level) { _minLevel = static_cast<int>(level); }
LogLevel getMinLevel() { return static_cast<LogLevel>(int(_minLevel)); }
LogLevel getMinLevel() const { return static_cast<LogLevel>(int(_minLevel)); }
QString getName() const { return _name; }
QString getAppName() const { return _appname; }
@@ -76,7 +76,7 @@ signals:
protected:
Logger(const QString & name="", LogLevel minLevel = INFO);
~Logger();
~Logger() override;
private:
void write(const Logger::T_LOG_MESSAGE & message);

View File

@@ -25,13 +25,13 @@ public:
/// @param local The local address of the socket (Differs based on NetworkAdapter IP or localhost)
/// @return True when allowed, else false
///
bool accessAllowed(const QHostAddress& address, const QHostAddress& local);
bool accessAllowed(const QHostAddress& address, const QHostAddress& local) const;
///
/// @brief Check if address is in subnet of local
/// @return True or false
///
bool isLocalAddress(const QHostAddress& address, const QHostAddress& local);
bool isLocalAddress(const QHostAddress& address, const QHostAddress& local) const;
static NetOrigin* getInstance(){ return instance; };
static NetOrigin* instance;

View File

@@ -18,37 +18,37 @@ enum class PixelFormat {
NO_CHANGE
};
inline PixelFormat parsePixelFormat(QString pixelFormat)
inline PixelFormat parsePixelFormat(const QString& pixelFormat)
{
// convert to lower case
pixelFormat = pixelFormat.toLower();
QString format = pixelFormat.toLower();
if (pixelFormat.compare("yuyv") )
if (format.compare("yuyv") )
{
return PixelFormat::YUYV;
}
else if (pixelFormat.compare("uyvy") )
else if (format.compare("uyvy") )
{
return PixelFormat::UYVY;
}
else if (pixelFormat.compare("bgr16") )
else if (format.compare("bgr16") )
{
return PixelFormat::BGR16;
}
else if (pixelFormat.compare("bgr24") )
else if (format.compare("bgr24") )
{
return PixelFormat::BGR24;
}
else if (pixelFormat.compare("rgb32") )
else if (format.compare("rgb32") )
{
return PixelFormat::RGB32;
}
else if (pixelFormat.compare("bgr32") )
else if (format.compare("bgr32") )
{
return PixelFormat::BGR32;
}
#ifdef HAVE_JPEG_DECODER
else if (pixelFormat.compare("mjpeg") )
else if (format.compare("mjpeg") )
{
return PixelFormat::MJPEG;
}

View File

@@ -6,6 +6,6 @@
namespace Process {
void restartHyperion(bool asNewProcess=false);
QByteArray command_exec(QString cmd, QByteArray data="");
QByteArray command_exec(const QString& cmd, const QByteArray& data="");
}

View File

@@ -36,8 +36,8 @@ public:
Profiler(const char* sourceFile, const char* func, unsigned int line);
~Profiler();
static void TimerStart(const QString stopWatchName, const char* sourceFile, const char* func, unsigned int line);
static void TimerGetTime(const QString stopWatchName, const char* sourceFile, const char* func, unsigned int line);
static void TimerStart(const QString& stopWatchName, const char* sourceFile, const char* func, unsigned int line);
static void TimerGetTime(const QString& stopWatchName, const char* sourceFile, const char* func, unsigned int line);
private:
static void initLogger();

View File

@@ -14,7 +14,6 @@ namespace RGBW {
WHITE_OFF
};
WhiteAlgorithm stringToWhiteAlgorithm(QString str);
WhiteAlgorithm stringToWhiteAlgorithm(const QString& str);
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, WhiteAlgorithm algorithm);
}

View File

@@ -12,16 +12,16 @@ enum class VideoMode
VIDEO_3DTAB
};
inline VideoMode parse3DMode(QString videoMode)
inline VideoMode parse3DMode(const QString& videoMode)
{
// convert to upper case
videoMode = videoMode.toUpper();
const QString vm = videoMode.toUpper();
if (videoMode == "3DTAB")
if (vm == "3DTAB")
{
return VideoMode::VIDEO_3DTAB;
}
else if (videoMode == "3DSBS")
else if (vm == "3DSBS")
{
return VideoMode::VIDEO_3DSBS;
}

View File

@@ -57,7 +57,7 @@ public:
///
/// @return A list of error messages
///
const QStringList & getMessages() const;
QStringList getMessages() const;
private:
///

View File

@@ -19,14 +19,14 @@ public:
{
if (path.first() == "[root]")
path.removeFirst();
for (QStringList::iterator it = path.begin(); it != path.end(); ++it)
{
QString current = *it;
if (current.left(1) == ".")
*it = current.mid(1, current.size()-1);
}
if (!value.isEmpty())
modifyValue(value, result, path, newValue, propertyName);
else if (newValue != QJsonValue::Null && !propertyName.isEmpty())
@@ -78,17 +78,17 @@ private:
{
QJsonObject result;
QJsonObject obj = schema.toObject();
if (obj.find("type") != obj.end() && obj.find("type").value().isString())
{
QJsonValue ret = QJsonValue::Null;
if (obj.find("type").value().toString() == "object" && ( obj.find("required").value().toBool() || ignoreRequired ) )
ret = createValue(obj["properties"], ignoreRequired);
else if (obj.find("type").value().toString() == "array" && ( obj.find("required").value().toBool() || ignoreRequired ) )
{
QJsonArray array;
if (obj.find("default") != obj.end())
ret = obj.find("default").value();
else
@@ -103,7 +103,7 @@ private:
else if ( obj.find("required").value().toBool() || ignoreRequired )
if (obj.find("default") != obj.end())
ret = obj.find("default").value();
return ret;
}
else
@@ -133,7 +133,7 @@ private:
{
QJsonValue retEmpty;
retEmpty = createValue(attributeValue.toObject()["items"], ignoreRequired);
if (!retEmpty.toObject().isEmpty())
array.append(retEmpty);
result[attribute] = array;
@@ -234,7 +234,7 @@ private:
subValue = newValue;
else
continue;
if (!subValue.toObject().isEmpty())
json_array.append(subValue);
else if (newValue != QJsonValue::Null && arrayLevel != -1)

View File

@@ -37,7 +37,7 @@ namespace settings {
/// @param type The settings::type from enum
/// @return The settings type as string
///
inline QString typeToString(const type& type)
inline QString typeToString(type type)
{
switch (type)
{

View File

@@ -28,7 +28,8 @@ openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-subj /CN=hyperion-project.org
*/
class WebServer : public QObject {
class WebServer : public QObject
{
Q_OBJECT
public: