1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
#ifndef CONFIGREFERENCE_HH
#define CONFIGREFERENCE_HH
#include "configobject.hh"
#include <QSet>
class Channel;
class DMRChannel;
class FMChannel;
class ScanList;
class EncryptionKey;
/** Implements a reference to a config object.
* This class is only used to implement the automatic generation/parsing of the YAML codeplug files.
* @ingroup conf */
class ConfigObjectReference: public QObject
{
Q_OBJECT
protected:
/** Hidden constructor. */
ConfigObjectReference(const QMetaObject &elementType=ConfigObject::staticMetaObject, QObject *parent = nullptr);
public:
/** Returns @c true if the reference is null.
* That is, if there is no object referenced. */
bool isNull() const;
/** Resets the reference.
* Same as @c set(nullptr). */
virtual void clear();
/** Sets the reference.
* If set to @c nullptr, the reference gets cleared. */
virtual bool set(ConfigObject *object);
/** Copies the reference from another reference. */
virtual bool copy(const ConfigObjectReference *ref);
/** Adds a possible type to this reference. */
virtual bool allow(const QMetaObject *elementType);
/** Returns the type names of allowed objects. */
const QStringList &elementTypeNames() const;
/** Returns the reference as the specified type. */
template <class Type>
Type *as() const {
if (nullptr == _object)
return nullptr;
return _object->as<Type>();
}
/** Returns @c true if the reference is of the specified type. */
template <class Type>
bool is() const {
if (nullptr == _object)
return false;
return _object->is<Type>();
}
/** Compares the references. */
int compare(const ConfigObjectReference &other) const;
signals:
/** Gets emitted if the reference is changed.
* This signal is not emitted if the referenced object is modified. */
void modified();
protected slots:
/** Internal call back whenever the referenced object gets deleted. */
void onReferenceDeleted(QObject *obj);
protected:
/** Holds the static QMetaObject of the possible element types. */
QStringList _elementTypes;
/** The reference to the object. */
ConfigObject *_object;
};
/** Represents a reference to a contact.
* This class is only used to automate the parsing and generation of the YAML codeplug file.
* @ingroup config */
class ContactReference: public ConfigObjectReference
{
Q_OBJECT
protected:
/** Constructor. */
ContactReference(const QMetaObject &elementType, QObject *parent = nullptr);
public:
/** Constructor. */
explicit ContactReference(QObject *parent=nullptr);
};
/** Represents a reference to a DMR contact.
* @ingroup conf*/
class DMRContactReference: public ContactReference
{
Q_OBJECT
public:
/** Constructor. */
explicit DMRContactReference(QObject *parent=nullptr);
};
/** List of references to DMR contacts. */
class DMRContactRefList: public ConfigObjectRefList
{
Q_OBJECT
public:
/** Constructor. */
explicit DMRContactRefList(QObject *parent=nullptr);
};
/** Represents a reference to a channel.
* This class is only used to automate the parsing and generation of the YAML codeplug file.
* @ingroup config */
class ChannelReference: public ConfigObjectReference
{
Q_OBJECT
protected:
/** Hidden constructor. */
ChannelReference(const QMetaObject &elementType, QObject *parent = nullptr);
public:
/** Constructor. */
explicit ChannelReference(QObject *parent=nullptr);
};
/** Implements a reference to a DMR channel.
* @ingroup conf */
class DMRChannelReference: public ChannelReference
{
Q_OBJECT
public:
/** Constructor. */
explicit DMRChannelReference(QObject *parent=nullptr);
};
/** Implements a reference to a FM channel.
* @ingroup conf */
class FMChannelReference: public ChannelReference
{
Q_OBJECT
public:
/** Constructor. */
explicit FMChannelReference(QObject *parent=nullptr);
};
/** Represents a list of weak references to channels (analog and digital).
* @ingroup config */
class ChannelRefList: public ConfigObjectRefList
{
Q_OBJECT
protected:
/** Hidden constructor. */
explicit ChannelRefList(const QMetaObject &elementTypes, QObject *parent = nullptr);
public:
/** Empty constructor. */
explicit ChannelRefList(QObject *parent=nullptr);
};
/** Represents a list of references to some DMR channels.
* @ingroup config */
class DMRChannelRefList: public ChannelRefList
{
Q_OBJECT
public:
/** Empty constructor. */
explicit DMRChannelRefList(QObject *parent=nullptr);
};
/** Represents a list of references to some roaming channels.
* @ingroup config */
class RoamingChannelRefList: public ConfigObjectRefList
{
Q_OBJECT
public:
/** Empty constructor. */
explicit RoamingChannelRefList(QObject *parent=nullptr);
};
/** Implements a reference to a scan list.
* @ingroup conf */
class ScanListReference: public ConfigObjectReference
{
Q_OBJECT
public:
/** Constructor. */
explicit ScanListReference(QObject *parent=nullptr);
};
/** Implements a reference to a positioning system.
* @ingroup conf */
class PositioningSystemReference: public ConfigObjectReference {
Q_OBJECT
protected:
/** Hidden constructor. */
PositioningSystemReference(const QMetaObject &elementType, QObject *parent = nullptr);
public:
/** Constructor. */
explicit PositioningSystemReference(QObject *parent=nullptr);
};
/** Implements a reference to an APRS system.
* @ingroup conf */
class APRSSystemReference: public PositioningSystemReference {
Q_OBJECT
public:
/** Constructor. */
explicit APRSSystemReference(QObject *parent=nullptr);
};
/** Implements a reference to a GPS system.
* @ingroup conf */
class GPSSystemReference: public PositioningSystemReference {
Q_OBJECT
public:
/** Constructor. */
explicit GPSSystemReference(QObject *parent=nullptr);
};
/** Implements a reference to a radio ID.
* @ingroup conf */
class DMRRadioIDReference: public ConfigObjectReference {
Q_OBJECT
public:
/** Constructor. */
explicit DMRRadioIDReference(QObject *parent=nullptr);
};
/** Implements a reference to a group list.
* @ingroup conf */
class GroupListReference: public ConfigObjectReference {
Q_OBJECT
public:
/** Constructor. */
explicit GroupListReference(QObject *parent=nullptr);
};
/** Implements a reference to a roaming zone.
* @ingroup conf */
class RoamingZoneReference: public ConfigObjectReference {
Q_OBJECT
public:
/** Constructor. */
explicit RoamingZoneReference(QObject *parent=nullptr);
};
/** Implements a reference to an encryption key.
* @ingroup conf */
class EncryptionKeyReference: public ConfigObjectReference {
Q_OBJECT
public:
/** Constructor. */
explicit EncryptionKeyReference(QObject *parent=nullptr);
};
/** Implements a reference to a zone.
* @ingroup conf */
class ZoneReference: public ConfigObjectReference {
Q_OBJECT
public:
/** Constructor. */
explicit ZoneReference(QObject *parent=nullptr);
};
#endif // CONFIGREFERENCE_HH
|