libdrmconf  0.11.3
A library to program DMR radios.
Classes | Signals | Public Member Functions | Protected Member Functions | List of all members
ConfigItem Class Referenceabstract

Base class for all configuration objects (channels, zones, contacts, etc). More...

#include <configobject.hh>

Inheritance diagram for ConfigItem:
Inheritance graph
[legend]
Collaboration diagram for ConfigItem:
Collaboration graph
[legend]

Classes

class  Context
 Parse context for config objects. More...
 

Signals

void modified (ConfigItem *obj)
 Gets emitted once the config object is modified. More...
 
void beginClear ()
 Gets emitted before clearing the item.
 
void endClear ()
 Gets emitted after clearing the item.
 

Public Member Functions

virtual bool copy (const ConfigItem &other)
 Copies the given item into this one. More...
 
virtual ConfigItemclone () const =0
 Clones this item.
 
virtual int compare (const ConfigItem &other) const
 Compares the items. More...
 
virtual bool label (Context &context, const ErrorStack &err=ErrorStack())
 Recursively labels the config object. More...
 
virtual YAML::Node serialize (const Context &context, const ErrorStack &err=ErrorStack())
 Recursively serializes the configuration to YAML nodes. More...
 
virtual ConfigItemallocateChild (QMetaProperty &prop, const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack())
 Allocates an instance for the given property on the given YAML node. More...
 
virtual 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). More...
 
virtual 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.
 
virtual void clear ()
 Clears the config object.
 
virtual const Configconfig () const
 Returns the config, the item belongs to or nullptr if not part of a config.
 
virtual void findItemsOfTypes (const QStringList &typeNames, QSet< ConfigItem * > &items) const
 Searches the config tree to find all instances of the given type names.
 
template<class Object >
bool is () const
 Returns true if this object is of class Object.
 
template<class Object >
const Object * as () const
 Casts this object to the given type.
 
template<class Object >
Object * as ()
 Casts this object to the given type.
 
bool hasDescription () const
 Returns true if there is a class info "description" for this instance.
 
bool hasLongDescription () const
 Returns true if there is a class info "longDescription" for this instance.
 
bool hasDescription (const QMetaProperty &prop) const
 Returns true if there is a class info "[PropertyName]Description" for the given property.
 
bool hasLongDescription (const QMetaProperty &prop) const
 Returns true if there is a class info "[PropertyName]LongDescription" for the given property.
 
QString description () const
 Returns the description of this instance if set by a class info.
 
QString longDescription () const
 Returns the long description of this instance if set by a class info.
 
QString description (const QMetaProperty &prop) const
 Returns the description of property if set by a class info.
 
QString longDescription (const QMetaProperty &prop) const
 Returns the long description of property if set by a class info.
 

Protected Member Functions

 ConfigItem (QObject *parent=nullptr)
 Hidden constructor. More...
 
virtual bool populate (YAML::Node &node, const Context &context, const ErrorStack &err=ErrorStack())
 Recursively serializes the configuration to YAML nodes. More...
 

Detailed Description

Base class for all configuration objects (channels, zones, contacts, etc).

Constructor & Destructor Documentation

◆ ConfigItem()

ConfigItem::ConfigItem ( QObject *  parent = nullptr)
explicitprotected

Hidden constructor.

Parameters
parentSpecifies the QObject parent.

Member Function Documentation

◆ allocateChild()

ConfigItem * ConfigItem::allocateChild ( QMetaProperty &  prop,
const YAML::Node &  node,
const Context ctx,
const ErrorStack err = ErrorStack() 
)
virtual

Allocates an instance for the given property on the given YAML node.

This is usually done automatically based on the meta-type of the property. To be able to instantiate the item, its default constructor must be Q_INVOKABLE.

◆ compare()

int ConfigItem::compare ( const ConfigItem other) const
virtual

Compares the items.

This method returns 0 if the two items are equivalent and -1, 1 otherwise. The established order is somewhat arbitrary.

Returns
0 if the two items are equivalent, -1 or 1 otherwise.

◆ copy()

bool ConfigItem::copy ( const ConfigItem other)
virtual

Copies the given item into this one.

Returns
true if copying was successful and false otherwise. The two items must be of the same type (obviously).

Reimplemented in RadioSettings, Melody, APRSSystem, Config, SelectedChannel, FMChannel, and Channel.

◆ label()

bool ConfigItem::label ( ConfigObject::Context context,
const ErrorStack err = ErrorStack() 
)
virtual

Recursively labels the config object.

Does not assign a label if the idBase passed to the constructor is empty.

Reimplemented in ConfigObject.

◆ modified

void ConfigItem::modified ( ConfigItem obj)
signal

Gets emitted once the config object is modified.

The instance passed is the modified item, this event is passed up the config tree.

◆ parse()

bool ConfigItem::parse ( const YAML::Node &  node,
ConfigItem::Context ctx,
const ErrorStack err = ErrorStack() 
)
virtual

Parses the given YAML node, updates the given object and updates the given context (IDs).

Todo:
With Qt 5.15, we can use the REQUIRED flag to check for mandatory properties. However, Ubuntu 20.04 (Focal) comes with Qt 5.12.

Reimplemented in APRSSystem, PositioningSystem, AESEncryptionKey, DMREncryptionKey, Contact, ConfigObject, Config, FMChannel, Channel, RoamingChannel, and DMRRadioID.

◆ populate()

bool ConfigItem::populate ( YAML::Node &  node,
const Context context,
const ErrorStack err = ErrorStack() 
)
protectedvirtual

Recursively serializes the configuration to YAML nodes.

The complete configuration must be labeled first.

Reimplemented in APRSSystem, ConfigObject, Config, FMChannel, Channel, RoamingZone, RoamingChannel, and PositioningSystem.

◆ serialize()

YAML::Node ConfigItem::serialize ( const Context context,
const ErrorStack err = ErrorStack() 
)
virtual

Recursively serializes the configuration to YAML nodes.

The complete configuration must be labeled first.

Reimplemented in RXGroupList, DMRRadioID, APRSSystem, GPSSystem, AESEncryptionKey, DMREncryptionKey, DMRContact, DTMFContact, DMRChannel, and FMChannel.


The documentation for this class was generated from the following files: