MeVisLabToolboxReference
MeVis/Foundation/Sources/DicomTree/MLDicomTree/DCMTree_Tree.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // **InsertLicense** code
00003 //-----------------------------------------------------------------------------
00005 
00010 //-----------------------------------------------------------------------------
00011 
00012 #ifndef CLASS_DCMTREE_TREE
00013 #define CLASS_DCMTREE_TREE
00014 
00015 #include "DCMTree_Lib.h"
00016 #include "DCMTree_TagId.h"
00017 #include "DCMTree_Defines.h"
00018 
00019 #include <iostream>
00020 #include <fstream>
00021 
00022 #include <set>
00023 
00024 #ifdef _MSC_VER
00025   #pragma warning (push)
00026   #pragma warning (disable : 4251)
00027 #endif
00028 
00045 namespace DCMTree
00046 {
00047     class DCMTREE_EXPORT Tree:public DCMTree_Serialization::Serializable,public DCMTree_Serialization::Deserializable
00048     {
00049     public:
00051         Tree();
00052 
00057         Tree (const Tree &other);
00058 
00065         Tree (Const_TreePtr parent);
00066 
00068         virtual ~Tree();
00069 
00071         Const_TreePtr parent() const;
00072 
00074         Const_TreePtr root () const;
00075 
00077         bool hasParent() const;
00078 
00080         bool hasDict() const;
00081 
00083         Const_DictPtr getDict () const;
00084 
00087         void setDict (Const_DictPtr dictPtr);
00088 
00094         Tree &operator= (const Tree &other);
00095 
00100         const TagPtrMap &tags();
00101 
00105         boost::uint32_t tagsSize() const;
00106 
00110         TagIdVectorPtr tagIds (TagSelector sel=AllTags) const;
00111 
00115         TagIdVectorPtr tagIds (const TagId &fromtag, const TagId &totag, TagSelector sel=AllTags) const;
00116 
00121         bool hasTag (const TagId &tagid, TagSelector sel=AllTags) const;
00122 
00127         bool hasTag (const std::string& tagName, TagSelector sel=AllTags) const;
00128 
00133         Const_TagPtr getTag (const TagId &tagid, TagSelector sel=AllTags) const;
00134 
00141         Const_TagPtr getTag (const TagId &tagid, const std::string& privateCreator, Vr privateVr=UN, TagSelector sel=AllTags) const;
00142 
00147         Const_TagPtr getTag (const std::string& tagName, TagSelector sel=AllTags) const;
00148         
00153         TagPtr getTag_rw (const TagId &tagid);
00154 
00159         Const_TagPtrMapPtr getTags (TagSelector sel=AllTags) const;
00160 
00165         Const_TagPtrMapPtr getTags (const TagId &fromtag, const TagId &totag, TagSelector sel=AllTags) const;
00166         
00172         void setTag (const TagId &tagid, Const_TagPtr tagdata);
00177         void setTag (Const_TagPtr tagdata);
00178 
00183         void setTags (Const_TreePtr tags);
00184 
00186         void addTag (const TagId &tagid, TagPtr tagdata);
00191         void addTag (TagPtr tagdata);
00192 
00193         /* add the given tags to this, NO copy, parent tags are ignored **/
00194         void addTags (TreePtr tags);
00195 
00199         void removeTag (const TagId &tagid);
00200 
00204         void removeTags (TagIdVectorPtr tags);
00205         
00209         TreePtr copy() const;
00210 
00214         TreePtr copy (const TagId &fromtag, const TagId &totag) const;
00215 
00219         TreePtr copy (TagIdVectorPtr tags) const;
00220 
00224         TreePtr mergedCopy (TagSelector sel) const;
00225 
00226 
00232         std::string getPrivateCreator (TagId tagId) const;
00233 
00240         unsigned short findPrivateSlot (unsigned short groupid, const std::string &creator, 
00241                                         bool newOrExisting = false) const;
00242 
00250         unsigned short getPrivateSlot (unsigned short groupid, const std::string &creator);
00251 
00255         void removePrivateTags (unsigned short groupId, unsigned short slot);
00256 
00260         void convertCharacterSet (const std::string &originalcharacterset,const std::string &newcharacterset);
00261 
00267         void fromStream (std::istream &in, bool readName=false);
00268 
00274         void toStream (std::ostream &out, bool writeName=false) const;
00275 
00276         virtual void serializeX (DCMTree_Serialization::Sink &sink) const;
00277         virtual void deserializeX (DCMTree_Serialization::Source &source);
00278 
00279 
00280     private:
00281 
00285         void addTagsToSet (std::set<RawTagId> &tagIdSet, TagSelector sel, const TagId &fromtag, const TagId &totag) const;
00286 
00290         void addTagsToMap (Const_TagPtrMap &tagMap, TagSelector sel, const TagId &fromtag, const TagId &totag) const;
00291 
00293         Const_TagPtr const_tag4tagid (const TagId &tagid,const TagSelector sel) const;
00294 
00296         TagPtr tag4tagid (const TagId &tagid);
00297 
00302         void checkForTag (const TagId &tagid,const TagSelector sel) const;
00303 
00305         bool isDeleted (const TagId &tagid) const;
00306 
00308         void markAsDeleted (const TagId &tagid);
00309 
00311         void undelete (const TagId &tagid);
00312 
00313 
00315         TagPtrMap _tags;
00316 
00318         std::set<RawTagId> _deletedtags;
00319 
00325         Const_TreePtr _parent;
00326 
00328         Const_DictPtr _dictionary;
00329     };
00330 
00331 
00333     inline std::ostream &operator << (std::ostream &out,const Tree &t)
00334     {
00335         t.toStream (out, false);
00336         return out;
00337     }
00338 
00339 
00341     inline std::istream &operator >> (std::istream &in,Tree &t)
00342     {
00343         t.fromStream (in, false);
00344         return in;
00345     }
00346 }
00347 
00348 #ifdef _MSC_VER
00349   #pragma warning (pop)
00350 #endif
00351 
00352 #endif
00353 
00354