ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMetaDataDictionary.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkMetaDataDictionary_h
19 #define itkMetaDataDictionary_h
20 
21 #include "itkMetaDataObjectBase.h"
22 #include <vector>
23 #include <map>
24 #include <string>
25 #include <memory>
26 
27 namespace itk
28 {
50 class ITKCommon_EXPORT MetaDataDictionary
51 {
52 public:
58  virtual void Print(std::ostream & os) const;
59 
60  // Declare the datastructure that will be used to hold the
61  // dictionary.
62  using MetaDataDictionaryMapType = std::map< std::string, MetaDataObjectBase::Pointer >;
63  using Iterator = MetaDataDictionaryMapType::iterator;
64  using ConstIterator = MetaDataDictionaryMapType::const_iterator;
65 
66  // Constructor
68  // Copy Constructor
71  // operator =
72  MetaDataDictionary & operator=(const MetaDataDictionary &);
73  MetaDataDictionary & operator=(MetaDataDictionary &&) = default;
74 
75  // Destructor
76  virtual ~MetaDataDictionary();
77 
81  std::vector< std::string > GetKeys() const;
82 
83  // Implement map's api. On some Micorsoft compilers, stl containers
84  // cannot be exported. This causes problems when building DLL's.
85  // Here we inherit privately from std::map and provide a simple
86  // API. The implementation will be in the DLL.
87  MetaDataObjectBase::Pointer & operator[](const std::string &);
88 
89  // \brief Get a constant point to a DataObject
90  //
91  // If the key does not exist then nullptr is returned.
92  const MetaDataObjectBase * operator[](const std::string &) const;
93 
94  const MetaDataObjectBase * Get(const std::string &) const;
95  void Set(const std::string &, MetaDataObjectBase * );
96  bool HasKey(const std::string &) const;
97 
98  bool Erase(const std::string&);
99 
105  // Blacklisted by igenerator.py
106  Iterator Begin();
107  // Blacklisted by igenerator.py
108  ConstIterator Begin() const;
110 
112  // Blacklisted by igenerator.py
113  Iterator End();
114  // Blacklisted by igenerator.py
115  ConstIterator End() const;
117 
119  Iterator Find(const std::string & key);
120 
121  ConstIterator Find(const std::string & key) const;
122 
124  void Clear();
125 
126  void Swap( MetaDataDictionary &other );
127 
128 private:
129  bool MakeUnique(void);
130 
131  std::shared_ptr<MetaDataDictionaryMapType> m_Dictionary;
132 };
133 
135 {
136  a.Swap(b);
137 }
138 
139 }
140 #endif // itkMetaDataDictionary_h
MetaDataDictionaryMapType::iterator Iterator
void Swap(MetaDataDictionary &other)
std::shared_ptr< MetaDataDictionaryMapType > m_Dictionary
std::map< std::string, MetaDataObjectBase::Pointer > MetaDataDictionaryMapType
void swap(Array< T > &a, Array< T > &b)
Definition: itkArray.h:211
Provides a mechanism for storing a collection of arbitrary data types.
MetaDataDictionaryMapType::const_iterator ConstIterator
The common interface for MetaDataObject&#39;s.