Isis 3 Programmer Reference
Resource.h
Go to the documentation of this file.
1 #ifndef Resource_h
2 #define Resource_h
3 
27 // Qt library
28 #include <QExplicitlySharedDataPointer>
29 #include <QMap>
30 #include <QMetaType>
31 #include <QSharedData>
32 #include <QString>
33 #include <QVariant>
34 
35 #include "GisGeometry.h" // SharedGisGeometry type
36 #include "PvlFlatMap.h"
37 
38 namespace Isis {
39 
40  class PvlContainer;
41  class PvlKeyword;
42  class PvlObject;
43 
71  class Resource {
72 
73  public:
74  Resource();
75  Resource(const QString &name);
76  Resource(const QString &name, const PvlFlatMap &profile);
77  Resource(const QString &name, const PvlContainer &profile);
78  Resource(const Resource &other);
79  virtual ~Resource();
80 
81  QString name() const;
82  void setName(const QString &identity);
83  bool isEqual(const Resource &other) const;
84 
85  bool exists(const QString &keywordName) const;
86  int count(const QString &keywordName) const;
87  bool isNull(const QString &keywordName, const int keywordIndex = 0) const;
88 
89  const PvlFlatMap &keys() const;
90  QString value(const QString &keywordName, const int &keywordIndex = 0) const;
91  QString value(const QString &keywordName, const QString &defValue,
92  const int &keywordIndex = 0) const;
93  PvlKeyword keyword(const QString &keywordName) const;
94 
95  void add(const QString &keywordName, const QString &keywordValue);
96  void add(const PvlKeyword &keyword);
97  void add(const PvlFlatMap &keys);
98  void append(const QString &keywordName, const QString &keywordValue);
99 
100  int erase(const QString &keywordName);
101 
102  void add(GisGeometry *geom);
103  void add(SharedGisGeometry &geom);
104 
105  bool hasGeometry() const;
106  bool hasValidGeometry() const;
107  SharedGisGeometry geometry() const;
108 
109  void activate();
110  bool isActive() const;
111  void discard();
112  bool isDiscarded() const;
113 
114  bool hasAsset(const QString &assetName) const;
115  void addAsset(const QString &assetName, QVariant &assetValue);
116  QVariant asset(const QString &assetName) const;
117  int removeAsset(const QString &assetName);
118  int clearAssets();
119 
120  virtual Resource *copy() const;
121  virtual Resource *clone(const QString &name,
122  const bool &withAssets=false) const;
123 
124  virtual PvlObject toPvl(const QString &pvlName = "Resource") const;
125 
126  protected:
127  Resource(const Resource &other, const bool deepcopy);
128 
129  private:
132 
140  class ResourceData : public QSharedData {
141  public:
142  ResourceData() : m_name("Resource"), m_keys(),
143  m_assets(), m_geom(0) { }
144  ResourceData(const ResourceData &other) : QSharedData(other),
145  m_name(other.m_name),
146  m_keys(other.m_keys),
147  m_assets(other.m_assets),
148  m_geom(other.m_geom) { }
149  ResourceData(const QString &name) : QSharedData(),
150  m_name(name),
151  m_keys(),
152  m_assets(),
153  m_geom(0) { }
154  ResourceData(const QString &name, const PvlFlatMap &profile) :
155  QSharedData(),
156  m_name(name),
157  m_keys(profile),
158  m_assets(),
159  m_geom(0) { }
160 
161  QString m_name;
172  };
173 
174  // Member variables
176  QExplicitlySharedDataPointer<ResourceData> m_data;
177  bool m_discard;
180  };
181 
184 
187 
188 
189 } // Namespace Isis
190 
191 // Declarations so they can be stored as QVariants (assets)
194 
195 #endif
196 
int count(const QString &keywordName) const
Counts the number of values the PVL keyword with the given name has, if it exists in this Resource...
Definition: Resource.cpp:186
QString m_name
Name of the Resource.
Definition: Resource.h:161
Contains more than one keyword-value pair.
Definition: PvlContainer.h:63
QString value(const QString &keywordName, const int &keywordIndex=0) const
Gets the value of the PVL keyword with the given name at the given index.
Definition: Resource.cpp:241
virtual ~Resource()
Destroys the Resource object.
Definition: Resource.cpp:122
PvlKeyword keyword(const QString &keywordName) const
Gets the PvlKeyword object with the given name, if it exists in this Resource.
Definition: Resource.cpp:287
VariantList m_assets
The list of assets associated with this Resource.
Definition: Resource.h:167
virtual PvlObject toPvl(const QString &pvlName="Resource") const
Transfer all keywords in map to a PvlObject.
Definition: Resource.cpp:583
bool isActive() const
Accessor method to determine whether this Resource is to be discarded.
Definition: Resource.cpp:438
virtual Resource * clone(const QString &name, const bool &withAssets=false) const
Clone this resource for additional specialized use.
Definition: Resource.cpp:565
bool isDiscarded() const
Accessor method to determine whether this Resource is to be discarded.
Definition: Resource.cpp:456
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *&#39;s to be stored in a QVariant.
const PvlFlatMap & keys() const
Accessor method for the PVL keywords associated with this Resource.
Definition: Resource.cpp:215
int removeAsset(const QString &assetName)
Removes all of the assets in this Resource that are mapped to the given name.
Definition: Resource.cpp:494
SharedGisGeometry geometry() const
Accessor method for this Resource&#39;s GIS geometry.
Definition: Resource.cpp:420
bool m_discard
A flag to indicate whether the Resource is inactive.
Definition: Resource.h:177
QString name() const
Accessor for a string containing the Resource&#39;s name.
Definition: Resource.cpp:131
void append(const QString &keywordName, const QString &keywordValue)
Appends the given value to the PVL keyword with the given name.
Definition: Resource.cpp:344
bool hasValidGeometry() const
This method is used to determine whether a valid GIS geometry has been set for this Resource...
Definition: Resource.cpp:406
SharedGisGeometry m_geom
A shared pointer to the GIS geometry object associated with this Resource.
Definition: Resource.h:170
bool isEqual(const Resource &other) const
Checks for equality of another Resource.
Definition: Resource.cpp:159
Provides a flat map of PvlKeywords.
Definition: PvlFlatMap.h:236
PvlFlatMap m_keys
The list of keywords associated with this Resource.
Definition: Resource.h:163
QVariant asset(const QString &assetName) const
Retrieves the value of the asset in this Resource that is mapped to the given name.
Definition: Resource.cpp:521
This class provides a resource of PVL keywords for Strategy classes.
Definition: Resource.h:71
void activate()
Activate a resource.
Definition: Resource.cpp:428
A single keyword-value pair.
Definition: PvlKeyword.h:98
virtual Resource * copy() const
Copy this resource for distinct management of its status.
Definition: Resource.cpp:543
int erase(const QString &keywordName)
Removes all of the PVL keywords in this Resource that are associated with the given name...
Definition: Resource.cpp:358
QMap< QString, QVariant > VariantList
Defintion for VariantList, a map between a string and a variant type variable.
Definition: Resource.h:131
void addAsset(const QString &assetName, QVariant &assetValue)
Inserts an asset with the given name and value into this Resource&#39;s VariantList.
Definition: Resource.cpp:480
bool isNull(const QString &keywordName, const int keywordIndex=0) const
Determines whether the PVL keyword with the given name at the given index is null.
Definition: Resource.cpp:204
Shared Resource data pointer.
Definition: Resource.h:140
bool hasAsset(const QString &assetName) const
This method is used to determine whether an asset with the given name is in this Resource.
Definition: Resource.cpp:469
void discard()
Discard a resource.
Definition: Resource.cpp:446
QSharedPointer< Resource > SharedResource
Defintion of a SharedResource, a shared pointer to a Resource object.
Definition: Resource.h:183
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool hasGeometry() const
This method is used to determine whether the GIS geometry has been set for this Resource.
Definition: Resource.cpp:395
Resource()
Default constructor for a Resource object.
Definition: Resource.cpp:48
void add(const QString &keywordName, const QString &keywordValue)
Adds a PVL keyword with the given name and value to this Resource.
Definition: Resource.cpp:303
void setName(const QString &identity)
A mutator to set the Resource&#39;s name.
Definition: Resource.cpp:141
QExplicitlySharedDataPointer< ResourceData > m_data
Explicitly managed pointer to Resource data.
Definition: Resource.h:176
QList< SharedResource > ResourceList
Defintion of a ResourceList, a list of SharedResource types.
Definition: Resource.h:186
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
Encapsulation class provides support for GEOS-C API.
Definition: GisGeometry.h:67
bool exists(const QString &keywordName) const
Determines whether a PVL keyword with the given name is in this Resource.
Definition: Resource.cpp:172
int clearAssets()
Clears the assets from this Resource&#39;s VariantList.
Definition: Resource.cpp:504