libdrmconf  0.12.0
A library to program DMR radios.
configcopyvisitor.hh
1 #ifndef CONFIGCOPYVISITOR_HH
2 #define CONFIGCOPYVISITOR_HH
3 
4 #include "visitor.hh"
5 
6 class ConfigObject;
7 
12 {
13 public:
16  ConfigCloneVisitor(QHash<ConfigObject *, ConfigObject*> &map);
17 
18  bool processProperty(ConfigItem *item, const QMetaProperty &prop, const ErrorStack &err=ErrorStack());
19  bool processItem(ConfigItem *item, const ErrorStack &err=ErrorStack());
21 
24 
25 protected:
27  QList<QObject *> _stack;
29  QHash<ConfigObject *, ConfigObject*> &_map;
30 };
31 
32 
38 {
39 public:
41  FixReferencesVisistor(QHash<ConfigObject *, ConfigObject*> &map, bool keepUnknown=false);
42 
43  bool processProperty(ConfigItem *item, const QMetaProperty &prop, const ErrorStack &err=ErrorStack());
45 
46 protected:
48  QHash<ConfigObject *, ConfigObject*> &_map;
51 };
52 
54 class ConfigCopy {
55 public:
57  static ConfigItem *copy(ConfigItem *original, const ErrorStack &err=ErrorStack());
58 };
59 
60 #endif // CONFIGCOPYVISITOR_HH
Generic list class for config objects.
Definition: configobject.hh:258
This visitor traverses the the given configuration and clones it.
Definition: configcopyvisitor.hh:12
ConfigCloneVisitor(QHash< ConfigObject *, ConfigObject * > &map)
Constructor.
Definition: configcopyvisitor.cc:12
bool processItem(ConfigItem *item, const ErrorStack &err=ErrorStack())
Traverses the specified config item.
Definition: configcopyvisitor.cc:189
QHash< ConfigObject *, ConfigObject * > & _map
Reference to the translation table origial -> cloned object.
Definition: configcopyvisitor.hh:29
ConfigItem * takeResult(const ErrorStack &err=ErrorStack())
Extracts the cloned item.
Definition: configcopyvisitor.cc:250
QList< QObject * > _stack
Stack of the current object.
Definition: configcopyvisitor.hh:27
bool processList(AbstractConfigObjectList *list, const ErrorStack &err=ErrorStack())
Traverses the list of objects or references.
Definition: configcopyvisitor.cc:209
bool processProperty(ConfigItem *item, const QMetaProperty &prop, const ErrorStack &err=ErrorStack())
Processes the specified property of the item.
Definition: configcopyvisitor.cc:20
Just a name space to hold the copy function.
Definition: configcopyvisitor.hh:54
static ConfigItem * copy(ConfigItem *original, const ErrorStack &err=ErrorStack())
Copies the given item.
Definition: configcopyvisitor.cc:337
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
Base class of all labeled and named objects.
Definition: configobject.hh:199
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Replaces references using a specified map.
Definition: configcopyvisitor.hh:38
bool processProperty(ConfigItem *item, const QMetaProperty &prop, const ErrorStack &err=ErrorStack())
Processes the specified property of the item.
Definition: configcopyvisitor.cc:281
QHash< ConfigObject *, ConfigObject * > & _map
Reference to the translation table origial -> cloned object.
Definition: configcopyvisitor.hh:48
bool _keepUnknown
If false, an unmapped reference is an error.
Definition: configcopyvisitor.hh:50
bool processList(AbstractConfigObjectList *list, const ErrorStack &err=ErrorStack())
Traverses the list of objects or references.
Definition: configcopyvisitor.cc:305
FixReferencesVisistor(QHash< ConfigObject *, ConfigObject * > &map, bool keepUnknown=false)
Constructor.
Definition: configcopyvisitor.cc:271
Base visitor class for the config tree.
Definition: visitor.hh:20