20 #ifndef GAIA_DESCRIPTORTREE_H 21 #define GAIA_DESCRIPTORTREE_H 24 #include <QStringList> 29 #define NOCONST_CALL(f) const_cast<DescriptorTree*>(const_cast<const DescriptorTree*>(this)->f) 79 QString
name()
const {
return _segment.name; }
88 QString
fullName(
bool recurseDown =
true)
const;
108 bool isLeaf()
const {
return _children.empty(); }
147 void removeNode(
const QString& name,
bool recurse =
true);
155 void removeNodes(
const QStringList& names,
bool recurse =
true);
229 void printLeafSegments()
const;
236 QString
toYaml(
int spaces = 0)
const;
242 void checkConsistency()
const;
255 QList<DescriptorTree*> _children;
263 QList<DescriptorTree*> dfs;
264 QList<const DescriptorTree*> dfsConst;
265 QList<DescriptorTree*> leaves;
266 QList<const DescriptorTree*> leavesConst;
267 int realSize, stringSize, enumSize;
268 int realSizeFixed, stringSizeFixed, enumSizeFixed;
277 QList<DescriptorTree*>
nodes();
278 QList<DescriptorTree*> leaves();
280 QList<const DescriptorTree*>
nodes()
const;
281 QList<const DescriptorTree*> leaves()
const;
283 QList<const DescriptorTree*> dfsNoCache()
const;
287 void reorder()
const;
288 void recomputeCaches()
const;
289 void recomputeHash()
const;
310 const DescriptorTree*
find(
const QStringList& nodeList,
bool onlyLeaves,
int i=0)
const;
312 friend QDataStream& operator<<(QDataStream& out,
const DescriptorTree& tree);
313 friend QDataStream& operator>>(QDataStream& in,
DescriptorTree& tree);
320 #endif // GAIA_DESCRIPTORTREE_H DescriptorLengthType lengthType() const
Returns the length type of this node.
Definition: descriptortree.cpp:93
void modify()
Function to be called by each non const function as soon as it modifies the tree, so as to know when ...
Definition: descriptortree.cpp:133
QString toYaml(int spaces=0) const
Returns a yaml string representing the hierachy of descriptors that this tree represents.
Definition: descriptortree.cpp:636
A region is a physical location in the point layout which consists in a list of segments.
Definition: region.h:125
Region correspondingRegion() const
Returns a Region formed by the merged segments of all the children of this node.
Definition: descriptortree.cpp:280
DescriptorTree * copy() const
Make a deep-copy of this region-tree.
Definition: descriptortree.cpp:66
void updateSegments(const QList< DescriptorTree * > &lrt) const
Updates the segments' begin and end indices so that all segments are contiguous and sorted alphabetic...
Definition: descriptortree.cpp:518
void removeChild(DescriptorTree *child)
Removes given DescriptorTree from this node's children.
Definition: descriptortree.cpp:170
void clear()
Resets this tree to a single root node.
Definition: descriptortree.cpp:114
void removeNode(const QString &name, bool recurse=true)
Remove the node with the given fully-qualified name.
Definition: descriptortree.cpp:180
const DescriptorTree * find(const QString &name) const
Find the node with given name (be it a leaf or not).
Definition: descriptortree.cpp:358
void removeNodes(const QStringList &names, bool recurse=true)
Remove the list of nodes with the given fully-qualified name.
Definition: descriptortree.cpp:188
void enumerate()
Sets this descriptor to be an enumeration.
Definition: descriptortree.cpp:231
Definition: descriptortree.h:37
A segment is a physical contiguous location of descriptors of the same type in the point layout...
Definition: region.h:75
void updateLayout()
This function takes all the segments of the current DescriptorTree, orders them by type and by alphab...
Definition: descriptortree.cpp:545
const DescriptorTree * findFromRoot(const QString &name) const
Find the node with the given name (be it a leaf or not).
Definition: descriptortree.cpp:374
DescriptorLengthType
Either fixed-length or variable-length.
Definition: region.h:46
QList< DescriptorTree * > nodes()
Returns all the nodes of this tree in a list, corresponding to a DFS search.
Definition: descriptortree.cpp:481
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
void detach()
detach this tree from its (possible) current parent.
Definition: descriptortree.cpp:151
void addChild(DescriptorTree *t)
Add the given DescriptorTree to this node's children.
Definition: descriptortree.cpp:159
QStringList descriptorNames() const
Returns a list of all the descriptor names contained in this layout.
Definition: descriptortree.cpp:262
QString fullName(bool recurseDown=true) const
Returns the fully-qualified name of this node, eg: using the names of the nodes from the root down to...
Definition: descriptortree.cpp:75
Definition: descriptortree.h:261
DescriptorTree * findSimple(const QString &name)
Find the node in this tree that has the given (short) name.
Definition: descriptortree.cpp:304
void fixLength(int length)
Sets this descriptor to be of the specified fixed length.
Definition: descriptortree.cpp:219
DescriptorType
The possible types of descriptors accepted.
Definition: region.h:36
const DescriptorTree * findLeaf(const QString &name) const
Find the leaf with given name.
Definition: descriptortree.cpp:315
DescriptorType type() const
Returns the type of this node.
Definition: descriptortree.cpp:85
bool subtreeOf(const DescriptorTree *other) const
Returns whether this tree is a subset of the given one (e.g.
Definition: descriptortree.cpp:608
const DescriptorTree * root() const
Returns the root of the tree which this node pertains to.
Definition: descriptortree.cpp:128
DescriptorTree * root()
Returns the root of the tree which this node pertains to.
Definition: descriptortree.h:118
QString descriptorName(DescriptorType type, DescriptorLengthType ltype, int index) const
Returns the name of the descriptor which is located at given position.
Definition: descriptortree.cpp:250
QString name() const
Returns the name of the current node.
Definition: descriptortree.h:79
bool isLeaf() const
Returns whether this node is a leaf (terminal node) or not.
Definition: descriptortree.h:108