Isis 3 Programmer Reference
DbProfile.h
1 #ifndef DbProfile_h
2 #define DbProfile_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <string>
13 #include <vector>
14 #include <iostream>
15 
16 #include "PvlKeyword.h"
17 #include "PvlContainer.h"
18 #include "CollectorMap.h"
19 #include "IException.h"
20 
21 namespace Isis {
22 
51  class DbProfile {
52 
53  protected:
54  /* Container for multi-valued keywords in profiles */
56 
57  public:
58  // Constructors and Destructor
59  DbProfile() : _name("Profile"), _keys() { }
60  DbProfile(const QString &name) : _name(name), _keys() { }
61  DbProfile(const DbProfile &prof1, const DbProfile &prof2,
62  const QString &name = "");
63  DbProfile(PvlContainer &pvl);
64 
65 
67  virtual ~DbProfile() { }
68 
77  bool isValid() const {
78  return (size() > 0);
79  }
80 
86  int size() const {
87  return (_keys.size());
88  }
89 
95  void setName(const QString &name) {
96  _name = name;
97  }
98 
104  QString Name() const {
105  return (_name);
106  }
107 
115  bool exists(const QString &key) const {
116  return (_keys.exists(key));
117  }
118 
119  // Convenience methods for adding keys
120  void add(const QString &key, const QString &value = "");
121  void replace(const QString &key, const QString &value = "");
122  void remove(const QString &key);
123  int count(const QString &key) const;
124 
141  QString key(int nth) const {
142  return (_keys.key(nth).ToQt());
143  }
144  QString value(const QString &key, int nth = 0) const;
145  QString operator()(const QString &key, int nth = 0) const;
146 
147  protected:
148  void loadkeys(PvlContainer &pvl);
149 
159  const KeyList &getKeyList() const {
160  return (_keys);
161  }
162 
163  private:
164  QString _name;
166  };
167 }
168 
169 
170 #endif
Isis::DbProfile::size
int size() const
Reports the number of keywords in this user profile.
Definition: DbProfile.h:86
Isis::DbProfile::~DbProfile
virtual ~DbProfile()
Destructor ensures everything is cleaned up properly.
Definition: DbProfile.h:67
Isis::DbProfile::Name
QString Name() const
Returns the name of this property.
Definition: DbProfile.h:104
Isis::DbProfile::operator()
QString operator()(const QString &key, int nth=0) const
Returns the specified value for the given keyword.
Definition: DbProfile.cpp:172
Isis::DbProfile::exists
bool exists(const QString &key) const
Checks for the existance of a keyword.
Definition: DbProfile.h:115
Isis::DbProfile::count
int count(const QString &key) const
Report number of values in keyword.
Definition: DbProfile.cpp:127
Isis::CollectorMap::size
int size() const
Returns the size of the collection.
Definition: CollectorMap.h:512
Isis::DbProfile::_keys
KeyList _keys
List of keys in profile.
Definition: DbProfile.h:165
Isis::DbProfile::replace
void replace(const QString &key, const QString &value="")
Adds a keyword and value pair to the profile.
Definition: DbProfile.cpp:103
Isis::DbProfile::add
void add(const QString &key, const QString &value="")
Adds a keyword and value pair to the profile.
Definition: DbProfile.cpp:82
Isis::CollectorMap::exists
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition: CollectorMap.h:551
Isis::DbProfile::_name
QString _name
Name of this profile.
Definition: DbProfile.h:164
Isis::CollectorMap::key
const K & key(int nth) const
Returns the nth key in the collection.
Definition: CollectorMap.h:673
Isis::DbProfile::isValid
bool isValid() const
Reports if this is a valid profile.
Definition: DbProfile.h:77
Isis::DbProfile::loadkeys
void loadkeys(PvlContainer &pvl)
Loads DbProfile keys from the given Pvl construct.
Definition: DbProfile.cpp:184
Isis::DbProfile
A DbProfile is a container for access parameters to a database.
Definition: DbProfile.h:51
Isis::CollectorMap< IString, PvlKeyword, NoCaseStringCompare >
Isis::DbProfile::remove
void remove(const QString &key)
Removes a keyword from the profile.
Definition: DbProfile.cpp:113
Isis::DbProfile::setName
void setName(const QString &name)
Set the name of this profile.
Definition: DbProfile.h:95
Isis::PvlContainer
Contains more than one keyword-value pair.
Definition: PvlContainer.h:49
Isis::DbProfile::value
QString value(const QString &key, int nth=0) const
Returns the specified value for the given keyword.
Definition: DbProfile.cpp:146
Isis::DbProfile::key
QString key(int nth) const
Returns the nth key in the profile.
Definition: DbProfile.h:141
Isis::DbProfile::getKeyList
const KeyList & getKeyList() const
Returns a reference to the key list.
Definition: DbProfile.h:159
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IString::ToQt
QString ToQt() const
Retuns the object string as a QString.
Definition: IString.cpp:869