USGS

Isis 3.0 Object Programmers' Reference

Home

PvlObject.h
Go to the documentation of this file.
1 #ifndef PvlObject_h
2 #define PvlObject_h
3 
25 #include <algorithm>
26 
27 #include "PvlContainer.h"
28 #include "PvlGroup.h"
29 
30 #include <QMetaType>
31 
32 template<typename T> class QList;
33 
34 namespace Isis {
71  class PvlObject : public Isis::PvlContainer {
72  public:
73  PvlObject();
74  PvlObject(const QString &name);
75  PvlObject(const PvlObject &other);
76 
77  friend std::ostream &operator<<(std::ostream &os, Isis::PvlObject &object);
78  friend std::istream &operator>>(std::istream &is, PvlObject &result);
79 
84  int groups() const {
85  return m_groups.size();
86  };
87 
88  PvlGroup &group(const int index);
89  const PvlGroup &group(const int index) const;
90 
93  typedef QList<Isis::PvlGroup>::const_iterator ConstPvlGroupIterator;
94 
95 
101  return m_groups.begin();
102  };
103 
104 
109  ConstPvlGroupIterator beginGroup() const {
110  return m_groups.begin();
111  };
112 
113 
119  return m_groups.end();
120  };
121 
122 
127  ConstPvlGroupIterator endGroup() const {
128  return m_groups.end();
129  };
130 
131 
138  PvlGroupIterator findGroup(const QString &name,
139  PvlGroupIterator beg,
141  Isis::PvlGroup temp(name);
142  return std::find(beg, end, temp);
143  }
144 
145 
152  ConstPvlGroupIterator findGroup(const QString &name,
153  ConstPvlGroupIterator beg,
154  ConstPvlGroupIterator end) const {
155  Isis::PvlGroup temp(name);
156  return std::find(beg, end, temp);
157  }
158 
159 
163  enum FindOptions {
168  };
169 
170  // The using statements below are used to make the PvlContainer's version
171  // of FindKeyword and HasKeyword vissible to other code that otherwise would not be
172  // able to see those versions.
174 
175 
176  PvlKeyword &findKeyword(const QString &kname,
177  FindOptions opts);
178 
179 
181 
182 
183  bool hasKeyword(const QString &kname,
184  FindOptions opts) const;
185 
186  Isis::PvlGroup &findGroup(const QString &name,
187  FindOptions opts = None);
188 
189  const Isis::PvlGroup &findGroup(const QString &name,
190  FindOptions opts = None) const;
196  m_groups.push_back(group);
197  //m_groups[m_groups.size()-1].SetFileName(FileName());
198  };
199 
200  using PvlContainer::operator+=;
201  void operator+= (const Isis::PvlGroup &group) {
202  addGroup(group);
203  }
204  void operator+= (const Isis::PvlObject &obj) {
205  addObject(obj);
206  }
207 
208  void deleteGroup(const QString &name);
209 
210  void deleteGroup(const int index);
211 
212 
219  bool hasGroup(const QString &name) const {
220  if(findGroup(name, beginGroup(), endGroup()) == endGroup()) return false;
221  return true;
222  }
223 
228  int objects() const {
229  return m_objects.size();
230  };
231 
232  PvlObject &object(const int index);
233  const PvlObject &object(const int index) const;
234 
237  typedef QList<PvlObject>::const_iterator ConstPvlObjectIterator;
238 
239 
245  return m_objects.begin();
246  };
247 
248 
253  ConstPvlObjectIterator beginObject() const {
254  return m_objects.begin();
255  };
256 
257 
263  return m_objects.end();
264  };
265 
266 
271  ConstPvlObjectIterator endObject() const {
272  return m_objects.end();
273  };
274 
275 
283  PvlObjectIterator findObject(const QString &name,
284  PvlObjectIterator beg,
286  PvlObject temp(name);
287  return std::find(beg, end, temp);
288  }
289 
290 
298  ConstPvlObjectIterator findObject(const QString &name,
299  ConstPvlObjectIterator beg,
300  ConstPvlObjectIterator end) const {
301  PvlObject temp(name);
302  return std::find(beg, end, temp);
303  }
304 
305 
306  PvlObject &findObject(const QString &name,
307  FindOptions opts = None);
308 
309  const PvlObject &findObject(const QString &name,
310  FindOptions opts = None) const;
311 
316  void addObject(const PvlObject &object) {
317  m_objects.push_back(object);
318  m_objects[m_objects.size()-1].setFileName(fileName());
319  }
320 
321  void deleteObject(const QString &name);
322  void deleteObject(const int index);
323 
324 
332  bool hasObject(const QString &name) const {
333  if(findObject(name, beginObject(), endObject()) == endObject()) return false;
334  return true;
335  }
336 
337 
344  bool operator==(const PvlObject &object) const {
345  return PvlKeyword::stringEqual(object.name(), this->name());
346  }
347 
348 
350  void clear() {
352  m_objects.clear();
353  m_groups.clear();
354  }
355 
356  const PvlObject &operator=(const PvlObject &other);
357 
359  void validateObject(PvlObject & pPvlObj);
360 
361  private:
366  };
367 }
368 
370 
371 #endif