Isis Developer Reference
DbProfile.h
Go to the documentation of this file.
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;
165  KeyList _keys;
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::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::CollectorMap::getNth
T & getNth(int nth)
Returns the nth value in the collection.
Definition: CollectorMap.h:624
Isis::PvlKeyword::addValue
void addValue(QString value, QString unit="")
Adds a value with units.
Definition: PvlKeyword.cpp:252
PvlGroup.h
Isis::DbProfile::count
int count(const QString &key) const
Report number of values in keyword.
Definition: DbProfile.cpp:127
Isis::CollectorMap::get
T & get(const K &key)
Returns the value associated with the name provided.
Definition: CollectorMap.h:567
Isis::DbProfile::DbProfile
DbProfile(const QString &name)
Definition: DbProfile.h:60
Isis::CollectorMap::size
int size() const
Returns the size of the collection.
Definition: CollectorMap.h:512
Isis::CollectorMap::remove
int remove(const K &key)
Removes and entry from the list.
Definition: CollectorMap.h:694
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::DbProfile::KeyList
CollectorMap< IString, PvlKeyword, NoCaseStringCompare > KeyList
Definition: DbProfile.h:55
Isis::CollectorMap::exists
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition: CollectorMap.h:551
Isis::CollectorMap::key
const K & key(int nth) const
Returns the nth key in the collection.
Definition: CollectorMap.h:673
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::DbProfile::DbProfile
DbProfile()
Definition: DbProfile.h:59
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::IException
Isis exception class.
Definition: IException.h:91
Isis::CollectorMap::add
void add(const K &key, const T &value)
Adds the element to the list.
Definition: CollectorMap.h:540
PvlContainer.h
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
CollectorMap.h
Isis::CollectorMap
Collector/container for arbitrary items.
Definition: CollectorMap.h:419
PvlKeyword.h
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
Isis::PvlContainer::PvlKeywordIterator
QList< PvlKeyword >::iterator PvlKeywordIterator
The keyword iterator.
Definition: PvlContainer.h:157
DbProfile.h
Isis::DbProfile::remove
void remove(const QString &key)
Removes a keyword from the profile.
Definition: DbProfile.cpp:113
Isis::PvlContainer::end
PvlKeywordIterator end()
Return the ending iterator.
Definition: PvlContainer.h:194
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::PvlContainer::begin
PvlKeywordIterator begin()
Return the beginning iterator.
Definition: PvlContainer.h:178
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