13 #ifndef DCM_TREE_TREE_H
14 #define DCM_TREE_TREE_H
24 #pragma warning (push)
25 #pragma warning (disable : 4365 4548 4623)
247 bool newOrExisting =
false)
const;
256 unsigned short getPrivateSlot (
unsigned short groupid,
const std::string &creator);
273 void fromStream (std::istream &in,
bool readName=
false,
size_t maxSize = 0);
280 void toStream (std::ostream &out,
bool writeName=
false)
const;
291 void addTagsToSet (std::set<RawTagId> &tagIdSet,
TagSelector sel,
const TagId &fromtag,
const TagId &totag)
const;
316 bool isDeleted (
const TagId &tagid)
const;
319 void markAsDeleted (
const TagId &tagid);
322 void undelete (
const TagId &tagid);
331 std::set<RawTagId> _deletedtags;
360 template <
typename T, T (Tag::*Access)(
unsigned) const>
364 if (
const auto tag = tree.
getTag(
id); tag && index < tag->numberOfValues() && !tag->isNull(index))
366 result = ((*tag).*Access)(index);
370 result = std::move(alternative);
387 template <
typename T>
390 return value_or(tree,
id, 0, std::move(alternative));
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.
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.
TreePtr mergedCopy(TagSelector sel) const
Makes a copy of this, creating a parentless tree.
Const_TagPtr getTag(const std::string &tagName, TagSelector sel=AllTags) const
Returns read access to the tag with the given tagName.
bool hasParent() const
Checks whether this has a parent.
void fromStream(std::istream &in, bool readName=false, size_t maxSize=0)
Extracts this instance from the given stream.
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...
void removePrivateTags(unsigned short groupId, unsigned short slot)
Removes all tags associated with a private slot in the specified group (0x10 <= slot <= 0xff).
const TagPtrMap & constTags_rw() const
Accesses tags map of this tree even if it is a const one to avoid expensive copy operations.
Const_TagPtr getTag(const TagId &tagid, TagSelector sel=AllTags) const
Returns read access to the tag with the given TagId.
boost::uint32_t tagsSize() const
Returns the size of tags map.
std::string getPrivateCreator(TagId tagId) const
Returns the private creator string for the given tag ID.
void removeTag(const TagId &tagid)
Drops a tag with the given tagid.
void toStream(std::ostream &out, bool writeName=false) const
Copies this instance recursively into the given stream.
Const_DictPtr getDict() const
Returns a pointer to the dictionary, which can be NULL.
TreePtr copy(const TagId &fromtag, const TagId &totag) const
Makes a deep copy of this, including only tags between and including fromtag and totag.
Const_TagPtrMapPtr getTags(const TagId &fromtag, const TagId &totag, TagSelector sel=AllTags) const
Accesses tags map of this tree, ranging from fromtag to totag.
void addTag(TagPtr tagdata)
Convenience function for the above.
Tree & operator=(Tree &&other) noexcept=default
Const_TreePtr parent() const
Returns the parent as an immutable object.
void removeTags(TagIdVectorPtr tags)
Drops all given tags.
Tree(Const_TreePtr parent)
Initializes an empty tree representing an incremental modification to the specified parent tree.
const TagPtrMap & tags()
Accesses tags map of this tree, parent tags are ignored.
~Tree() override=default
Destructor.
Tree(const Tree &other)
Copies all values from other to this.
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.
TagPtr getTag_rw(const TagId &tagid)
Returns read/write access to the tag with the given TagId, search is restricted to owned tags.
void addTags(TreePtr tags)
void addTag(const TagId &tagid, TagPtr tagdata)
Adds a tag to this; tagdata is not copied.
TreePtr copy() const
Makes a deep copy of this, including a reference to the parent.
void serializeX(DCMTree_Serialization::Sink &sink) const override
Writes data of this object to sink.
bool hasTag(const TagId &tagid, TagSelector sel=AllTags) const
Checks whether this has the given tag.
void setTags(Const_TreePtr tags)
Sets or overwrites all tags in this from the given data.
Tree(Tree &&other) noexcept=default
TagIdVectorPtr tagIds(TagSelector sel=AllTags) const
Returns all tagIds of this tree in ascending order.
Const_TagPtrMapPtr getTags(TagSelector sel=AllTags) const
Accesses tags map of this tree.
bool hasTag(const std::string &tagName, TagSelector sel=AllTags) const
Checks whether this has the given tag.
Const_TreePtr root() const
Returns the immutable root object of this.
bool hasDict() const
Checks whether this has a pointer to a dictionary.
void deserializeX(DCMTree_Serialization::Source &source) override
Overwrites data of this object with data from source.
void setDict(Const_DictPtr dictPtr)
Sets the pointer to the dictionary.
void setTag(const TagId &tagid, Const_TagPtr tagdata)
Sets the tag with the given TagId.
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.
Tree & operator=(const Tree &other)
Assignment operator.
TreePtr copy(TagIdVectorPtr tags) const
Makes a deep copy of this including, only tags whose IDs are within the given vector.
void setTag(Const_TagPtr tagdata)
Convenience function for the above.
Interface that provides a method to deserialize an object.
Interface that provides a method to serialize an object.
Interface of a data sink for the serialization of objects.
Interface of a data source for the deserialization of objects.
DCMTREE_EXPORT bool convertCharacterSet(const std::string &originalcharacterset, const std::string &newcharacterset, std::string &val)
Converts val from the original character set to the new character set.
Class to dump a DCMTree DICOM message into a human-readable file.
boost::shared_ptr< const Tag > Const_TagPtr
std::istream & operator>>(std::istream &in, Message &m)
TagSelector
Constants selecting a tag subset in a chain of incrementally modified DICOM trees.
@ AllTags
Select all tags from all trees in the chain that are not deleted in a successor.
boost::shared_ptr< const CharacterSetConverter > Const_CharacterSetConverterPtr
std::map< TagId, TagPtr > TagPtrMap
A map from tag ID to TagPtr.
boost::shared_ptr< const Tree > Const_TreePtr
std::map< TagId, Const_TagPtr > Const_TagPtrMap
boost::shared_ptr< Const_TagPtrMap > Const_TagPtrMapPtr
boost::shared_ptr< Tag > TagPtr
Shared pointer to tag.
T value_or(const Tree &tree, TagId id, unsigned index, T alternative)
boost::shared_ptr< const Dict > Const_DictPtr
boost::shared_ptr< Tree > TreePtr
Shared pointer to a DCMTree::Tree.
boost::shared_ptr< TagIdVector > TagIdVectorPtr
A shared pointer to a vector of TagIds.
std::ostream & operator<<(std::ostream &out, const Message &m)
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.