MeVisLab Toolbox Reference
DCMTree::Tree Class Reference

#include <DCMTree_Tree.h>

Inheritance diagram for DCMTree::Tree:
DCMTree_Serialization::Serializable DCMTree_Serialization::Deserializable

Public Member Functions

 Tree ()
 Constructor. More...
 
 Tree (const Tree &other)
 Copies all values from other to this. More...
 
 Tree (Tree &&other) noexcept=default
 
 Tree (Const_TreePtr parent)
 Initializes an empty tree representing an incremental modification to the specified parent tree. More...
 
 ~Tree () override=default
 Destructor. More...
 
Const_TreePtr parent () const
 Returns the parent as an immutable object. More...
 
Const_TreePtr root () const
 Returns the immutable root object of this. More...
 
bool hasParent () const
 Checks whether this has a parent. More...
 
bool hasDict () const
 Checks whether this has a pointer to a dictionary. More...
 
Const_DictPtr getDict () const
 Returns a pointer to the dictionary, which can be NULL. More...
 
void setDict (Const_DictPtr dictPtr)
 Sets the pointer to the dictionary. More...
 
Treeoperator= (const Tree &other)
 Assignment operator. More...
 
Treeoperator= (Tree &&other) noexcept=default
 
const TagPtrMaptags ()
 Accesses tags map of this tree, parent tags are ignored. More...
 
const TagPtrMapconstTags_rw () const
 Accesses tags map of this tree even if it is a const one to avoid expensive copy operations. More...
 
boost::uint32_t tagsSize () const
 Returns the size of tags map. More...
 
TagIdVectorPtr tagIds (TagSelector sel=AllTags) const
 Returns all tagIds of this tree in ascending order. More...
 
TagIdVectorPtr tagIds (const TagId &fromtag, const TagId &totag, TagSelector sel=AllTags) const
 Returns all tagIds of this tree ranging from fromtag to totag in ascending order. More...
 
bool hasTag (const TagId &tagid, TagSelector sel=AllTags) const
 Checks whether this has the given tag. More...
 
bool hasTag (const std::string &tagName, TagSelector sel=AllTags) const
 Checks whether this has the given tag. More...
 
Const_TagPtr getTag (const TagId &tagid, TagSelector sel=AllTags) const
 Returns read access to the tag with the given TagId. More...
 
Const_TagPtr getTag (const TagId &tagid, const std::string &privateCreator, Vr privateVr=UN, TagSelector sel=AllTags) const
 Returns read access to the private tag with the given TagId. More...
 
Const_TagPtr getTag (const std::string &tagName, TagSelector sel=AllTags) const
 Returns read access to the tag with the given tagName. More...
 
TagPtr getTag_rw (const TagId &tagid)
 Returns read/write access to the tag with the given TagId, search is restricted to owned tags. More...
 
Const_TagPtrMapPtr getTags (TagSelector sel=AllTags) const
 Accesses tags map of this tree. More...
 
Const_TagPtrMapPtr getTags (const TagId &fromtag, const TagId &totag, TagSelector sel=AllTags) const
 Accesses tags map of this tree, ranging from fromtag to totag. More...
 
void setTag (const TagId &tagid, Const_TagPtr tagdata)
 Sets the tag with the given TagId. More...
 
void setTag (Const_TagPtr tagdata)
 Convenience function for the above. More...
 
void setTags (Const_TreePtr tags)
 Sets or overwrites all tags in this from the given data. More...
 
void addTag (const TagId &tagid, TagPtr tagdata)
 Adds a tag to this; tagdata is not copied. More...
 
void addTag (TagPtr tagdata)
 Convenience function for the above. More...
 
void addTags (TreePtr tags)
 
void removeTag (const TagId &tagid)
 Drops a tag with the given tagid. More...
 
void removeTags (TagIdVectorPtr tags)
 Drops all given tags. More...
 
TreePtr copy () const
 Makes a deep copy of this, including a reference to the parent. More...
 
TreePtr copy (const TagId &fromtag, const TagId &totag) const
 Makes a deep copy of this, including only tags between and including fromtag and totag. More...
 
TreePtr copy (TagIdVectorPtr tags) const
 Makes a deep copy of this including, only tags whose IDs are within the given vector. More...
 
TreePtr mergedCopy (TagSelector sel) const
 Makes a copy of this, creating a parentless tree. More...
 
std::string getPrivateCreator (TagId tagId) const
 Returns the private creator string for the given tag ID. More...
 
unsigned short findPrivateSlot (unsigned short groupid, const std::string &creator, bool newOrExisting=false) const
 Searches for a private creator tag with specified group ID and private creator string. More...
 
unsigned short getPrivateSlot (unsigned short groupid, const std::string &creator)
 Searches for a private creator tag with specified group ID and private creator string and returns its element ID. More...
 
void removePrivateTags (unsigned short groupId, unsigned short slot)
 Removes all tags associated with a private slot in the specified group (0x10 <= slot <= 0xff). More...
 
bool convertCharacterSet (const std::string &originalcharacterset, const std::string &newcharacterset)
 Converts from one character set to another; returns false if the conversion was not possible. More...
 
void fromStream (std::istream &in, bool readName=false, size_t maxSize=0)
 Extracts this instance from the given stream. More...
 
void toStream (std::ostream &out, bool writeName=false) const
 Copies this instance recursively into the given stream. More...
 
void serializeX (DCMTree_Serialization::Sink &sink) const override
 Writes data of this object to sink. More...
 
void deserializeX (DCMTree_Serialization::Source &source) override
 Overwrites data of this object with data from source. More...
 
- Public Member Functions inherited from DCMTree_Serialization::Serializable
virtual ~Serializable ()
 Empty. More...
 
- Public Member Functions inherited from DCMTree_Serialization::Deserializable
virtual ~Deserializable ()
 Empty. More...
 

Detailed Description

Definition at line 42 of file DCMTree_Tree.h.

Constructor & Destructor Documentation

◆ Tree() [1/4]

DCMTree::Tree::Tree ( )

Constructor.

◆ Tree() [2/4]

DCMTree::Tree::Tree ( const Tree other)

Copies all values from other to this.

Uses operator=

◆ Tree() [3/4]

DCMTree::Tree::Tree ( Tree &&  other)
defaultnoexcept

◆ Tree() [4/4]

DCMTree::Tree::Tree ( Const_TreePtr  parent)

Initializes an empty tree representing an incremental modification to the specified parent tree.

Tags from the parent tree are inherited, tags stored or deleted in this tree overwrite information contained in the parent tree.

◆ ~Tree()

DCMTree::Tree::~Tree ( )
overridedefault

Destructor.

Member Function Documentation

◆ addTag() [1/2]

void DCMTree::Tree::addTag ( const TagId tagid,
TagPtr  tagdata 
)

Adds a tag to this; tagdata is not copied.

◆ addTag() [2/2]

void DCMTree::Tree::addTag ( TagPtr  tagdata)

Convenience function for the above.

It uses the tag ID contained in the tagdata.

◆ addTags()

void DCMTree::Tree::addTags ( TreePtr  tags)

◆ constTags_rw()

const TagPtrMap& DCMTree::Tree::constTags_rw ( ) const

Accesses tags map of this tree even if it is a const one to avoid expensive copy operations.

Use this with care, as it breaks constantness in favor of a fast tag map access. Use tags() instead if possible, it is left to the programmer's responsibility to avoid misuse.

◆ convertCharacterSet()

bool DCMTree::Tree::convertCharacterSet ( const std::string &  originalcharacterset,
const std::string &  newcharacterset 
)

Converts from one character set to another; returns false if the conversion was not possible.

◆ copy() [1/3]

TreePtr DCMTree::Tree::copy ( ) const

Makes a deep copy of this, including a reference to the parent.

◆ copy() [2/3]

TreePtr DCMTree::Tree::copy ( const TagId fromtag,
const TagId totag 
) const

Makes a deep copy of this, including only tags between and including fromtag and totag.

◆ copy() [3/3]

TreePtr DCMTree::Tree::copy ( TagIdVectorPtr  tags) const

Makes a deep copy of this including, only tags whose IDs are within the given vector.

◆ deserializeX()

void DCMTree::Tree::deserializeX ( DCMTree_Serialization::Source source)
overridevirtual

Overwrites data of this object with data from source.

All the rules stated for SCR::Serializable::serializeX apply correspondingly.

See also
SCR::Serializable::serializeX

Implements DCMTree_Serialization::Deserializable.

◆ findPrivateSlot()

unsigned short DCMTree::Tree::findPrivateSlot ( unsigned short  groupid,
const std::string &  creator,
bool  newOrExisting = false 
) const

Searches for a private creator tag with specified group ID and private creator string.

Returns the element ID of the private creator tag, or the element ID of an unused private creator tag if the specified creator is not present and newOrExisting is true. Returns 0 if the creator was not found or if no unused private creator tag is available.

◆ fromStream()

void DCMTree::Tree::fromStream ( std::istream &  in,
bool  readName = false,
size_t  maxSize = 0 
)

Extracts this instance from the given stream.

readName = true reads tag name(s) from stream, false assumes that no name(s) is/are in stream. IMPORTANT: This method is used for file format persistence; thus stream contents must be maintained compatible.

Referenced by DCMTree::operator>>().

◆ getDict()

Const_DictPtr DCMTree::Tree::getDict ( ) const

Returns a pointer to the dictionary, which can be NULL.

◆ getPrivateCreator()

std::string DCMTree::Tree::getPrivateCreator ( TagId  tagId) const

Returns the private creator string for the given tag ID.

If the tag is a private creator tag itself, it returns the tag value. If no private creator is defined or the tag is not a private tag, an empty string is returned.

◆ getPrivateSlot()

unsigned short DCMTree::Tree::getPrivateSlot ( unsigned short  groupid,
const std::string &  creator 
)

Searches for a private creator tag with specified group ID and private creator string and returns its element ID.

If the specified creator is not present, a new private creator tag is created and its element ID returned. Returns 0 if the creator was not found and if no unused private creator tag is available.

◆ getTag() [1/3]

Const_TagPtr DCMTree::Tree::getTag ( const std::string &  tagName,
TagSelector  sel = AllTags 
) const

Returns read access to the tag with the given tagName.

Returns An empty pointer if not found..

◆ getTag() [2/3]

Const_TagPtr DCMTree::Tree::getTag ( const TagId tagid,
const std::string &  privateCreator,
Vr  privateVr = UN,
TagSelector  sel = AllTags 
) const

Returns read access to the private tag with the given TagId.

Parameters
privateCreatorShall match the respective private creator exactly if the tag is a private tag.
privateVrShall be used as VR for the private tag if set and the VR of the private tag is not known. returns An empty pointer if not found.

◆ getTag() [3/3]

Const_TagPtr DCMTree::Tree::getTag ( const TagId tagid,
TagSelector  sel = AllTags 
) const

Returns read access to the tag with the given TagId.

Returns an empty pointer if not found.

Referenced by DCMTree::value_or().

◆ getTag_rw()

TagPtr DCMTree::Tree::getTag_rw ( const TagId tagid)

Returns read/write access to the tag with the given TagId, search is restricted to owned tags.

Returns An empty pointer if not found.

◆ getTags() [1/2]

Const_TagPtrMapPtr DCMTree::Tree::getTags ( const TagId fromtag,
const TagId totag,
TagSelector  sel = AllTags 
) const

Accesses tags map of this tree, ranging from fromtag to totag.

This method is const and returns a map with const pointers to the tag objects.

◆ getTags() [2/2]

Const_TagPtrMapPtr DCMTree::Tree::getTags ( TagSelector  sel = AllTags) const

Accesses tags map of this tree.

This method is const and returns a map with const pointers to the tag objects.

◆ hasDict()

bool DCMTree::Tree::hasDict ( ) const

Checks whether this has a pointer to a dictionary.

◆ hasParent()

bool DCMTree::Tree::hasParent ( ) const

Checks whether this has a parent.

◆ hasTag() [1/2]

bool DCMTree::Tree::hasTag ( const std::string &  tagName,
TagSelector  sel = AllTags 
) const

Checks whether this has the given tag.

It searches only on the top-level and not in sequences!

◆ hasTag() [2/2]

bool DCMTree::Tree::hasTag ( const TagId tagid,
TagSelector  sel = AllTags 
) const

Checks whether this has the given tag.

It searches only on the top-level and not in sequences!

◆ mergedCopy()

TreePtr DCMTree::Tree::mergedCopy ( TagSelector  sel) const

Makes a copy of this, creating a parentless tree.

◆ operator=() [1/2]

Tree& DCMTree::Tree::operator= ( const Tree other)

Assignment operator.

Copies all values from other to this. Handles self-assignment well.

◆ operator=() [2/2]

Tree& DCMTree::Tree::operator= ( Tree &&  other)
defaultnoexcept

◆ parent()

Const_TreePtr DCMTree::Tree::parent ( ) const

Returns the parent as an immutable object.

◆ removePrivateTags()

void DCMTree::Tree::removePrivateTags ( unsigned short  groupId,
unsigned short  slot 
)

Removes all tags associated with a private slot in the specified group (0x10 <= slot <= 0xff).

◆ removeTag()

void DCMTree::Tree::removeTag ( const TagId tagid)

Drops a tag with the given tagid.

◆ removeTags()

void DCMTree::Tree::removeTags ( TagIdVectorPtr  tags)

Drops all given tags.

◆ root()

Const_TreePtr DCMTree::Tree::root ( ) const

Returns the immutable root object of this.

◆ serializeX()

void DCMTree::Tree::serializeX ( DCMTree_Serialization::Sink sink) const
overridevirtual

Writes data of this object to sink.

Implementations of Serializable::serializeX should strictly follow this pattern:

class C: public SCR::Serializable { T1 _m1; T2 _m2; T3 _m3; public: void serializeX(SCR::Sink &sink) const { SCR::serializeX(sink, _m1); SCR::serializeX(sink, _m2); SCR::serializeX(sink, _m3); } };

That is, you should call some overloading of SCR::serializeX for every member.

If some of the types T1, T2, T3 are not serializable, you should make them serializable.

See also
SCR

Implements DCMTree_Serialization::Serializable.

◆ setDict()

void DCMTree::Tree::setDict ( Const_DictPtr  dictPtr)

Sets the pointer to the dictionary.

All contained sequence items receive this dictionary, too.

◆ setTag() [1/2]

void DCMTree::Tree::setTag ( const TagId tagid,
Const_TagPtr  tagdata 
)

Sets the tag with the given TagId.

Overwrites or discards a previously existing tag. The given tag is deep-copied.

◆ setTag() [2/2]

void DCMTree::Tree::setTag ( Const_TagPtr  tagdata)

Convenience function for the above.

It uses the tag ID contained in the tagdata.

◆ setTags()

void DCMTree::Tree::setTags ( Const_TreePtr  tags)

Sets or overwrites all tags in this from the given data.

Source tags are copied and parent tags are ignored.

◆ tagIds() [1/2]

TagIdVectorPtr DCMTree::Tree::tagIds ( const TagId fromtag,
const TagId totag,
TagSelector  sel = AllTags 
) const

Returns all tagIds of this tree ranging from fromtag to totag in ascending order.

◆ tagIds() [2/2]

TagIdVectorPtr DCMTree::Tree::tagIds ( TagSelector  sel = AllTags) const

Returns all tagIds of this tree in ascending order.

◆ tags()

const TagPtrMap& DCMTree::Tree::tags ( )

Accesses tags map of this tree, parent tags are ignored.

Non-const, the map allows write access to the individual tags.

◆ tagsSize()

boost::uint32_t DCMTree::Tree::tagsSize ( ) const

Returns the size of tags map.

◆ toStream()

void DCMTree::Tree::toStream ( std::ostream &  out,
bool  writeName = false 
) const

Copies this instance recursively into the given stream.

writeName = true writes tag name(s) to stream, false writes no name(s) into stream. IMPORTANT: This method is used for file format persistence; thus stream contents must be maintained compatible.

Referenced by DCMTree::operator<<().


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