29 #ifndef RADIOLIMITS_HH
30 #define RADIOLIMITS_HH
33 #include <QTextStream>
106 void push(
const QString &element);
139 typedef std::initializer_list< std::pair<QString, RadioLimitElement *> >
PropList;
271 QObject *parent=
nullptr);
293 RadioLimitUInt(qint64 minValue=-1, qint64 maxValue=-1, qint64 defValue=-1, QObject *parent=
nullptr);
329 RadioLimitEnum(
const std::initializer_list<unsigned> &values, QObject *parent=
nullptr);
347 typedef std::initializer_list<std::pair<double, double>>
RangeList;
485 typedef std::initializer_list<std::pair<const QMetaObject&, RadioLimitObject *> >
TypeList;
512 QHash<QString, RadioLimitObject *>
_types;
527 RadioLimitObjRef(
const QMetaObject &type,
bool allowNull=
true, QObject *parent=
nullptr);
533 bool validType(
const QMetaObject *type)
const;
556 QObject *parent=
nullptr);
593 RadioLimitList(
const std::initializer_list<ElementLimits> &elements, QObject *parent=
nullptr);
623 RadioLimitRefList(
int minSize,
int maxSize,
const QMetaObject &type, QObject *parent=
nullptr);
629 bool validType(
const QMetaObject *type)
const;
697 explicit RadioLimits(
bool betaWarning, QObject *parent =
nullptr);
699 RadioLimits(
const std::initializer_list<std::pair<QString,RadioLimitElement *> > &list, QObject *parent=
nullptr);
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
Base class of all labeled and named objects.
Definition: configobject.hh:199
The config class, representing the codeplug configuration.
Definition: config.hh:68
Checks if a property is a boolean value.
Definition: radiolimits.hh:248
RadioLimitBool(QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:276
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:283
Collects the issues found during verification.
Definition: radiolimits.hh:91
RadioLimitIssue::Severity _maxSeverity
Holds the highest severity of all messages.
Definition: radiolimits.hh:126
bool ignoreFrequencyLimits() const
If true, frequency limit voilations are warnings.
Definition: radiolimits.cc:111
void pop()
Pops the top-most property name/element index from the stack.
Definition: radiolimits.cc:106
const RadioLimitIssue & message(int n) const
Returns the n-th issue.
Definition: radiolimits.cc:96
RadioLimitContext(bool ignoreFrequencyLimits=false)
Empty constructor.
Definition: radiolimits.cc:76
bool _ignoreFrequencyLimits
If true, any frequency range voilation is a warning.
Definition: radiolimits.hh:124
void push(const QString &element)
Push a property name/element index onto the stack.
Definition: radiolimits.cc:101
QStringList _stack
The current item stack.
Definition: radiolimits.hh:120
QList< RadioLimitIssue > _messages
The list of issues found.
Definition: radiolimits.hh:122
RadioLimitIssue::Severity maxSeverity() const
Returns the highest severity of the messages.
Definition: radiolimits.cc:120
RadioLimitIssue & newMessage(RadioLimitIssue::Severity severity=RadioLimitIssue::Hint)
Constructs a new message and puts it into the list of issues.
Definition: radiolimits.cc:83
int count() const
Returns the number of issues.
Definition: radiolimits.cc:91
void enableIgnoreFrequencyLimits(bool enable=true)
Enables/disables that frequency range voilations are handled as warnings.
Definition: radiolimits.cc:115
Represents a DMR ID.
Definition: radiolimits.hh:311
RadioLimitDMRId(QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:359
Abstract base class for all radio limits.
Definition: radiolimits.hh:134
virtual ~RadioLimitElement()
Destructor.
Definition: radiolimits.cc:134
std::initializer_list< std::pair< QString, RadioLimitElement * > > PropList
Initializer lists of ConfigItem properties.
Definition: radiolimits.hh:139
RadioLimitElement(QObject *parent=nullptr)
Hidden constructor.
Definition: radiolimits.cc:128
virtual bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const =0
Verifies the given property of the specified item.
Represents a limit for a set of enum values.
Definition: radiolimits.hh:324
QSet< unsigned > _values
Holds the set of valid values.
Definition: radiolimits.hh:335
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:376
RadioLimitEnum(const std::initializer_list< unsigned > &values, QObject *parent=nullptr)
Constructor from initializer list of possible enum values.
Definition: radiolimits.cc:369
Represents a limit on frequencies in MHz.
Definition: radiolimits.hh:342
std::initializer_list< std::pair< double, double > > RangeList
Typedef for the initializer list.
Definition: radiolimits.hh:347
RadioLimitFrequencies(QObject *parent=nullptr)
Empty constructor.
Definition: radiolimits.cc:424
QList< FrequencyRange > _frequencyRanges
Holds the frequency ranges for the device.
Definition: radiolimits.hh:371
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:439
bool _warnOnly
If true, throw only a warning.
Definition: radiolimits.hh:373
Implements the limits for a list of references to group call contacts.
Definition: radiolimits.hh:645
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:857
qint64 _minSize
Holds the minimum size of the list.
Definition: radiolimits.hh:659
RadioLimitGroupCallRefList(int minSize, int maxSize, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:850
qint64 _maxSize
Holds the maximum size of the list.
Definition: radiolimits.hh:661
Specifies an boolean value as ignored.
Definition: radiolimits.hh:263
RadioLimitIssue::Severity _severity
The severity of the issue generated.
Definition: radiolimits.hh:277
RadioLimitIgnoredBool(RadioLimitIssue::Severity notify=RadioLimitIssue::Hint, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:299
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:306
Represents an ignored element in the codeplug.
Definition: radiolimits.hh:456
RadioLimitIssue::Severity _notification
Holds the level of the notification.
Definition: radiolimits.hh:468
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:149
RadioLimitIgnored(RadioLimitIssue::Severity notify=RadioLimitIssue::Hint, QObject *parent=nullptr)
Constructor for a ignored setting verification element.
Definition: radiolimits.cc:142
bool verifyObject(const ConfigObject *item, RadioLimitContext &context) const
Verifies the properties of the given object.
Definition: radiolimits.cc:158
Represents a single issue found during verification.
Definition: radiolimits.hh:47
Severity
Defines the possible severity levels.
Definition: radiolimits.hh:50
@ Critical
Assembly of the codeplug will fail or a non-functional codeplug might be created.
Definition: radiolimits.hh:54
@ Hint
Just a hint, a working codplug will be assembled.
Definition: radiolimits.hh:52
@ Silent
The user will not be notified.
Definition: radiolimits.hh:51
@ Warning
The codeplug gets changed but a working codeplug might be assembled.
Definition: radiolimits.hh:53
Severity severity() const
Returns the severity of the issue.
Definition: radiolimits.cc:49
QStringList _stack
Holds the item-stack (where the issue occurred).
Definition: radiolimits.hh:80
RadioLimitIssue(Severity severity, const QStringList &stack)
Constructs an empty message for the specified severity at the specified point of the verification.
Definition: radiolimits.cc:21
QString format() const
Formats the message.
Definition: radiolimits.cc:59
const QString & message() const
Returns the text message.
Definition: radiolimits.cc:54
RadioLimitIssue & operator=(const RadioLimitIssue &other)
Copy assignment.
Definition: radiolimits.cc:34
QString _message
Holds the text message.
Definition: radiolimits.hh:82
Severity _severity
Holds the severity of the issue.
Definition: radiolimits.hh:78
Represents the limits for a ConfigItem instance.
Definition: radiolimits.hh:401
virtual bool verifyItem(const ConfigItem *item, RadioLimitContext &context) const
Verifies the properties of the given item.
Definition: radiolimits.cc:547
bool add(const QString &prop, RadioLimitElement *structure)
Adds a property declaration.
Definition: radiolimits.cc:515
QHash< QString, RadioLimitElement * > _elements
Holds the property <-> limits map.
Definition: radiolimits.hh:427
RadioLimitItem(QObject *parent=nullptr)
Empty constructor.
Definition: radiolimits.cc:500
virtual bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:524
Specifies the limits for a list of ConfigObject instances.
Definition: radiolimits.hh:571
QString findClassName(const QMetaObject &type) const
Searches for the specified type or one of its super-clsases in the set of allowed types.
Definition: radiolimits.cc:778
RadioLimitList(const QMetaObject &type, int minSize, int maxSize, RadioLimitObject *element, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:692
QHash< QString, qint64 > _minCount
Maps typename to minimum count.
Definition: radiolimits.hh:605
QHash< QString, RadioLimitObject * > _elements
Maps typename to element definition.
Definition: radiolimits.hh:603
QHash< QString, qint64 > _maxCount
Maps typename to maximum count.
Definition: radiolimits.hh:607
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:713
Issues a notification if a reference is set.
Definition: radiolimits.hh:546
RadioLimitObjRefIgnored(ConfigObject *defObj=nullptr, RadioLimitIssue::Severity notify=RadioLimitIssue::Hint, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:667
ConfigObject * _default
A weak reference to a default value, that gets silently ignored.
Definition: radiolimits.hh:564
RadioLimitIssue::Severity _severity
The severity of the issue.
Definition: radiolimits.hh:562
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:676
Limits the possible classes a ConfigObjectReference may refer to.
Definition: radiolimits.hh:519
RadioLimitObjRef(const QMetaObject &type, bool allowNull=true, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:617
bool _allowNull
If true, a null reference is allowed.
Definition: radiolimits.hh:537
bool validType(const QMetaObject *type) const
Checks if the given type is one of the valid ones in _types.
Definition: radiolimits.cc:655
QSet< QString > _types
Possible classes of instances, the reference may point to.
Definition: radiolimits.hh:539
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:624
Represents the limits for all properties of a ConfigObject instance.
Definition: radiolimits.hh:434
virtual bool verifyObject(const ConfigObject *item, RadioLimitContext &context) const
Verifies the properties of the given object.
Definition: radiolimits.cc:582
RadioLimitObject(QObject *parent=nullptr)
Empty constructor.
Definition: radiolimits.cc:569
Dispatch by class.
Definition: radiolimits.hh:480
RadioLimitObjects(const TypeList &list, QObject *parent=nullptr)
Constructor from initializer list.
Definition: radiolimits.cc:593
bool verifyItem(const ConfigItem *item, RadioLimitContext &context) const
Verifies the properties of the given item.
Definition: radiolimits.cc:603
std::initializer_list< std::pair< const QMetaObject &, RadioLimitObject * > > TypeList
Initializer lists of type properties.
Definition: radiolimits.hh:485
QHash< QString, RadioLimitObject * > _types
Maps class-names to object limits.
Definition: radiolimits.hh:512
Implements the limits for reference lists.
Definition: radiolimits.hh:614
qint64 _maxSize
Holds the maximum size of the list.
Definition: radiolimits.hh:635
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:797
QSet< QString > _types
Possible classes of instances, the references may point to.
Definition: radiolimits.hh:637
RadioLimitRefList(int minSize, int maxSize, const QMetaObject &type, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:790
qint64 _minSize
Holds the minimum size of the list.
Definition: radiolimits.hh:633
bool validType(const QMetaObject *type) const
Checks if the given type is one of the valid ones in _types.
Definition: radiolimits.cc:838
Specialized RadioLimitObject handling a zone for radio supporting only a single channel list per zone...
Definition: radiolimits.hh:673
RadioLimitSingleZone(qint64 maxSize, const PropList &list, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:906
bool verifyItem(const ConfigItem *item, RadioLimitContext &context) const
Verifies the properties of the given item.
Definition: radiolimits.cc:915
Notifies the user that a string gets ignored.
Definition: radiolimits.hh:230
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:256
RadioLimitIssue::Severity _severity
Holds the severity of the message.
Definition: radiolimits.hh:241
RadioLimitStringIgnored(RadioLimitIssue::Severity severity=RadioLimitIssue::Hint, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:249
Verifies that a string matches a regular expression.
Definition: radiolimits.hh:210
RadioLimitStringRegEx(const QString &pattern, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:221
QRegExp _pattern
Holds the regular expression pattern.
Definition: radiolimits.hh:223
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:228
Checks a string valued property.
Definition: radiolimits.hh:177
RadioLimitString(int minLen, int maxLen, Encoding enc, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:181
int _minLen
Holds the minimum length of the string.
Definition: radiolimits.hh:199
int _maxLen
Holds the maximum length of the string.
Definition: radiolimits.hh:201
Encoding
Possible encoding of strings.
Definition: radiolimits.hh:182
@ ASCII
Just ASCII is allowed.
Definition: radiolimits.hh:183
@ Unicode
Any Unicode character is allowed.
Definition: radiolimits.hh:184
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:188
Encoding _encoding
Holds the allowed character encoding.
Definition: radiolimits.hh:203
Specialization for transmit frequency limits.
Definition: radiolimits.hh:381
RadioLimitTransmitFrequencies(QObject *parent=nullptr)
Empty constructor.
Definition: radiolimits.cc:469
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:482
Represents a limit for an unsigned integer value.
Definition: radiolimits.hh:284
qint64 _maxValue
Holds the maximum value.
Definition: radiolimits.hh:301
qint64 _defValue
Holds the default value.
Definition: radiolimits.hh:303
bool verify(const ConfigItem *item, const QMetaProperty &prop, RadioLimitContext &context) const
Verifies the given property of the specified item.
Definition: radiolimits.cc:333
qint64 _minValue
Holds the minimum value.
Definition: radiolimits.hh:299
RadioLimitUInt(qint64 minValue=-1, qint64 maxValue=-1, qint64 defValue=-1, QObject *parent=nullptr)
Constructor.
Definition: radiolimits.cc:326
Base class to verify values.
Definition: radiolimits.hh:161
RadioLimitValue(QObject *parent=nullptr)
Hidden constructor.
Definition: radiolimits.cc:171
Represents the limits or the entire codeplug.
Definition: radiolimits.hh:692
unsigned numCallSignDBEntries() const
Returns the maximum number of entries in the call-sign DB.
Definition: radiolimits.cc:956
virtual bool verifyConfig(const Config *config, RadioLimitContext &context) const
Verifies the given configuration.
Definition: radiolimits.cc:961
bool _callSignDBImplemented
If true, the call-sign is implemented.
Definition: radiolimits.hh:718
bool _hasCallSignDB
If true, the radio supports a call-sign DB.
Definition: radiolimits.hh:716
bool hasCallSignDB() const
Returns true if the radio supports a call-sign DB.
Definition: radiolimits.cc:946
unsigned _numCallSignDBEntries
Holds the number of possible call-sign DB entries.
Definition: radiolimits.hh:720
RadioLimits(bool betaWarning, QObject *parent=nullptr)
Empty constructor.
Definition: radiolimits.cc:933
bool callSignDBImplemented() const
Returns true if the call-sign DB is implemented.
Definition: radiolimits.cc:951
bool _betaWarning
If true, a warning is issued that the radio is still under development and not well tested yet.
Definition: radiolimits.hh:714
Represents a single frequency range.
Definition: radiolimits.hh:350
bool contains(double f) const
Returns true if f is inside this limit.
Definition: radiolimits.cc:416
FrequencyRange(double lower, double upper)
Constructs a frequency range from limits.
Definition: radiolimits.cc:403
double min
Lower frequency limit.
Definition: radiolimits.hh:351
double max
Upper frequency limit.
Definition: radiolimits.hh:352
Helper struct to pass list entry definitions.
Definition: radiolimits.hh:576
int minCount
Minimum count of elements.
Definition: radiolimits.hh:578
const QMetaObject & type
The type of the object.
Definition: radiolimits.hh:577
int maxCount
Maximum count of elements.
Definition: radiolimits.hh:579
RadioLimitObject * structure
The structure of the elements.
Definition: radiolimits.hh:580