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
21namespace Isis {
22
51 class DbProfile {
52
53 protected:
54 /* Container for multi-valued keywords in profiles */
55 typedef CollectorMap<IString, PvlKeyword, NoCaseStringCompare> KeyList;
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 = "");
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
const K & key(int nth) const
Returns the nth key in the collection.
Definition CollectorMap.h:673
int size() const
Returns the size of the collection.
Definition CollectorMap.h:512
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition CollectorMap.h:551
A DbProfile is a container for access parameters to a database.
Definition DbProfile.h:51
virtual ~DbProfile()
Destructor ensures everything is cleaned up properly.
Definition DbProfile.h:67
void add(const QString &key, const QString &value="")
Adds a keyword and value pair to the profile.
Definition DbProfile.cpp:82
DbProfile()
Definition DbProfile.h:59
const KeyList & getKeyList() const
Returns a reference to the key list.
Definition DbProfile.h:159
CollectorMap< IString, PvlKeyword, NoCaseStringCompare > KeyList
Definition DbProfile.h:55
int size() const
Reports the number of keywords in this user profile.
Definition DbProfile.h:86
void setName(const QString &name)
Set the name of this profile.
Definition DbProfile.h:95
QString value(const QString &key, int nth=0) const
Returns the specified value for the given keyword.
Definition DbProfile.cpp:146
bool isValid() const
Reports if this is a valid profile.
Definition DbProfile.h:77
QString operator()(const QString &key, int nth=0) const
Returns the specified value for the given keyword.
Definition DbProfile.cpp:172
DbProfile(const QString &name)
Definition DbProfile.h:60
void remove(const QString &key)
Removes a keyword from the profile.
Definition DbProfile.cpp:113
bool exists(const QString &key) const
Checks for the existance of a keyword.
Definition DbProfile.h:115
QString Name() const
Returns the name of this property.
Definition DbProfile.h:104
void loadkeys(PvlContainer &pvl)
Loads DbProfile keys from the given Pvl construct.
Definition DbProfile.cpp:184
QString key(int nth) const
Returns the nth key in the profile.
Definition DbProfile.h:141
void replace(const QString &key, const QString &value="")
Adds a keyword and value pair to the profile.
Definition DbProfile.cpp:103
int count(const QString &key) const
Report number of values in keyword.
Definition DbProfile.cpp:127
Contains more than one keyword-value pair.
Definition PvlContainer.h:49
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16