IsisDlm  Version 0.2
KeywordHandler.h
Go to the documentation of this file.
1 
2 //_Title KeywordHandler.h Definition of basic ISIS support structure
3 //
4 //_Descr ISIS3 file/functionality definition.
5 //
6 //_Hist Jul 24 2004 Kris Becker, USGS
7 //_Version: $Id: KeywordHandler.h,v 1.4 2007/04/26 16:38:58 kbecker Exp $
8 //_End
10 
11 #if !defined(KeywordHandler_h)
12 #define KeywordHandler_h
13 #include <string>
14 #include <vector>
15 
16 #include <QString>
17 #include <QList>
18 #include <QStringList>
19 #include <QVariant>
20 #include <QMetaType>
21 
22 #include "Cube.h"
23 #include "Pvl.h"
24 #include "PvlKeyword.h"
25 #include "IException.h"
26 #include "IString.h"
27 
28 namespace ISISDLM {
38 class PvlSpecs {
39  public:
40  typedef enum { Object, Group, Container, Keyword, None } PvlType;
41  PvlSpecs();
42  PvlSpecs(const QString &spec, const PvlType &ptype);
43  ~PvlSpecs() { }
44 
45  QString name() const;
46  PvlType type() const;
47 
48  void setType(const PvlType &ptype);
49  bool hasQualifiers(Isis::PvlContainer &element) const;
50 
51  private:
52  QString m_spec;
53  QString m_name;
55  QList<Isis::PvlKeyword> m_qualifiers;
56 
57  void init(const QString &spec);
58 };
59 
60 
67  public:
69  KeywordHandler( );
70  KeywordHandler(const QString &path, const PvlType &type = PvlSpecs::Keyword,
71  const bool &recurse = false);
72  KeywordHandler(const std::string &path, const PvlType &type = PvlSpecs::Keyword,
73  const bool &recurse = false);
75 
76  void setRecursive();
77  void setNoRecursive();
78 
79  Isis::PvlKeyword read(Isis::Pvl &pvl) const;
80  static Isis::PvlKeyword read(const QString &path, Isis::Pvl &pvl);
81 
82 #if defined(FULL_IMPLEMENTATION)
83  bool exists(const Pvl &pvl) const;
84  bool write(const QStringList &values, Pvl &pvl) const;
85  bool remove(Pvl &pvl) const;
86 
87  static bool exists(const QString &path, const Pvl &pvl,
88  const PvlType &type = Keyword);
89 
90  static bool write(const QString &path, const QStringList &values, Pvl &pvl);
91  static bool remove(const QString &path, Pvl &pvl,
92  const PvlType &ptype = Keyword);
93  static bool create(const QString &path, PvlType &ptype, Pvl &pvl);
94 #endif
95 
96  private:
97  typedef QList<PvlSpecs> PvlElementList;
98  QString m_path;
101 
102  void init(const QString &path, const PvlType &type);
103  QVariant find(Isis::PvlObject &pvl) const;
104  QVariant findElement(const PvlElementList &plist, const QVariant &source) const;
105  Isis::PvlKeyword *getKeyword(Isis::PvlContainer *pvl, const QString &name) const;
106 
107 
108 };
109 
110 } // namespace ISISDLM
111 
112 // Add Pvl elements to QVariant type list
113 Q_DECLARE_METATYPE(Isis::PvlKeyword *);
114 Q_DECLARE_METATYPE(Isis::PvlContainer *);
115 Q_DECLARE_METATYPE(Isis::PvlObject *);
116 #endif