HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_InfoTree Class Reference

#include <UT_InfoTree.h>

Public Member Functions

 UT_InfoTree (UT_InfoTree *tree_top=NULL, UT_InfoTree *parent=NULL, const UT_StringHolder &name=TREE_TOP_DEFAULT_NAME)
 
 ~UT_InfoTree ()
 
void clearProperties ()
 
void clearChildren ()
 Clears all child branches. Doesn't affect our properties. More...
 
UT_InfoTreeaddChildBranch (const UT_StringHolder &name)
 
UT_InfoTreeaddChildMap (const UT_StringHolder &name)
 Adds a child branch with "Property" and "Value" headings. More...
 
ut_PropertyRowaddProperties ()
 Create a new empty row. More...
 
template<class ValType1 >
ut_PropertyRowaddProperties (const ValType1 &v1)
 
template<class ValType1 , class ValType2 >
ut_PropertyRowaddProperties (const ValType1 &v1, const ValType2 &v2)
 
template<class ValType1 , class ValType2 , class ValType3 >
ut_PropertyRowaddProperties (const ValType1 &v1, const ValType2 &v2, const ValType3 &v3)
 
template<class ValType1 , class ValType2 , class ValType3 , class ValType4 >
ut_PropertyRowaddProperties (const ValType1 &v1, const ValType2 &v2, const ValType3 &v3, const ValType4 &v4)
 
void addColumnHeading (const UT_StringHolder &label, fpreal width=-1.0)
 
void addColumnHeading (int label, fpreal width=-1.0)
 
UT_InfoTreegetParentBranch () const
 Get a pointer to my parent. More...
 
UT_InfoTreegetTreeTop () const
 Get a pointer to the very top node in the tree. More...
 
const UT_StringHoldergetName () const
 Return this branch's name. More...
 
void setName (const UT_StringHolder &new_name)
 In case we decide to change the name of this branch. More...
 
const UT_StringHoldergetInfoType () const
 Return this branch's "type" idwentifier. More...
 
void setInfoType (const UT_StringHolder &new_type)
 In case we decide to change the "type" of this branch. More...
 
UT_InfoTreegetDescendentPtr (UT_StringArray &path)
 
const UT_Array< UT_InfoTree * > & getChildBranches () const
 
const UT_Array< ut_PropertyRow * > & getProperties () const
 
const ut_PropertyRowgetColumnHeadings () const
 
const UT_FloatArraygetColumnWidths () const
 

Static Public Member Functions

static const UT_StringHoldergetGeometryInfoType ()
 
static const UT_StringHoldergetFieldInfoType ()
 

Detailed Description

This is a tree in which each node can have as many children as it likes, and at each node we can store data in the form of strings (which are stored in arrays/rows, in case we want to display each row in a spreadsheet table).

Definition at line 75 of file UT_InfoTree.h.

Constructor & Destructor Documentation

UT_InfoTree::UT_InfoTree ( UT_InfoTree tree_top = NULL,
UT_InfoTree parent = NULL,
const UT_StringHolder name = TREE_TOP_DEFAULT_NAME 
)

User should always call this constructor with no parameters specified. The parameters are only needed when branches are created internally.

UT_InfoTree::~UT_InfoTree ( )

Recursively deletes all my data and all children, which in turn delete all their data and children, etc...

Member Function Documentation

UT_InfoTree* UT_InfoTree::addChildBranch ( const UT_StringHolder name)

Create a child or subtree under this tree with the name 'branch_name' The caller should NOT call delete on the pointer returned when they are done with it, since this class' destructor will take care of any children created in addChildBranch(..).

IMPORTANT NOTE: It is assumed that all branches on the same level will have unique names, BUT this is NOT enforced to prevent a performance hit since these trees can get rebuilt pretty often to accurately reflect the data they are containing. BOTTOM LINE: Make sure 'branch_name' is unique among 'myChildBranches' (otherwise there'll be trouble when we decide to traverse a tree given a path of branches - system won't crash, but will always choose the first available branch on a level with the name it is looking for).

UT_InfoTree* UT_InfoTree::addChildMap ( const UT_StringHolder name)

Adds a child branch with "Property" and "Value" headings.

void UT_InfoTree::addColumnHeading ( const UT_StringHolder label,
fpreal  width = -1.0 
)

Add column headings for this node to be used when the info is displayed in a table. THE NUMBER OF HEADINGS ADDED HERE WILL DETERMINE THE NUMBER OF COLUMNS DISPLAYED. Note: This class does NOT ensure that the # of column headings matches the width of each property array in 'myProperties'. Instead, we only display as many properties per row as we have number of columns.

The width parameter must either be specified on all columns or on none. If set on all columns, it represents the fraction of the total width that gets allocated to that column (the values get normalized). If any column has a width specified of <= 0.0, the whole thing reverts to the default behavior of allocating all columns with equal width.

void UT_InfoTree::addColumnHeading ( int  label,
fpreal  width = -1.0 
)
ut_PropertyRow* UT_InfoTree::addProperties ( )

Create a new empty row.

template<class ValType1 >
ut_PropertyRow * UT_InfoTree::addProperties ( const ValType1 &  v1)

HOW TO USE: You may add up to 4 properties to a single row at once using these methods. If you still need to add more properties to this SAME row/array after that, simply use the returned ut_PropertyRow* to call 'append()' on and add more properties. To add properties that are ints, use the same technique, since there is an 'append()' method in ut_PropertyRow that takes an int parameter (or check the overridden version of addProperties below). BOTTOM LINE - if you want maximum flexibility, call this with no parameters and then append each property manually to the returned ut_PropertyRow*.

Definition at line 215 of file UT_InfoTree.h.

template<class ValType1 , class ValType2 >
ut_PropertyRow * UT_InfoTree::addProperties ( const ValType1 &  v1,
const ValType2 &  v2 
)

Definition at line 230 of file UT_InfoTree.h.

template<class ValType1 , class ValType2 , class ValType3 >
ut_PropertyRow * UT_InfoTree::addProperties ( const ValType1 &  v1,
const ValType2 &  v2,
const ValType3 &  v3 
)

Definition at line 247 of file UT_InfoTree.h.

template<class ValType1 , class ValType2 , class ValType3 , class ValType4 >
ut_PropertyRow * UT_InfoTree::addProperties ( const ValType1 &  v1,
const ValType2 &  v2,
const ValType3 &  v3,
const ValType4 &  v4 
)

Definition at line 266 of file UT_InfoTree.h.

void UT_InfoTree::clearChildren ( )

Clears all child branches. Doesn't affect our properties.

void UT_InfoTree::clearProperties ( )

Clears all our row and column information. Doesn't affect child branches.

const UT_Array<UT_InfoTree *>& UT_InfoTree::getChildBranches ( ) const
const ut_PropertyRow& UT_InfoTree::getColumnHeadings ( ) const
const UT_FloatArray& UT_InfoTree::getColumnWidths ( ) const
UT_InfoTree* UT_InfoTree::getDescendentPtr ( UT_StringArray path)

Get a ptr to a specific descendant branch of this tree, given a UT_StringArray of branch names. e.g. if you want to traverse down the tree through a child branch named "Antigen" and get a pointer to that branch's child called "Rocks", then your UT_StringArray should simply have 2 elements, "Antigen" and "Rocks", respectively in that order. Method returns NULL if no such valid path found.

NOTE: Again, this assumes all branches at the same level have unique names, as stated above for 'addChildBranch()'.

static const UT_StringHolder& UT_InfoTree::getFieldInfoType ( )
static
static const UT_StringHolder& UT_InfoTree::getGeometryInfoType ( )
static
const UT_StringHolder& UT_InfoTree::getInfoType ( ) const

Return this branch's "type" idwentifier.

const UT_StringHolder& UT_InfoTree::getName ( ) const

Return this branch's name.

UT_InfoTree* UT_InfoTree::getParentBranch ( ) const

Get a pointer to my parent.

const UT_Array<ut_PropertyRow *>& UT_InfoTree::getProperties ( ) const
UT_InfoTree* UT_InfoTree::getTreeTop ( ) const

Get a pointer to the very top node in the tree.

void UT_InfoTree::setInfoType ( const UT_StringHolder new_type)

In case we decide to change the "type" of this branch.

void UT_InfoTree::setName ( const UT_StringHolder new_name)

In case we decide to change the name of this branch.


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