libdrmconf  0.11.3
A library to program DMR radios.
radioid.hh
1 #ifndef RADIOID_HH
2 #define RADIOID_HH
3 
4 #include "configobject.hh"
5 
6 
12 class RadioID: public ConfigObject
13 {
14  Q_OBJECT
15 
16 protected:
19  explicit RadioID(QObject *parent=nullptr);
21  RadioID(const QString &name, QObject *parent=nullptr);
22 };
23 
24 
30 class DMRRadioID : public RadioID
31 {
32  Q_OBJECT
33  Q_CLASSINFO("IdPrefix", "id")
34 
35 
36  Q_PROPERTY(unsigned number READ number WRITE setNumber)
37 
38 public:
40  explicit DMRRadioID(QObject *parent=nullptr);
41 
46  DMRRadioID(const QString &name, uint32_t number, QObject *parent = nullptr);
47 
48  ConfigItem *clone() const;
49 
51  uint32_t number() const;
53  void setNumber(uint32_t number);
54 
55  YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
56  bool parse(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
57  bool link(const YAML::Node &node, const ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
58 
59 protected:
61  uint32_t _number;
62 };
63 
64 
68 {
69  Q_OBJECT
70 
71 protected:
73  explicit DefaultRadioID(QObject *parent=nullptr);
74 
75 public:
77  static DefaultRadioID *get();
78 
79 private:
81  static DefaultRadioID *_instance;
82 };
83 
84 
89 class DTMFRadioID: public RadioID
90 {
91  Q_OBJECT
92  Q_CLASSINFO("IdPrefix", "dtmf")
93 
94 
95  Q_PROPERTY(QString number READ number WRITE setNumber)
96 
97 public:
99  explicit DTMFRadioID(QObject *parent=nullptr);
100 
105  explicit DTMFRadioID(const QString &name, const QString &number, QObject *parent=nullptr);
106 
107  ConfigItem *clone() const;
108 
110  const QString &number() const;
112  void setNumber(const QString &number);
113 
114 protected:
116  QString _number;
117 };
118 
119 
126 {
127  Q_OBJECT
128 
129 public:
131  explicit RadioIDList(QObject *parent=nullptr);
132 
133  void clear();
134 
136  DMRRadioID *getId(int idx) const;
138  DMRRadioID * defaultId() const;
140  bool setDefaultId(int idx);
142  DMRRadioID *find(uint32_t id) const;
143 
144  int add(ConfigObject *obj, int row=-1);
145 
147  virtual int addId(const QString &name, uint32_t id);
149  virtual bool delId(uint32_t id);
150 
151 public:
152  ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
153 
154 protected slots:
156  void onDefaultIdDeleted();
157 
158 protected:
161 };
162 
163 
164 #endif // RADIOID_HH
Parse context for config objects.
Definition: configobject.hh:48
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
List class for config objects.
Definition: configobject.hh:341
Base class of all labeled and named objects.
Definition: configobject.hh:199
QString name
The name of the object.
Definition: configobject.hh:203
Represents a DMR radio ID within the abstract config.
Definition: radioid.hh:31
unsigned number
The number of the radio ID.
Definition: radioid.hh:36
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:88
ConfigItem * clone() const
Clones this item.
Definition: radioid.cc:38
void setNumber(uint32_t number)
Sets the DMR ID.
Definition: radioid.cc:53
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: radioid.cc:61
DMRRadioID(QObject *parent=nullptr)
Default constructor.
Definition: radioid.cc:25
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:74
uint32_t _number
Holds the DMR ID.
Definition: radioid.hh:61
Represents a DTMF radio ID as used for PTT-ID on analog channels.
Definition: radioid.hh:90
ConfigItem * clone() const
Clones this item.
Definition: radioid.cc:137
QString _number
Holds the DTMF number of the radio ID.
Definition: radioid.hh:116
DTMFRadioID(QObject *parent=nullptr)
Default constructor.
Definition: radioid.cc:124
QString number
The DTMF number of the radio ID.
Definition: radioid.hh:95
void setNumber(const QString &number)
Sets the DTMF number of the radio ID.
Definition: radioid.cc:151
A singleton radio ID representing the default DMR radio ID within the abstract config.
Definition: radioid.hh:68
DefaultRadioID(QObject *parent=nullptr)
Constructor.
Definition: radioid.cc:107
static DefaultRadioID * get()
Factory method returning the singleton instance.
Definition: radioid.cc:114
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Represents the list of configured DMR IDs (radio IDs) within the abstract config.
Definition: radioid.hh:126
DMRRadioID * defaultId() const
Returns the current default ID for the radio.
Definition: radioid.cc:183
void clear()
Clears the list.
Definition: radioid.cc:170
virtual int addId(const QString &name, uint32_t id)
Adds the given DMR ID.
Definition: radioid.cc:214
void onDefaultIdDeleted()
Gets call whenever the default DMR ID gets deleted.
Definition: radioid.cc:270
DMRRadioID * _default
Holds a weak reference to the default DMR radio ID.
Definition: radioid.hh:160
RadioIDList(QObject *parent=nullptr)
Constructor.
Definition: radioid.cc:163
bool setDefaultId(int idx)
Sets the default DMR ID.
Definition: radioid.cc:219
int add(ConfigObject *obj, int row=-1)
Adds an element to the list.
Definition: radioid.cc:197
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:246
virtual bool delId(uint32_t id)
Deletes and removes the given DMR ID.
Definition: radioid.cc:240
DMRRadioID * find(uint32_t id) const
Searches the DMR ID object associated with the given DMR ID.
Definition: radioid.cc:188
DMRRadioID * getId(int idx) const
Returns the radio ID at the given index.
Definition: radioid.cc:176
Abstract base class for all radio IDs.
Definition: radioid.hh:13
RadioID(QObject *parent=nullptr)
Hidden default constructor.
Definition: radioid.cc:9