libdrmconf 0.15.0
A library to program DMR radios.
Loading...
Searching...
No Matches
radioid.hh
1#ifndef RADIOID_HH
2#define RADIOID_HH
3
4#include "configobject.hh"
5
7
8
14class RadioID: public ConfigObject
15{
16 Q_OBJECT
17
18protected:
21 explicit RadioID(QObject *parent=nullptr);
23 RadioID(const QString &name, QObject *parent=nullptr);
24};
25
26
32class DMRRadioID : public RadioID
33{
34 Q_OBJECT
35 Q_CLASSINFO("IdPrefix", "id")
36
37
38 Q_PROPERTY(unsigned number READ number WRITE setNumber)
39
40public:
42 Q_INVOKABLE explicit DMRRadioID(QObject *parent=nullptr);
43
48 DMRRadioID(const QString &name, uint32_t number, QObject *parent = nullptr);
49
50 ConfigItem *clone() const;
51
53 uint32_t number() const;
55 void setNumber(uint32_t number);
56
57 YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
58 bool parse(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
59 bool link(const YAML::Node &node, const ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
60
61protected:
63 uint32_t _number;
64};
65
66
70{
71 Q_OBJECT
72
73protected:
75 explicit DefaultRadioID(QObject *parent=nullptr);
76
77public:
79 static DefaultRadioID *get();
80
81private:
83 static DefaultRadioID *_instance;
84};
85
86
89class M17RadioID: public RadioID
90{
91 Q_OBJECT
92 Q_CLASSINFO("IdPrefix", "id")
93
94
95 Q_PROPERTY(QString call READ call WRITE setCall)
96
97public:
99 explicit M17RadioID(QObject *parent=nullptr);
100
105 M17RadioID(const QString &name, const QString &call, QObject *parent = nullptr);
106
107 ConfigItem *clone() const;
108
110 const QString &call() const;
112 void setCall(const QString &call);
113
114 YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
115 bool parse(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
116 bool link(const YAML::Node &node, const ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
117
118protected:
120 QString _call;
121};
122
123
128class DTMFRadioID: public RadioID
129{
130 Q_OBJECT
131 Q_CLASSINFO("IdPrefix", "dtmf")
132
133
134 Q_PROPERTY(QString number READ number WRITE setNumber)
135
136public:
138 Q_INVOKABLE explicit DTMFRadioID(QObject *parent=nullptr);
139
144 explicit DTMFRadioID(const QString &name, const QString &number, QObject *parent=nullptr);
145
146 ConfigItem *clone() const;
147
149 const QString &number() const;
151 void setNumber(const QString &number);
152
153protected:
155 QString _number;
156};
157
158
162{
163 Q_OBJECT
164
165
166public:
168 explicit RadioIDList(QObject *parent=nullptr);
169
170 void clear();
171
173 [[deprecated("Use indexing instead.")]] DMRRadioID *getId(int idx) const;
175 DMRRadioID *find(uint32_t id) const;
176
177 int add(ConfigObject *obj, int row=-1, bool unique=true);
178
180 virtual int addId(const QString &name, uint32_t id);
182 virtual bool delId(uint32_t id);
183
184public:
185 ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
186};
187
188
189#endif // RADIOID_HH
Parse context for config objects.
Definition configobject.hh:43
Base class for all configuration objects (channels, zones, contacts, etc).
Definition configobject.hh:35
ConfigItem(QObject *parent=nullptr)
Hidden constructor.
Definition configobject.cc:158
ConfigObjectList(const QMetaObject &elementTypes=ConfigItem::staticMetaObject, QObject *parent=nullptr)
Hidden constructor.
Definition configobject.cc:1511
Base class of all labeled and named objects.
Definition configobject.hh:192
ConfigObject(QObject *parent=nullptr)
Specifies the prefix for every ID assigned to every object during serialization.
Definition configobject.cc:1141
QString name
The name of the object.
Definition configobject.hh:196
Implements a reference to a radio ID.
Definition configreference.hh:263
Represents a DMR radio ID within the abstract config.
Definition radioid.hh:33
unsigned number
The number of the radio ID.
Definition radioid.hh:38
bool link(const YAML::Node &node, const ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Links the given object to the rest of the codeplug using the given context.
Definition radioid.cc:90
ConfigItem * clone() const
Clones this item.
Definition radioid.cc:40
void setNumber(uint32_t number)
Sets the DMR ID.
Definition radioid.cc:55
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition radioid.cc:63
Q_INVOKABLE DMRRadioID(QObject *parent=nullptr)
Default constructor.
Definition radioid.cc:27
bool parse(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition radioid.cc:76
uint32_t _number
Holds the DMR ID.
Definition radioid.hh:63
ConfigItem * clone() const
Clones this item.
Definition radioid.cc:219
QString _number
Holds the DTMF number of the radio ID.
Definition radioid.hh:155
Q_INVOKABLE DTMFRadioID(QObject *parent=nullptr)
Default constructor.
Definition radioid.cc:206
QString number
The DTMF number of the radio ID.
Definition radioid.hh:134
void setNumber(const QString &number)
Sets the DTMF number of the radio ID.
Definition radioid.cc:233
DefaultRadioID(QObject *parent=nullptr)
Constructor.
Definition radioid.cc:109
static DefaultRadioID * get()
Factory method returning the singleton instance.
Definition radioid.cc:116
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
QString call
The callsign of the radio ID.
Definition radioid.hh:95
ConfigItem * clone() const
Clones this item.
Definition radioid.cc:139
bool link(const YAML::Node &node, const ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Links the given object to the rest of the codeplug using the given context.
Definition radioid.cc:189
QString _call
Holds the M17 call/ID.
Definition radioid.hh:120
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition radioid.cc:162
bool parse(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition radioid.cc:175
M17RadioID(QObject *parent=nullptr)
Default constructor.
Definition radioid.cc:126
void setCall(const QString &call)
Sets the M17 call/ID.
Definition radioid.cc:154
void clear()
Clears the list.
Definition radioid.cc:252
virtual int addId(const QString &name, uint32_t id)
Adds the given DMR ID.
Definition radioid.cc:285
RadioIDList(QObject *parent=nullptr)
Constructor.
Definition radioid.cc:245
int add(ConfigObject *obj, int row=-1, bool unique=true)
Adds an element to the list.
Definition radioid.cc:273
ConfigItem * allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Allocates a member objects for the given YAML node.
Definition radioid.cc:296
virtual bool delId(uint32_t id)
Deletes and removes the given DMR ID.
Definition radioid.cc:290
DMRRadioID * find(uint32_t id) const
Searches the DMR ID object associated with the given DMR ID.
Definition radioid.cc:264
DMRRadioID * getId(int idx) const
Returns the radio ID at the given index.
Definition radioid.cc:257
RadioID(QObject *parent=nullptr)
Hidden default constructor.
Definition radioid.cc:11