ALBULA  4.0.1
dectris.albula.DNeXusTree Class Reference

class DNeXusTree forms a tree like representation of the NeXus/Hdf5 header. More...

Public Member Functions

def DNeXusTree ()
 Construct empty tree with a single root node. More...
 
def DNeXusTree (other)
 Copy constructor. More...
 
def contains (node)
 Return true if node is part of the tree, else false. More...
 
def at (path)
 Returns reference to NeXus node at given path. More...
 
def newPath (path, type)
 Add a new absolute path (starting with '/') or relative to root(). More...
 
def root ()
 Access the root node. More...
 
def toXml ()
 Write to xml string. More...
 
def fromXml (xmlString)
 Read from xml string. More...
 

Detailed Description

class DNeXusTree forms a tree like representation of the NeXus/Hdf5 header.

Every node in that tree is represented by an instance of DNeXusNode. Possible issue: As soon as a DNeXusNode object goes out of scope, all its children are deleted. So references kept to a DNeXusNode child, whose parent object has been destroyed, become invalid. Consider the following simple example:

n = DNeXusTree()
n = n.root().attachChild("some_child") # Here the previous n goes out of scope and n becomes invalid

In the second line a new child is attached to n. By assigning a new value to n its old value goes out of scope and is destroyed together with its child. Hence n points now to an object that has already been destroyed.

Constructor & Destructor Documentation

◆ DNeXusTree() [1/2]

def dectris.albula.DNeXusTree.DNeXusTree ( )

Construct empty tree with a single root node.

The root node may be obtained by root().

◆ DNeXusTree() [2/2]

def dectris.albula.DNeXusTree.DNeXusTree (   other)

Copy constructor.

In general very fast as copying of the underlying NeXus tree is postponed to the first non constant access

Member Function Documentation

◆ at()

def dectris.albula.DNeXusTree.at (   path)

Returns reference to NeXus node at given path.

Parameters
pathString containing the NeXus path
Returns
Reference to NeXus node

◆ contains()

def dectris.albula.DNeXusTree.contains (   node)

Return true if node is part of the tree, else false.

◆ fromXml()

def dectris.albula.DNeXusTree.fromXml (   xmlString)

Read from xml string.

Parameters
xmlStringString

◆ newPath()

def dectris.albula.DNeXusTree.newPath (   path,
  type 
)

Add a new absolute path (starting with '/') or relative to root().

Depending on type returns a reference to DNeXusGroup (DNeXusNode.GROUP), DNeXusData (DNeXusNode.DATA) or DNeXusAttribute (DNeXusNode.ATTRIBUTE)

Parameters
pathString with path ot new NeXus node
typeDNeXusNode.GROUP (=0), DNeXusNode.DATA (=1) or DNeXusNode.ATTRIBUTE (=2)
Returns
Reference to new DNeXusNode

◆ root()

def dectris.albula.DNeXusTree.root ( )

Access the root node.

Returns
DNeXusGroup

◆ toXml()

def dectris.albula.DNeXusTree.toXml ( )

Write to xml string.

Returns
xml string