Isis Developer Reference
Isis::Resource Class Reference

This class provides a resource of PVL keywords for Strategy classes. More...

#include <Resource.h>

Collaboration diagram for Isis::Resource:
Collaboration graph

Public Member Functions

 Resource ()
 Default constructor for a Resource object.
 
 Resource (const QString &name)
 Constructs a Resource object with the given name.
 
 Resource (const QString &name, const PvlFlatMap &profile)
 Constructs a Resource object with the given name and profile of keywords.
 
 Resource (const QString &name, const PvlContainer &profile)
 Constructs a Resource object with the given name and profile of keywords.
 
 Resource (const Resource &other)
 Constructs a Resource from another Resource.
 
virtual ~Resource ()
 Destroys the Resource object.
 
QString name () const
 Accessor for a string containing the Resource's name.
 
void setName (const QString &identity)
 A mutator to set the Resource's name.
 
bool isEqual (const Resource &other) const
 Checks for equality of another Resource.
 
bool exists (const QString &keywordName) const
 Determines whether a PVL keyword with the given name is in this Resource.
 
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.
 
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.
 
const PvlFlatMapkeys () const
 Accessor method for the PVL keywords associated with this Resource.
 
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.
 
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.
 
PvlKeyword keyword (const QString &keywordName) const
 Gets the PvlKeyword object with the given name, if it exists in this Resource.
 
void add (const QString &keywordName, const QString &keywordValue)
 Adds a PVL keyword with the given name and value to this Resource.
 
void add (const PvlKeyword &keyword)
 Adds the given PVL keyword to this Resource.
 
void add (const PvlFlatMap &keys)
 Adds the PVL keywords from the given map of keywords to this Resource.
 
void append (const QString &keywordName, const QString &keywordValue)
 Appends the given value to the PVL keyword with the given name.
 
int erase (const QString &keywordName)
 Removes all of the PVL keywords in this Resource that are associated with the given name.
 
void add (GisGeometry *geom)
 Sets the GIS geometry for this Resource to the given value.
 
void add (SharedGisGeometry &geom)
 Sets the GIS geometry for this Resource to the given value.
 
bool hasGeometry () const
 This method is used to determine whether the GIS geometry has been set for this Resource.
 
bool hasValidGeometry () const
 This method is used to determine whether a valid GIS geometry has been set for this Resource.
 
SharedGisGeometry geometry () const
 Accessor method for this Resource's GIS geometry.
 
void activate ()
 Activate a resource.
 
bool isActive () const
 Accessor method to determine whether this Resource is to be discarded.
 
void discard ()
 Discard a resource.
 
bool isDiscarded () const
 Accessor method to determine whether this Resource is to be discarded.
 
bool hasAsset (const QString &assetName) const
 This method is used to determine whether an asset with the given name is in this Resource.
 
void addAsset (const QString &assetName, QVariant &assetValue)
 Inserts an asset with the given name and value into this Resource's VariantList.
 
QVariant asset (const QString &assetName) const
 Retrieves the value of the asset in this Resource that is mapped to the given name.
 
int removeAsset (const QString &assetName)
 Removes all of the assets in this Resource that are mapped to the given name.
 
int clearAssets ()
 Clears the assets from this Resource's VariantList.
 
virtual Resourcecopy () const
 Copy this resource for distinct management of its status.
 
virtual Resourceclone (const QString &name, const bool &withAssets=false) const
 Clone this resource for additional specialized use.
 
virtual PvlObject toPvl (const QString &pvlName="Resource") const
 Transfer all keywords in map to a PvlObject.
 

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.
 

Detailed Description

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.

Author
2012-07-15 Kris Becker

Constructor & Destructor Documentation

◆ Resource() [1/6]

Isis::Resource::Resource ( )

Default constructor for a Resource object.

The name is set to "Resource" and discard is set to false. The keyword and asset lists are left empty.

References setName().

Referenced by clone(), and copy().

◆ Resource() [2/6]

Isis::Resource::Resource ( const QString & name)

Constructs a Resource object with the given name.

Discard is set to false. The keyword and asset lists are left empty.

Parameters
nameA string containing the resource name.

References name(), and setName().

◆ Resource() [3/6]

Isis::Resource::Resource ( const QString & name,
const PvlFlatMap & profile )

Constructs a Resource object with the given name and profile of keywords.

Discard is set to false. The asset list is left empty.

Parameters
nameA string containing the resource name.
profileA map between strings and PVL keywords.

References name(), and setName().

◆ Resource() [4/6]

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.

Parameters
nameA string containing the resource name.
profileA PvlContainer of keywords.

References name(), and setName().

◆ Resource() [5/6]

Isis::Resource::Resource ( const Resource & other)

Constructs a Resource from another Resource.

Parameters
otherResource to copy

◆ ~Resource()

Isis::Resource::~Resource ( )
virtual

Destroys the Resource object.

◆ Resource() [6/6]

Isis::Resource::Resource ( const Resource & other,
const bool deepcopy )
protected

Constructs a Resource from another Resource with options to make it a deep or shallow copy of the data.

Parameters
otherResource to copy
deepcopyA deep copy of the data is made if true, otherwise a shallow copy of the data is performed

Member Function Documentation

◆ activate()

void Isis::Resource::activate ( )

Activate a resource.

◆ add() [1/5]

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.

Parameters
keysA PvlFlatMap containing the PvlKeywords to be inserted into the existing keyword list.

References add(), keys(), and keyword().

◆ add() [2/5]

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.

Parameters
keywordA reference to the PvlKeyword object to be added.

References keyword().

◆ add() [3/5]

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.

Parameters
keywordNameA string containing the name of the keyword to be added.
keywordValueA string containing the value of the keyword to be added.

Referenced by add(), and setName().

◆ add() [4/5]

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.

See also
add(SharedGisGeometry &geom)
Parameters
geomA pointer to the GisGeometry to be added to this Resource.

◆ add() [5/5]

void Isis::Resource::add ( SharedGisGeometry & geom)

Sets the GIS geometry for this Resource to the given value.

Parameters
geomA shared pointer to the GisGeometry to be added to this Resource.

◆ addAsset()

void Isis::Resource::addAsset ( const QString & assetName,
QVariant & assetValue )

Inserts an asset with the given name and value into this Resource's VariantList.

Parameters
assetNameA string containing the name of the asset to be added.
assetValueA QVariant containing the value of the asset to be added.

◆ append()

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.

Parameters
keywordNameA string containing the keyword name.
keywordValueThe value to be appended to the keyword associated with the given name.

◆ asset()

QVariant Isis::Resource::asset ( const QString & assetName) const

Retrieves the value of the asset in this Resource that is mapped to the given name.

Parameters
assetNameA string containing the name of the asset to be accessed.
Returns
QVariant The value of the asset that is mapped to the given name in this Resource's VariantList map.
Exceptions
IException::Programmer"Requested asset does not exist."

References _FILEINFO_, hasAsset(), and Isis::IException::Programmer.

◆ clearAssets()

int Isis::Resource::clearAssets ( )

Clears the assets from this Resource's VariantList.

Returns
int The number of assets that were in this Resource's VariantList before clearing it.

◆ clone()

Resource * Isis::Resource::clone ( const QString & name,
const bool & withAssets = false ) const
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.

Parameters
nameA string containing the name of the new cloned resource.
withAssetsSpecify to also copy out the Asset list.
Returns
Resource* Pointer to new resource

References Resource().

◆ copy()

Resource * Isis::Resource::copy ( ) const
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.

Returns
Resource* Pointer to new resource

References Resource().

◆ count()

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.

Parameters
keywordNameA string containing the keyword name.
Returns
int The size of the PvlKeyword object mapped to the given name in this Resource's PvlFlatMap.

◆ discard()

void Isis::Resource::discard ( )

Discard a resource.

◆ erase()

int Isis::Resource::erase ( const QString & keywordName)

Removes all of the PVL keywords in this Resource that are associated with the given name.

Parameters
keywordNameThe name mapped to the PVL keywords to be removed from this Resource's PvlFlatMap.
Returns
int The number of PVL keywords removed from this Resource's PvlFlatMap.

◆ exists()

bool Isis::Resource::exists ( const QString & keywordName) const

Determines whether a PVL keyword with the given name is in this Resource.

Parameters
keywordNameA string containing the keyword name.
Returns
bool Indicates whether a PVL keyword in this Resource's PvlFlatMap is mapped to the given name.

◆ geometry()

SharedGisGeometry Isis::Resource::geometry ( ) const

Accessor method for this Resource's GIS geometry.

Returns
SharedGisGeometry A shared pointer to the GIS geometry associated with this Resource.

◆ hasAsset()

bool Isis::Resource::hasAsset ( const QString & assetName) const

This method is used to determine whether an asset with the given name is in this Resource.

Parameters
assetNameA string containing the asset name.
Returns
bool Indicates whether an asset in this Resource's VariantList is mapped to the given name.

Referenced by asset().

◆ hasGeometry()

bool Isis::Resource::hasGeometry ( ) const

This method is used to determine whether the GIS geometry has been set for this Resource.

Returns
bool Indicates whether the GIS geometry has been set.

Referenced by hasValidGeometry().

◆ 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.

Returns
bool Indicates whether the GIS geometry is valid.

References hasGeometry().

◆ isActive()

bool Isis::Resource::isActive ( ) const

Accessor method to determine whether this Resource is to be discarded.

Returns
bool Indicates whether to discard this Resource.

◆ isDiscarded()

bool Isis::Resource::isDiscarded ( ) const

Accessor method to determine whether this Resource is to be discarded.

Returns
bool Indicates whether to discard this Resource.

◆ isEqual()

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.

Parameters
otherResource to check for equality
Returns
bool True if names are the same, false otherwise

References name().

◆ isNull()

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.

Parameters
keywordNameName of the PVL keyword whose values will be accessed.
indexZero-based index for the value to be checked.
Returns
bool Indicates whether the given PVL keyword is null at the given index.

Referenced by value().

◆ keys()

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.

Returns
const PvlFlatMap& A reference to the map of PVL keywords.

Referenced by add().

◆ keyword()

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.

Parameters
keywordNameA string containing the name of the PVL keyword to be accessed.
Returns
PvlKeyword The keyword mapped to the given name in this Resource's PvlFlatMap, if it exists. Otherwise an empty PvlKeyword with the given name.

Referenced by add(), and add().

◆ name()

QString Isis::Resource::name ( ) const

Accessor for a string containing the Resource's name.

Returns
QString The name of this resource.

Referenced by isEqual(), Resource(), Resource(), and Resource().

◆ removeAsset()

int Isis::Resource::removeAsset ( const QString & assetName)

Removes all of the assets in this Resource that are mapped to the given name.

Parameters
assetNameThe name mapped to the assets to be removed from this Resource's VariantList.
Returns
int The number of assets removed from this Resource's VariantList.

◆ setName()

void Isis::Resource::setName ( const QString & identity)

A mutator to set the Resource's name.

Parameters
identityA string containing the name of this Resource.

References add().

Referenced by Resource(), Resource(), Resource(), and Resource().

◆ toPvl()

PvlObject Isis::Resource::toPvl ( const QString & pvlName = "Resource") const
virtual

Transfer all keywords in map to a PvlObject.

Derived classes of Resource can define their own implementation if propagation of all keywords is not acceptable.

Parameters
pvlNameName of the PVL object to create and fill with map keywords
Returns
PvlObject An object with all keywords in the map

◆ value() [1/2]

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.

See also
isNull(QString, int)
value(QString, QString, int)
Parameters
keywordNameA string containing the name of the PVL keyword in this Resource's list of keywords.
indexZero-based index for the value to be accessed.
Returns
QString A string containing the PVL keyword value at the given index.

Referenced by value().

◆ value() [2/2]

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.

See also
isNull(QString, int)
value(QString, int)
Parameters
keywordNameA string containing the name of the PVL keyword in this Resource's list of keywords.
defaultValueA string containing the default value for this keyword if not found in the PvlFlatMap.
indexZero-based index for the value to be accessed.
Returns
QString A string containing the PVL keyword value at the given index, if it exists; otherwise the given default value is returned.

References isNull(), and value().


The documentation for this class was generated from the following files: