Orfeo Toolbox  4.0
itkMetaDataDictionary.cxx
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 #include "itkMetaDataDictionary.h"
19 
20 namespace itk
21 {
24 {
25  m_Dictionary = new MetaDataDictionaryMapType;
26 }
27 
30 {
31  delete m_Dictionary;
32  m_Dictionary = 0;
33 }
34 
37 {
38  m_Dictionary = new MetaDataDictionaryMapType;
39  *m_Dictionary = *( old.m_Dictionary );
40 }
41 
44 {
45  if(this != &old)
46  {
47  *m_Dictionary = *( old.m_Dictionary );
48  }
49  return *this;
50 }
51 
52 void
54 ::Print(std::ostream & os) const
55 {
56  for ( MetaDataDictionaryMapType::const_iterator it = m_Dictionary->begin();
57  it != m_Dictionary->end();
58  ++it )
59  {
60  os << ( *it ).first << " ";
61  ( *it ).second->Print(os);
62  }
63 }
64 
67 ::operator[](const std::string & key)
68 {
69  return ( *m_Dictionary )[key];
70 }
71 
72 const MetaDataObjectBase *
74 ::operator[](const std::string & key) const
75 {
76  MetaDataObjectBase::Pointer entry = ( *m_Dictionary )[key];
77  const MetaDataObjectBase * constentry = entry.GetPointer();
78 
79  return constentry;
80 }
81 
82 const MetaDataObjectBase *
84 ::Get(const std::string &key) const
85 {
86  if (!this->HasKey(key))
87  {
88  itkGenericExceptionMacro(<< "Key '"<<key<<"' does not exist ");
89  }
90  MetaDataObjectBase::Pointer entry = ( *m_Dictionary )[key];
91  const MetaDataObjectBase * constentry = entry.GetPointer();
92  return constentry;
93 }
94 
95 void
97 ::Set(const std::string & key, MetaDataObjectBase * object)
98 {
99  (*m_Dictionary)[key] = object;
100 }
101 
102 bool
104 ::HasKey(const std::string & key) const
105 {
106  return m_Dictionary->find(key) != m_Dictionary->end();
107 }
108 
109 std::vector< std::string >
111 ::GetKeys() const
112 {
113  typedef std::vector< std::string > VectorType;
114  VectorType ans;
115 
116  for ( MetaDataDictionaryMapType::const_iterator it = m_Dictionary->begin();
117  it != m_Dictionary->end(); ++it )
118  {
119  ans.push_back( ( *it ).first );
120  }
121 
122  return ans;
123 }
124 
128 {
129  return m_Dictionary->begin();
130 }
131 
134 ::Begin() const
135 {
136  return m_Dictionary->begin();
137 }
138 
142 {
143  return m_Dictionary->end();
144 }
145 
148 ::End() const
149 {
150  return m_Dictionary->end();
151 }
152 
155 ::Find(const std::string & key)
156 {
157  return m_Dictionary->find(key);
158 }
159 
162 ::Find(const std::string & key) const
163 {
164  return m_Dictionary->find(key);
165 }
166 
167 void
170 {
171  this->m_Dictionary->clear();
172 }
173 
174 } // namespace

Generated at Sat Mar 8 2014 15:12:51 for Orfeo Toolbox with doxygen 1.8.3.1