ITK  5.2.0
Insight Toolkit
itkMetaDataDictionary.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 {
53 class ITKCommon_EXPORT MetaDataDictionary
54 {
55 public:
61  virtual void
62  Print(std::ostream & os) const;
63 
64  // Declare the datastructure that will be used to hold the
65  // dictionary.
66  using MetaDataDictionaryMapType = std::map<std::string, MetaDataObjectBase::Pointer>;
67  using Iterator = MetaDataDictionaryMapType::iterator;
68  using ConstIterator = MetaDataDictionaryMapType::const_iterator;
69 
70  // Constructor
72  // Copy Constructor
75  // operator =
77  operator=(const MetaDataDictionary &);
79  operator=(MetaDataDictionary &&) = default;
80 
81  // Destructor
82  virtual ~MetaDataDictionary();
83 
87  std::vector<std::string>
88  GetKeys() const;
89 
90  // Implement map's api. On some Micorsoft compilers, stl containers
91  // cannot be exported. This causes problems when building DLL's.
92  // Here we inherit privately from std::map and provide a simple
93  // API. The implementation will be in the DLL.
94  MetaDataObjectBase::Pointer & operator[](const std::string &);
95 
96  // \brief Get a constant point to a DataObject
97  //
98  // If the key does not exist then nullptr is returned.
99  const MetaDataObjectBase * operator[](const std::string &) const;
100 
101  const MetaDataObjectBase *
102  Get(const std::string &) const;
103  void
104  Set(const std::string &, MetaDataObjectBase *);
105  bool
106  HasKey(const std::string &) const;
107 
108  bool
109  Erase(const std::string &);
110 
116  // Blacklisted by igenerator.py
117  Iterator
118  Begin();
119  // Blacklisted by igenerator.py
121  Begin() const;
123 
125  // Blacklisted by igenerator.py
126  Iterator
127  End();
128  // Blacklisted by igenerator.py
130  End() const;
132 
134  Iterator
135  Find(const std::string & key);
136 
138  Find(const std::string & key) const;
139 
141  void
142  Clear();
143 
144  void
145  Swap(MetaDataDictionary & other);
146 
147 private:
148  bool
149  MakeUnique();
150 
151  std::shared_ptr<MetaDataDictionaryMapType> m_Dictionary;
152 };
153 
154 inline void
156 {
157  a.Swap(b);
158 }
159 
160 } // namespace itk
161 #endif // itkMetaDataDictionary_h
itk::MetaDataDictionary::m_Dictionary
std::shared_ptr< MetaDataDictionaryMapType > m_Dictionary
Definition: itkMetaDataDictionary.h:151
itk::MetaDataObjectBase
The common interface for MetaDataObject's.
Definition: itkMetaDataObjectBase.h:47
itkMetaDataObjectBase.h
itk::swap
void swap(Array< T > &a, Array< T > &b)
Definition: itkArray.h:244
itk::SmartPointer< Self >
itk::MetaDataDictionary::ConstIterator
MetaDataDictionaryMapType::const_iterator ConstIterator
Definition: itkMetaDataDictionary.h:68
itk::MetaDataDictionary
Provides a mechanism for storing a collection of arbitrary data types.
Definition: itkMetaDataDictionary.h:53
itk::MetaDataDictionary::Swap
void Swap(MetaDataDictionary &other)
itk::MetaDataDictionary::MetaDataDictionaryMapType
std::map< std::string, MetaDataObjectBase::Pointer > MetaDataDictionaryMapType
Definition: itkMetaDataDictionary.h:66
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MetaDataDictionary::Iterator
MetaDataDictionaryMapType::iterator Iterator
Definition: itkMetaDataDictionary.h:67