Isis 3 Developer Reference
|
This class provides a resource of PVL keywords for Strategy classes. More...
#include <Resource.h>
Public Member Functions | |
Resource () | |
Default constructor for a Resource object. More... | |
Resource (const QString &name) | |
Constructs a Resource object with the given name. More... | |
Resource (const QString &name, const PvlFlatMap &profile) | |
Constructs a Resource object with the given name and profile of keywords. More... | |
Resource (const QString &name, const PvlContainer &profile) | |
Constructs a Resource object with the given name and profile of keywords. More... | |
Resource (const Resource &other) | |
Constructs a Resource from another Resource. More... | |
virtual | ~Resource () |
Destroys the Resource object. More... | |
QString | name () const |
Accessor for a string containing the Resource's name. More... | |
void | setName (const QString &identity) |
A mutator to set the Resource's name. More... | |
bool | isEqual (const Resource &other) const |
Checks for equality of another Resource. More... | |
bool | exists (const QString &keywordName) const |
Determines whether a PVL keyword with the given name is in this Resource. More... | |
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. More... | |
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. More... | |
const PvlFlatMap & | keys () const |
Accessor method for the PVL keywords associated with this Resource. More... | |
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. More... | |
QString | value (const QString &keywordName, const QString &defValue, const int &keywordIndex=0) const |
Gets the value of the PVL keyword at the given index, if found; otherwise it returns the given default value. More... | |
PvlKeyword | keyword (const QString &keywordName) const |
Gets the PvlKeyword object with the given name, if it exists in this Resource. More... | |
void | add (const QString &keywordName, const QString &keywordValue) |
Adds a PVL keyword with the given name and value to this Resource. More... | |
void | add (const PvlKeyword &keyword) |
Adds the given PVL keyword to this Resource. More... | |
void | add (const PvlFlatMap &keys) |
Adds the PVL keywords from the given map of keywords to this Resource. More... | |
void | append (const QString &keywordName, const QString &keywordValue) |
Appends the given value to the PVL keyword with the given name. More... | |
int | erase (const QString &keywordName) |
Removes all of the PVL keywords in this Resource that are associated with the given name. More... | |
void | add (GisGeometry *geom) |
Sets the GIS geometry for this Resource to the given value. More... | |
void | add (SharedGisGeometry &geom) |
Sets the GIS geometry for this Resource to the given value. More... | |
bool | hasGeometry () const |
This method is used to determine whether the GIS geometry has been set for this Resource. More... | |
bool | hasValidGeometry () const |
This method is used to determine whether a valid GIS geometry has been set for this Resource. More... | |
SharedGisGeometry | geometry () const |
Accessor method for this Resource's GIS geometry. More... | |
void | activate () |
Activate a resource. More... | |
bool | isActive () const |
Accessor method to determine whether this Resource is to be discarded. More... | |
void | discard () |
Discard a resource. More... | |
bool | isDiscarded () const |
Accessor method to determine whether this Resource is to be discarded. More... | |
bool | hasAsset (const QString &assetName) const |
This method is used to determine whether an asset with the given name is in this Resource. More... | |
void | addAsset (const QString &assetName, QVariant &assetValue) |
Inserts an asset with the given name and value into this Resource's VariantList. More... | |
QVariant | asset (const QString &assetName) const |
Retrieves the value of the asset in this Resource that is mapped to the given name. More... | |
int | removeAsset (const QString &assetName) |
Removes all of the assets in this Resource that are mapped to the given name. More... | |
int | clearAssets () |
Clears the assets from this Resource's VariantList. More... | |
virtual Resource * | copy () const |
Copy this resource for distinct management of its status. More... | |
virtual Resource * | clone (const QString &name, const bool &withAssets=false) const |
Clone this resource for additional specialized use. More... | |
virtual PvlObject | toPvl (const QString &pvlName="Resource") const |
Transfer all keywords in map to a PvlObject. More... | |
Protected Member Functions | |
Resource (const Resource &other, const bool deepcopy) | |
Constructs a Resource from another Resource with options to make it a deep or shallow copy of the data. More... | |
This class provides a resource of PVL keywords for Strategy classes.
The Resource may have a associated GIS geometry and list of assets. If a Resource has been flagged as discarded (i.e. inactive), then the Strategy using the Resource may be set to not apply algorithms to this Resource.
Isis::Resource::Resource | ( | ) |
Isis::Resource::Resource | ( | const QString & | name | ) |
Isis::Resource::Resource | ( | const QString & | name, |
const PvlFlatMap & | profile | ||
) |
Isis::Resource::Resource | ( | const QString & | name, |
const PvlContainer & | profile | ||
) |
Constructs a Resource object with the given name and profile of keywords.
Discard is set to false. The asset list is left empty.
name | A string containing the resource name. |
profile | A PvlContainer of keywords. |
Isis::Resource::Resource | ( | const Resource & | other | ) |
|
virtual |
Destroys the Resource object.
|
protected |
void Isis::Resource::activate | ( | ) |
Activate a resource.
Referenced by clone().
void Isis::Resource::add | ( | const QString & | keywordName, |
const QString & | keywordValue | ||
) |
Adds a PVL keyword with the given name and value to this Resource.
A PvlKeyword object is created and added to the PvlFlatMap belonging to this Resource.
keywordName | A string containing the name of the keyword to be added. |
keywordValue | A string containing the value of the keyword to be added. |
void Isis::Resource::add | ( | const PvlKeyword & | keyword | ) |
Adds the given PVL keyword to this Resource.
The PvlKeyword object is added to the PvlFlatMap belonging to this Resource.
keyword | A reference to the PvlKeyword object to be added. |
References keyword().
void Isis::Resource::add | ( | const PvlFlatMap & | keys | ) |
Adds the PVL keywords from the given map of keywords to this Resource.
The new keywords are inserted into this Resource's existing PvlFlatMap.
keys | A PvlFlatMap containing the PvlKeywords to be inserted into the existing keyword list. |
void Isis::Resource::add | ( | GisGeometry * | geom | ) |
Sets the GIS geometry for this Resource to the given value.
Note this Resource then takes control of this pointer. Therefore, there should be no other references as it is turned into a shared pointer.
geom | A pointer to the GisGeometry to be added to this Resource. |
void Isis::Resource::add | ( | SharedGisGeometry & | geom | ) |
Sets the GIS geometry for this Resource to the given value.
geom | A shared pointer to the GisGeometry to be added to this Resource. |
void Isis::Resource::addAsset | ( | const QString & | assetName, |
QVariant & | assetValue | ||
) |
Inserts an asset with the given name and value into this Resource's VariantList.
assetName | A string containing the name of the asset to be added. |
assetValue | A QVariant containing the value of the asset to be added. |
void Isis::Resource::append | ( | const QString & | keywordName, |
const QString & | keywordValue | ||
) |
Appends the given value to the PVL keyword with the given name.
If the keyword already exists in the PvlFlatMap, the provided value is appended to the keyword's list of values. Otherwise, a new PVL keyword with the given name and value is added.
keywordName | A string containing the keyword name. |
keywordValue | The value to be appended to the keyword associated with the given name. |
QVariant Isis::Resource::asset | ( | const QString & | assetName | ) | const |
Retrieves the value of the asset in this Resource that is mapped to the given name.
assetName | A string containing the name of the asset to be accessed. |
IException::Programmer | "Requested asset does not exist." |
References _FILEINFO_, hasAsset(), and Isis::IException::Programmer.
int Isis::Resource::clearAssets | ( | ) |
|
virtual |
Clone this resource for additional specialized use.
This clone method will create a new Resource with or without Assets. Keywords are fully propagated. The GisGeometry is also propagated as it can easily be reset. The resource status is activated.
Use this method when a deep copy of the Resource data is desired so that it can vary independently of its parent.
name | A string containing the name of the new cloned resource. |
withAssets | Specify to also copy out the Asset list. |
References activate(), clearAssets(), and Resource().
|
virtual |
Copy this resource for distinct management of its status.
This copy method will create a copy of an existing Resource and retain all its current data and status.
Use this method when a shallow (shared data) copy of the Resource is desired so that its active status can be managed with copy of the same data source.
References Resource().
int Isis::Resource::count | ( | const QString & | keywordName | ) | const |
Counts the number of values the PVL keyword with the given name has, if it exists in this Resource.
Otherwise, it returns 0.
keywordName | A string containing the keyword name. |
void Isis::Resource::discard | ( | ) |
Discard a resource.
int Isis::Resource::erase | ( | const QString & | keywordName | ) |
Removes all of the PVL keywords in this Resource that are associated with the given name.
keywordName | The name mapped to the PVL keywords to be removed from this Resource's PvlFlatMap. |
bool Isis::Resource::exists | ( | const QString & | keywordName | ) | const |
Determines whether a PVL keyword with the given name is in this Resource.
keywordName | A string containing the keyword name. |
SharedGisGeometry Isis::Resource::geometry | ( | ) | const |
bool Isis::Resource::hasAsset | ( | const QString & | assetName | ) | const |
bool Isis::Resource::hasGeometry | ( | ) | const |
This method is used to determine whether the GIS geometry has been set for this Resource.
Referenced by hasValidGeometry().
bool Isis::Resource::hasValidGeometry | ( | ) | const |
This method is used to determine whether a valid GIS geometry has been set for this Resource.
If no geometry has been set or the geometry is empty, false is returned.
References hasGeometry().
bool Isis::Resource::isActive | ( | ) | const |
bool Isis::Resource::isDiscarded | ( | ) | const |
bool Isis::Resource::isEqual | ( | const Resource & | other | ) | const |
Checks for equality of another Resource.
This is nothing more than comparing the names of the two resources. If both resources have the same name without regard to case, they are considered the same resource.
other | Resource to check for equality |
References name().
bool Isis::Resource::isNull | ( | const QString & | keywordName, |
const int | index = 0 |
||
) | const |
Determines whether the PVL keyword with the given name at the given index is null.
This method looks for the PVL keyword in this Resource's PvlFlatMap that is mapped to the given name and checks whether the value at the given index is null. If no index is given, by default this method checks the first value (i.e. index 0). If the keyword does not exist in the map, this method returns true.
keywordName | Name of the PVL keyword whose values will be accessed. |
index | Zero-based index for the value to be checked. |
Referenced by value().
const PvlFlatMap & Isis::Resource::keys | ( | ) | const |
Accessor method for the PVL keywords associated with this Resource.
This method gets the PvlFlatMap, a map between a name and PvlKeyword objects.
Referenced by add().
PvlKeyword Isis::Resource::keyword | ( | const QString & | keywordName | ) | const |
Gets the PvlKeyword object with the given name, if it exists in this Resource.
If not, an empty PvlKeyword with the given name is returned.
keywordName | A string containing the name of the PVL keyword to be accessed. |
Referenced by add().
QString Isis::Resource::name | ( | ) | const |
Accessor for a string containing the Resource's name.
Referenced by isEqual(), and Resource().
int Isis::Resource::removeAsset | ( | const QString & | assetName | ) |
void Isis::Resource::setName | ( | const QString & | identity | ) |
A mutator to set the Resource's name.
identity | A string containing the name of this Resource. |
References add().
Referenced by Resource().
|
virtual |
QString Isis::Resource::value | ( | const QString & | keywordName, |
const int & | index = 0 |
||
) | const |
Gets the value of the PVL keyword with the given name at the given index.
This method looks for the PVL keyword in this Resource's PvlFlatMap that is mapped to the given name and accesses the value at the given index. If no index is given, by default this method returns the first value (i.e. index 0).
Note: If the keyword does not exist in the map, PvlFlatMap throws an exception. To avoid this, the isNull() method can be called before invoking this method to verify whether a value exists at the given index. Otherwise, the value(QString, QString, int) version of this overloaded method can be called.
keywordName | A string containing the name of the PVL keyword in this Resource's list of keywords. |
index | Zero-based index for the value to be accessed. |
Referenced by value().
QString Isis::Resource::value | ( | const QString & | keywordName, |
const QString & | defaultValue, | ||
const int & | index = 0 |
||
) | const |
Gets the value of the PVL keyword at the given index, if found; otherwise it returns the given default value.
This method looks for the PVL keyword in this Resource's PvlFlatMap that is mapped to the given name and accesses the value at the given index. If no index is given, by default this method returns the first value (i.e. index 0).
If the keyword does not exist in the map, the given default value will be returned.
keywordName | A string containing the name of the PVL keyword in this Resource's list of keywords. |
defaultValue | A string containing the default value for this keyword if not found in the PvlFlatMap. |
index | Zero-based index for the value to be accessed. |