Isis 3 Programmer Reference
DbProfile.h
Go to the documentation of this file.
1 #ifndef DbProfile_h
2 #define DbProfile_h
3 
26 #include <string>
27 #include <vector>
28 #include <iostream>
29 
30 #include "PvlKeyword.h"
31 #include "PvlContainer.h"
32 #include "CollectorMap.h"
33 #include "IException.h"
34 
35 namespace Isis {
36 
65  class DbProfile {
66 
67  protected:
68  /* Container for multi-valued keywords in profiles */
70 
71  public:
72  // Constructors and Destructor
73  DbProfile() : _name("Profile"), _keys() { }
74  DbProfile(const QString &name) : _name(name), _keys() { }
75  DbProfile(const DbProfile &prof1, const DbProfile &prof2,
76  const QString &name = "");
77  DbProfile(PvlContainer &pvl);
78 
79 
81  virtual ~DbProfile() { }
82 
91  bool isValid() const {
92  return (size() > 0);
93  }
94 
100  int size() const {
101  return (_keys.size());
102  }
103 
109  void setName(const QString &name) {
110  _name = name;
111  }
112 
118  QString Name() const {
119  return (_name);
120  }
121 
129  bool exists(const QString &key) const {
130  return (_keys.exists(key));
131  }
132 
133  // Convenience methods for adding keys
134  void add(const QString &key, const QString &value = "");
135  void replace(const QString &key, const QString &value = "");
136  void remove(const QString &key);
137  int count(const QString &key) const;
138 
155  QString key(int nth) const {
156  return (_keys.key(nth).ToQt());
157  }
158  QString value(const QString &key, int nth = 0) const;
159  QString operator()(const QString &key, int nth = 0) const;
160 
161  protected:
162  void loadkeys(PvlContainer &pvl);
163 
173  const KeyList &getKeyList() const {
174  return (_keys);
175  }
176 
177  private:
178  QString _name;
180  };
181 }
182 
183 
184 #endif
185 
186 
QString operator()(const QString &key, int nth=0) const
Returns the specified value for the given keyword.
Definition: DbProfile.cpp:186
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
int size() const
Reports the number of keywords in this user profile.
Definition: DbProfile.h:100
Contains more than one keyword-value pair.
Definition: PvlContainer.h:63
int count(const QString &key) const
Report number of values in keyword.
Definition: DbProfile.cpp:141
bool exists(const QString &key) const
Checks for the existance of a keyword.
Definition: DbProfile.h:129
int size() const
Returns the size of the collection.
Definition: CollectorMap.h:528
QString _name
Name of this profile.
Definition: DbProfile.h:178
A DbProfile is a container for access parameters to a database.
Definition: DbProfile.h:65
void replace(const QString &key, const QString &value="")
Adds a keyword and value pair to the profile.
Definition: DbProfile.cpp:117
const K & key(int nth) const
Returns the nth key in the collection.
Definition: CollectorMap.h:689
KeyList _keys
List of keys in profile.
Definition: DbProfile.h:179
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition: CollectorMap.h:567
void add(const QString &key, const QString &value="")
Adds a keyword and value pair to the profile.
Definition: DbProfile.cpp:96
QString value(const QString &key, int nth=0) const
Returns the specified value for the given keyword.
Definition: DbProfile.cpp:160
QString ToQt() const
Retuns the object string as a QString.
Definition: IString.cpp:884
void setName(const QString &name)
Set the name of this profile.
Definition: DbProfile.h:109
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool isValid() const
Reports if this is a valid profile.
Definition: DbProfile.h:91
virtual ~DbProfile()
Destructor ensures everything is cleaned up properly.
Definition: DbProfile.h:81
QString Name() const
Returns the name of this property.
Definition: DbProfile.h:118
void loadkeys(PvlContainer &pvl)
Loads DbProfile keys from the given Pvl construct.
Definition: DbProfile.cpp:198
const KeyList & getKeyList() const
Returns a reference to the key list.
Definition: DbProfile.h:173
QString key(int nth) const
Returns the nth key in the profile.
Definition: DbProfile.h:155