libdrmconf  0.11.3
A library to program DMR radios.
config.hh
1 
38 #ifndef CONFIG_HH
39 #define CONFIG_HH
40 
41 #include <QTextStream>
42 
43 #include "configobject.hh"
44 #include "contact.hh"
45 #include "rxgrouplist.hh"
46 #include "channel.hh"
47 #include "zone.hh"
48 #include "scanlist.hh"
49 #include "gpssystem.hh"
50 #include "roamingchannel.hh"
51 #include "roamingzone.hh"
52 #include "radioid.hh"
53 #include "radiosettings.hh"
54 
55 #include "commercial_extension.hh"
56 #include "tyt_extensions.hh"
57 
58 // Forward declaration
59 class UserDatabase;
60 
61 
68 class Config : public ConfigItem
69 {
70  Q_OBJECT
71 
73  Q_PROPERTY(RadioSettings* settings READ settings SCRIPTABLE false)
75  Q_PROPERTY(RadioIDList* radioIDs READ radioIDs SCRIPTABLE false)
77  Q_PROPERTY(ContactList* contacts READ contacts SCRIPTABLE false)
79  Q_PROPERTY(RXGroupLists* groupLists READ rxGroupLists SCRIPTABLE false)
81  Q_PROPERTY(ChannelList* channels READ channelList SCRIPTABLE false)
83  Q_PROPERTY(ZoneList* zones READ zones SCRIPTABLE false)
85  Q_PROPERTY(ScanLists* scanLists READ scanlists SCRIPTABLE false)
87  Q_PROPERTY(PositioningSystems* positioning READ posSystems SCRIPTABLE false)
89  Q_PROPERTY(RoamingChannelList* roamingChannels READ roamingChannels SCRIPTABLE false)
91  Q_PROPERTY(RoamingZoneList* roamingZones READ roamingZones SCRIPTABLE false)
92 
93 
97 
98 public:
100  explicit Config(QObject *parent = nullptr);
101 
102  bool copy(const ConfigItem &other);
103  ConfigItem *clone() const;
104 
106  bool isModified() const;
108  void setModified(bool modified);
109 
111  RadioSettings *settings() const;
113  RadioIDList *radioIDs() const;
115  ContactList *contacts() const;
117  RXGroupLists *rxGroupLists() const;
119  ChannelList *channelList() const;
121  ZoneList *zones() const;
123  ScanLists *scanlists() const;
129  RoamingZoneList *roamingZones() const;
130 
132  bool requiresRoaming() const;
134  bool requiresGPS() const;
135 
137  void clear();
138 
139  const Config *config() const;
140 
143 
149 
150 
151 public:
153  bool readCSV(const QString &filename, QString &errorMessage);
155  bool readCSV(QTextStream &stream, QString &errorMessage);
156 
158  bool readYAML(const QString &filename, const ErrorStack &err=ErrorStack());
159 
160  bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
161  bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack());
162 
163 public:
165  bool toYAML(QTextStream &stream, const ErrorStack &err=ErrorStack());
166 
167 protected:
168  bool populate(YAML::Node &node, const Context &context, const ErrorStack &err=ErrorStack());
169 
170 protected slots:
172  void onConfigModified();
173 
174 protected:
176  bool _modified;
201 };
202 
203 #endif // CONFIG_HH
Container class holding all channels (analog and digital) for a specific configuration (Config).
Definition: channel.hh:544
Implements the generic extension for the codeplug to represent some commercial features of DMR.
Definition: commercial_extension.hh:11
Parse context for config objects.
Definition: configobject.hh:48
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
void modified(ConfigItem *obj)
Gets emitted once the config object is modified.
The config class, representing the codeplug configuration.
Definition: config.hh:69
RoamingZoneList * _roamingZones
The list of roaming zones.
Definition: config.hh:196
ContactList * _contacts
The list of contacts.
Definition: config.hh:182
bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack())
Links the given object to the rest of the codeplug using the given context.
Definition: config.cc:409
ScanLists * scanLists
The list of scan lists.
Definition: config.hh:85
TyTConfigExtension * tytExtension
Represents the config extension for TyT devices.
Definition: config.hh:96
bool copy(const ConfigItem &other)
Copies the given item into this one.
Definition: config.cc:62
ScanLists * _scanlists
The list of scan lists.
Definition: config.hh:190
RoamingChannelList * roamingChannels
The list of roaming channels.
Definition: config.hh:89
RoamingChannelList * _roamingChannels
The list of roaming channels.
Definition: config.hh:194
ContactList * contacts
The list of contacts.
Definition: config.hh:77
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition: config.cc:360
void onConfigModified()
Iternal callback.
Definition: config.cc:300
bool readYAML(const QString &filename, const ErrorStack &err=ErrorStack())
Imports a configuration from the given YAML file.
Definition: config.cc:325
RXGroupLists * rxGroupLists() const
Returns the list of RX group lists.
Definition: config.cc:185
RadioSettings * _settings
Radio wide settings.
Definition: config.hh:178
RadioIDList * _radioIDs
The list of radio IDs.
Definition: config.hh:180
bool requiresGPS() const
Returns true if one of the channels has a GPS or APRS system assigned.
Definition: config.cc:236
ChannelList * channels
The list of channels.
Definition: config.hh:81
bool populate(YAML::Node &node, const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition: config.cc:118
RXGroupLists * groupLists
The list of group lists.
Definition: config.hh:79
Config(QObject *parent=nullptr)
Constructs an empty configuration.
Definition: config.cc:20
void clear()
Clears the complete configuration.
Definition: config.cc:253
RoamingZoneList * roamingZones
The list of roaming zones.
Definition: config.hh:91
ChannelList * channelList() const
Returns the list of channels.
Definition: config.cc:190
CommercialExtension * commercial
Represents the config extension for encryption keys.
Definition: config.hh:94
TyTConfigExtension * _tytExtension
Owns the TyT settings extension.
Definition: config.hh:198
RadioIDList * radioIDs
The list of radio IDs.
Definition: config.hh:75
bool toYAML(QTextStream &stream, const ErrorStack &err=ErrorStack())
Serializes the configuration into the given stream as text.
Definition: config.cc:101
PositioningSystems * positioning
The list of positioning systems.
Definition: config.hh:87
ConfigItem * clone() const
Clones this item.
Definition: config.cc:82
ZoneList * _zones
The list of zones.
Definition: config.hh:188
ScanLists * scanlists() const
Returns the list of scanlists.
Definition: config.cc:200
CommercialExtension * commercialExtension() const
Returns the commercial extension.
Definition: config.cc:278
ChannelList * _channels
The list of channels.
Definition: config.hh:186
const Config * config() const
Returns the config, the item belongs to or nullptr if not part of a config.
Definition: config.cc:272
PositioningSystems * posSystems() const
Returns the list of positioning systems.
Definition: config.cc:205
bool requiresRoaming() const
Returns true if one of the digital channels has a roaming zone assigned.
Definition: config.cc:220
PositioningSystems * _gpsSystems
The list of GPS Systems.
Definition: config.hh:192
ZoneList * zones
The list of zones.
Definition: config.hh:83
void setTyTExtension(TyTConfigExtension *ext)
Sets the TyT settings extension.
Definition: config.cc:287
bool readCSV(const QString &filename, QString &errorMessage)
Imports a configuration from the given file.
Definition: config.cc:306
RadioSettings * settings
The global radio settings.
Definition: config.hh:73
void setModified(bool modified)
Sets the modified flag.
Definition: config.cc:96
bool _modified
If true, the configuration was modified.
Definition: config.hh:176
bool isModified() const
Returns true if the config was modified,.
Definition: config.cc:92
CommercialExtension * _commercialExtension
Owns the commercial extension.
Definition: config.hh:200
RXGroupLists * _rxGroupLists
The list of RX group lists.
Definition: config.hh:184
Represents the list of contacts within the abstract radio configuration.
Definition: contact.hh:223
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
The list of positioning systems.
Definition: gpssystem.hh:267
Represents the list of RX group lists within the generic configuration.
Definition: rxgrouplist.hh:68
Represents the list of configured DMR IDs (radio IDs) within the abstract config.
Definition: radioid.hh:126
Represents the common radio-global settings.
Definition: radiosettings.hh:14
Represents the list of roaming channels within the abstract device configuration.
Definition: roamingchannel.hh:99
Represents the list of roaming zones within the abstract device configuration.
Definition: roamingzone.hh:101
Represents the list of scan lists.
Definition: scanlist.hh:112
Groups several extension for TyT devices.
Definition: tyt_extensions.hh:1025
Auto-updating DMR user database.
Definition: userdatabase.hh:23
Represents the list of zones within the generic configuration.
Definition: zone.hh:75