Isis 3 Programmer Reference
Isis::Strategy Class Reference

Strategy - Supports algorithm development. More...

#include <Strategy.h>

Collaboration diagram for Isis::Strategy:
Collaboration graph

Public Member Functions

 Strategy ()
 Constructs default Strategy object of name "Strategy" and type "Counter". More...
 
 Strategy (const PvlObject &definition, const ResourceList &globals)
 Constructs Strategy object from the given definition pvl and shared resource globals. More...
 
virtual ~Strategy ()
 Destroys the Strategy object. More...
 
QString name () const
 Accessor method to get the name of the strategy. More...
 
QString type () const
 Accessor method to get the type of strategy. More...
 
QString description () const
 Return description for the strategy. More...
 
int apply (ResourceList &resources)
 Apply algorithm to resource list. More...
 
int apply (SharedResource &resource)
 Apply algorithm to Resource. More...
 
virtual int apply (ResourceList &resources, const ResourceList &globals)
 Apply strategy algorithms to list of Resources. More...
 
virtual int apply (SharedResource &resource, const ResourceList &globals)
 This method applies the strategy algorithms to the data stored in the given shared resource. More...
 
unsigned int totalProcessed () const
 Accessor for the total number of resources processed. More...
 

Protected Types

typedef QSharedPointer< PvlObjectSharedPvlObject
 Definition for a SharedPvlObject, a shared pointer to a PvlObject. More...
 

Protected Member Functions

 Strategy (const QString &name, const QString &type)
 Constructs a Strategy object from the given name, type, and shared resource globals. More...
 
void setName (const QString &name)
 Allow derived strategies to reset name (mostly for default constructors) More...
 
void setType (const QString &type)
 Allow derived strategies to reset type (mostly for default constructors) More...
 
ResourceList getGlobalDefaults () const
 Accessor method to get the global defaults. More...
 
ResourceList getGlobals (SharedResource &myGlobals, const ResourceList &globals) const
 
const PvlObjectgetDefinition () const
 
PvlFlatMap getDefinitionMap () const
 Returns the keyword definitions found in the Strategy object. More...
 
void setApplyToDiscarded ()
 Sets Resource as discarded. More...
 
bool isApplyToDiscarded () const
 Accessor for the apply discarded variable. More...
 
void setDoNotApplyToDiscarded ()
 Disables the general application of Strategy algorithm for all Resources regardless of state. More...
 
int applyToResources (ResourceList &resources, const ResourceList &globals)
 Applies the strategy algorithms to the resources in the given list. More...
 
unsigned int processed ()
 Increments the total number of resources processed and returns the incremented value. More...
 
void resetProcessed ()
 Resets the total number of processed resources to zero. More...
 
int countActive (const ResourceList &resources) const
 Counts the number of active (i.e. More...
 
int countDiscarded (const ResourceList &resources) const
 Counts the number of non-active (i.e. More...
 
ResourceList assetResourceList (const SharedResource &resource, const QString &name) const
 Searches the given resource for an asset with the given name and converts it to a ResourceList, if possible. More...
 
QString findReplacement (const QString &target, const ResourceList &globals, const int &index=0, const QString &defValue="") const
 Find keyword replacement value in globals list. More...
 
QStringList qualifiers (const QString &keyspec, const QString &delimiter="::") const
 Splits the given keyspec string into a list using the given delimiter string. More...
 
QString scanAndReplace (const QString &input, const QString &target, const QString &replacement) const
 Performs a case insensitive scan of the input string for a substring matching the target string and replaces the target substring with the replacement string. More...
 
QString translateKeywordArgs (const QString &value, const ResourceList &globals, const QString &defValue="") const
 Translates the arguments of the PVL keyword in the PVL definition object. More...
 
QString processArgs (const QString &value, const QStringList &argKeys, const ResourceList &globals, const QString &defValue="") const
 Processes the given string value using the given argument list, resource and default resource. More...
 
void propagateKeys (SharedResource &source, SharedResource &target) const
 Adds the PVL definition keywords from the source to the target. More...
 
SharedResource composite (SharedResource &resourceA, SharedResource &resourceB, const QPair< QString, QString > &keySuffix=qMakePair(QString("A"), QString("B"))) const
 Create a composite Resource from a pair by merging keywords. More...
 
bool importGeometry (SharedResource &resource, const ResourceList &globals) const
 Imports a geometry from the given resource. More...
 
ResourceList activeList (ResourceList &resources) const
 Get list of all active Resources only - no discarded Resources. More...
 
void activateList (ResourceList &resources) const
 Activate all resources contained in the resource list. More...
 
void deactivateList (ResourceList &resources) const
 Deactivate all resources contained in the resource list. More...
 
ResourceList copyList (const ResourceList &resources) const
 Make a copy of the resource list that is independently managed. More...
 
ResourceList cloneList (const ResourceList &resources, const bool &withAssets=false) const
 Create a clone of a Resource list. More...
 
int applyToIntersectedGeometry (ResourceList &resources, GisGeometry &geom, const ResourceList &globals)
 Identify and apply Strategy to Resources that intersect a geometry. More...
 
bool isDebug () const
 An accessor method so that inherited classes can determine whether to print debug messages for this object. More...
 
bool doShowProgress () const
 
bool initProgress (const int &nsteps=0, const QString &text="")
 Initializes strategy progress monitor if requested by user. More...
 
QStringList getObjectList (const PvlObject &object) const
 
template<class STRATEGYLIST , class STRATEGYFACTORY >
STRATEGYLIST LoadMinerStrategies (const QString &minerName, const ResourceList &globals) const
 

Static Protected Member Functions

static void queryCallback (void *item, void *userdata)
 Important GEOS query callback for class and overlap geometry. More...
 

Private Attributes

ResourceList m_globals
 A shared pointer to the global Resource of keywords. More...
 
SharedPvlObject m_definition
 A shared pointer to the PvlObject that defines the strategy. More...
 
QString m_name
 A string containing the name of the strategy. More...
 
QString m_type
 A string containing the type of strategy. More...
 
unsigned int m_total
 The total number of resources processed. More...
 
bool m_applyDiscarded
 Indicates whether to apply strategy to discarded resources. More...
 
bool m_debug
 Indicates whether to print debug messages. More...
 
QScopedPointer< Progressm_progress
 Progress percentage monitor. More...
 

Detailed Description

Strategy - Supports algorithm development.

This base class provides a framework to develop strategic planning tools used to process and/or rank ISIS resources.

The ISIS resource can be cubes, PVLs (e.g., PDS/EDRs, etc), CSV files or virtually any other resource type simply by adding support in the Resources type class.

This default implementation is simply a LessThan function for real data types

  • likely on to the more heavily used function evaluators.

The Users may provide values for the following influential keywords in the Pvl Stategy configuration:

Object = Strategy
Name = Emission
Type = Calculator
Equation = "((EmissionAngle > 20) && (EmissionAngle < 80))"
Result = EmissionCriteria
EndObject
Author
2012-07-15 Kris Becker
History:

2012-07-15 Kris Becker - Original version.

2015-03-18 Jeannie Backer - Brought class files closer to ISIS coding standards.

2015-04-07 Kristin Berry - Modified applytoIntserectedGeometry to deal

2015-03-26 Jeannie Backer - Updated documentation.

2015-03-28 Kris Becker - Added the composite(Resource, Resource) method

2015-04-30 Kris Becker - Added setName() and setType() methods

2015-05-08 Kris Becker - Added new methods to provide better support for keyword argument replacement with global parameters: getGlobalDefaults(), getGlobals(), getDefinition() and getDefinitionMap(). Removed virtual designation for apply() methods that do not take a globals resource list.

2015-06-17 Kris Becker - Added ability for users to simplify geometry such that topology is preserved. Keywords that provide numbers of original points, points in geoemtry size and tolerance used can optionally be created in Resources that apply this feature.

2015-09-27 Kris Becker - Added copyList() and cloneList() methods.

2015-10-12 Kris Becker - Fixed bug in how arguments are scanned and replaced. Once the count of arguments reached above 9, %1 was replaced for %10. Scan for replacements in reverse order fixes this issue.

2016-03-07 Tyler Wilson - Corrected documentation, and created a unit test to test most of this classe's methods.

Definition at line 102 of file Strategy.h.

Member Typedef Documentation

◆ SharedPvlObject

Definition for a SharedPvlObject, a shared pointer to a PvlObject.

Definition at line 125 of file Strategy.h.

Constructor & Destructor Documentation

◆ Strategy() [1/3]

Isis::Strategy::Strategy ( )

Constructs default Strategy object of name "Strategy" and type "Counter".

Debug and apply discarded are set to false.

Definition at line 50 of file Strategy.cpp.

◆ Strategy() [2/3]

Isis::Strategy::Strategy ( const PvlObject definition,
const ResourceList globals 
)

Constructs Strategy object from the given definition pvl and shared resource globals.

Strategy name, strategy type, debug, and apply discarded values are read from the pvl. If not found in the PVL, debug and apply discarded are set to false.

Example PVL:

Object = Strategy
Name = Emission
Type = Calculator
Equation = "((EmissionAngle > 20) && (EmissionAngle < 80))"
Result = EmissionCriteria
ApplyToDiscarded = true
Debug = false
EndObject
Parameters
definitionA PVL that defines the strategy.
globalsA shared pointer to a global Resource of keywords.

Definition at line 93 of file Strategy.cpp.

References Isis::PvlFlatMap::get(), getDefinitionMap(), initProgress(), m_applyDiscarded, m_debug, m_name, m_type, and Isis::toBool().

◆ ~Strategy()

Isis::Strategy::~Strategy ( )
virtual

Destroys the Strategy object.

Definition at line 109 of file Strategy.cpp.

◆ Strategy() [3/3]

Isis::Strategy::Strategy ( const QString &  name,
const QString &  type 
)
protected

Constructs a Strategy object from the given name, type, and shared resource globals.

Debug and apply discarded are set to false.

Parameters
nameA string containing the strategy name.
typeA string containing the strategy type.

Definition at line 64 of file Strategy.cpp.

Member Function Documentation

◆ activateList()

void Isis::Strategy::activateList ( ResourceList resources) const
protected

Activate all resources contained in the resource list.

Parameters
resourcesA list of resources to activate.

Definition at line 832 of file Strategy.cpp.

◆ activeList()

ResourceList Isis::Strategy::activeList ( ResourceList resources) const
protected

Get list of all active Resources only - no discarded Resources.

Parameters
resourcesA list of resources to check.
Returns
ResourceList A list of active resouces from the given list.

Definition at line 817 of file Strategy.cpp.

Referenced by applyToIntersectedGeometry().

◆ apply() [1/4]

int Isis::Strategy::apply ( ResourceList resources)

Apply algorithm to resource list.

This method is used to initiate the Strategy algorithm implemented by deriving Strategy for a list of Resources.

History:
2015-05-27 Kris Becker
Parameters
resourcesList of resources to be processed by the Strategy algorithm
Returns
int Number of Resources processed by the algorithm

Definition at line 242 of file Strategy.cpp.

References getGlobalDefaults().

Referenced by apply(), applyToIntersectedGeometry(), and applyToResources().

◆ apply() [2/4]

int Isis::Strategy::apply ( SharedResource resource)

Apply algorithm to Resource.

This method is used to initiate the Strategy algorithm implemented by deriving Strategy for a Resources.

History:
2015-05-27 Kris Becker
Parameters
resourceResource to be processed by the Strategy algorithm
Returns
int Number of Resources processed by the algorithm

Definition at line 259 of file Strategy.cpp.

References apply(), and getGlobalDefaults().

◆ apply() [3/4]

int Isis::Strategy::apply ( ResourceList resources,
const ResourceList globals 
)
virtual

Apply strategy algorithms to list of Resources.

This method iterates once through all Resources contained in the list. Resources that have been discarded are filtered out unless users/strategies opt to process all resources.

By making the actual iteration of Resources a separate method, this allows other strategies to derive this virtual return to give them a change to do something meaninful prior to processing the Resource list, but retain behavior in counts and calls to the Resource applicator.

See also
applyToResources(ResourceList &resources, ResourceList &globals)
Author
2013-01-30 Kris Becker
Parameters
resourcesA list of resources to which the strategy will be applied.
Returns
int The number of resources processed.

Definition at line 285 of file Strategy.cpp.

References applyToResources().

◆ apply() [4/4]

int Isis::Strategy::apply ( SharedResource resource,
const ResourceList globals 
)
virtual

This method applies the strategy algorithms to the data stored in the given shared resource.

Parameters
resourceA resource to which the strategy will be applied.
Returns
int The number of resources processed, i.e. 1.

Definition at line 298 of file Strategy.cpp.

References isDebug().

◆ applyToIntersectedGeometry()

int Isis::Strategy::applyToIntersectedGeometry ( ResourceList resources,
GisGeometry geom,
const ResourceList globals 
)
protected

Identify and apply Strategy to Resources that intersect a geometry.

This method applies the Strategy::apply(SharedResource &) method for all Resources whose geometry intersect the given geometry. This method uses a very efficient RTree implementation in GEOS to determine geometries that intersect each others envelope (a minimal boundary for a geometry). There is a significant performance increase (up to 30% or more) achieved by using this method over direct intersection and operation techniques.

However, since this is typically done once, it is not advantageous to create an index and then search it doing essentially the same operation as the evaluation of the RTree. Therefore a direct intersection loop is available and applied by default. The use of the RTree method can be selected by a user preferenced keyword. Set GisMethod = Indexed. The default is GisMethod = Direct.

This method only acts upon active Resources, so be sure to provide the appropriate state of Resources in the list provided.

It will discard all Resources prior to call the GEOS intersection query. When a Resources is identified to intersect, it makes in active again prior to calling the Strategy::apply(SharedResource &) method. Note that the implementation of the apply(SharedResource &) should further check for false postives as the envelope used in the RTree method may not be as accurate as is required for a robust intersection of GIS geometries.

Author
2013-02-23 Kris Becker
Parameters
resourcesA list of resources to which the strategy will be applied.
geomA reference to the GIS geometry to be intersected.
globalsGlobal parameter pool for keyword translation
Returns
int The number of resources processed.
Exceptions
IException::Programmer"Cannot apply RTree search to bad geometry."

Definition at line 946 of file Strategy.cpp.

References _FILEINFO_, activeList(), apply(), deactivateList(), Isis::GisGeometry::geometry(), Isis::PvlFlatMap::get(), getDefinitionMap(), initProgress(), Isis::GisGeometry::intersects(), isDebug(), Isis::GisGeometry::isValid(), name(), processed(), Isis::IException::Programmer, queryCallback(), Isis::toString(), and type().

◆ applyToResources()

int Isis::Strategy::applyToResources ( ResourceList resources,
const ResourceList globals 
)
protected

Applies the strategy algorithms to the resources in the given list.

Parameters
resourcesA list of resources to which the strategy will be applied.
globalsA list of global resources.
Returns
int The number of resources processed.

Definition at line 354 of file Strategy.cpp.

References apply(), countActive(), initProgress(), isApplyToDiscarded(), and processed().

Referenced by apply().

◆ assetResourceList()

ResourceList Isis::Strategy::assetResourceList ( const SharedResource resource,
const QString &  name 
) const
protected

Searches the given resource for an asset with the given name and converts it to a ResourceList, if possible.

Parameters
resourceThe resource to be searched
nameThe name of the asset being searched for
Returns
ResourceList If the asset can be converted to a ResourceList, it is returned. Otherwise an empty ResourceList is returned.

Definition at line 441 of file Strategy.cpp.

References name().

◆ cloneList()

ResourceList Isis::Strategy::cloneList ( const ResourceList resources,
const bool &  withAssets = false 
) const
protected

Create a clone of a Resource list.

This method creates a clone of the resources where an independent copy of the Resource data is created from its parent. Assets are optional created as well, but can be retained if desired. Any shared components are simply copied as well and can be individually managed if desired.

This creates new data for all copies the parent for each resource. All Resources are set to an active state upon cloning.

Author
2015-09-27 Kris Becker
Parameters
resourcesList of resources to clone
withAssetsIf true, assets are retained, otherwise they are deleted from the cloned Resource.
Returns
ResourceList List of cloned Resources

Definition at line 899 of file Strategy.cpp.

◆ composite()

SharedResource Isis::Strategy::composite ( SharedResource resourceA,
SharedResource resourceB,
const QPair< QString, QString > &  keySuffix = qMakePair(QString("A"),QString("B")) 
) const
protected

Create a composite Resource from a pair by merging keywords.

This method will create a composite Resource from two resources my merging the keywords from both resources. Users can provide a list of keywords they would like to merge by providing the PropogateKeywords Strategy keyword in the definition section. If not provided or empty, all keywords in each Resource is propagated.

Keywords from each resource are distinguished by appending a suffix to the name of each keyword propagated. For example, the default suffix for resourceA is "A" and resourceB is "B". If the keyword named "Emission" exists in both resourceA and resourceB then two keywords wind up in the composite resource as "EmissionA" and "EmissionB".

The name of the composite resource is the name of resourceA and resourceB separated by an "_".

Author
2015-03-28 Kris Becker
Parameters
resourceAFirst resource
resourceBSecond resource
keySuffixString pair specifying the suffix to append to the keywords originating from each Resource Defaults: ("A", "B")
Returns
SharedResource Composite Resource of combined keywords

Definition at line 650 of file Strategy.cpp.

References Isis::PvlFlatMap::allValues(), getDefinitionMap(), and Isis::PvlKeyword::setName().

◆ copyList()

ResourceList Isis::Strategy::copyList ( const ResourceList resources) const
protected

Make a copy of the resource list that is independently managed.

This method creates a copy of the resources but provides independent management of its status from its parent. All Resource data, name, keywords, assets and geometry, are copied to the new Resource list created. Its current status is also copied.

This allows the same data for all copies to be shared but the active/discard status to be managed in each copy independently of the parent for each resource.

This is really useful for strategies such as AssetSideBar.

Author
2015-09-27 Kris Becker
Parameters
resourcesInput list of Resources to copy
Returns
resources of copied (data) Resources

Definition at line 871 of file Strategy.cpp.

◆ countActive()

int Isis::Strategy::countActive ( const ResourceList resources) const
protected

Counts the number of active (i.e.

not discarded) resources in the given list.

Parameters
resourcesA list of resources to count.
Returns
int The number of resources in the given list that are not set to discarded.

Definition at line 409 of file Strategy.cpp.

References countDiscarded().

Referenced by applyToResources().

◆ countDiscarded()

int Isis::Strategy::countDiscarded ( const ResourceList resources) const
protected

Counts the number of non-active (i.e.

discarded) resources in the given list.

Parameters
resourcesA list of resources to count.
Returns
int The number of resources in the given list that are set to discarded.

Definition at line 423 of file Strategy.cpp.

Referenced by countActive().

◆ deactivateList()

void Isis::Strategy::deactivateList ( ResourceList resources) const
protected

Deactivate all resources contained in the resource list.

Parameters
resourcesA list of resources to discard.

Definition at line 844 of file Strategy.cpp.

Referenced by applyToIntersectedGeometry().

◆ description()

QString Isis::Strategy::description ( ) const

Return description for the strategy.

If a Description keyword exists in the PvlObject definition of the strategy, this is returned to the caller. If it doesn't exist, it will provide a simple description made up of its name and type.

Author
2015-03-28 Kris Becker
Returns
QString Description for this strategy

Definition at line 218 of file Strategy.cpp.

References m_definition, name(), and type().

◆ doShowProgress()

bool Isis::Strategy::doShowProgress ( ) const
protected
Returns
bool

Definition at line 1089 of file Strategy.cpp.

References m_progress.

Referenced by initProgress(), and processed().

◆ findReplacement()

QString Isis::Strategy::findReplacement ( const QString &  target,
const ResourceList globals,
const int &  index = 0,
const QString &  defValue = "" 
) const
protected

Find keyword replacement value in globals list.

Author
2015-05-07 Kris Becker
Parameters
globalsResourceList A list of resources to be searched.
targetQString The keyword of the target resource.
indexint The index of the last resource in the list with keyword == target.
defValueQString The value to return in the event the resource is not found.
Returns
QString

Definition at line 467 of file Strategy.cpp.

Referenced by processArgs().

◆ getDefinitionMap()

PvlFlatMap Isis::Strategy::getDefinitionMap ( ) const
protected

Returns the keyword definitions found in the Strategy object.

Author
2015-06-12 Kris Becker
Returns
PvlFlatMap Set of keywords found in strategy object

Definition at line 202 of file Strategy.cpp.

References m_definition, and Isis::PvlConstraints::withExcludes().

Referenced by applyToIntersectedGeometry(), composite(), importGeometry(), initProgress(), propagateKeys(), Strategy(), and translateKeywordArgs().

◆ getGlobalDefaults()

ResourceList Isis::Strategy::getGlobalDefaults ( ) const
protected

Accessor method to get the global defaults.

Returns
ResourceList containing the global defaults.

Definition at line 161 of file Strategy.cpp.

References m_globals.

Referenced by apply().

◆ getGlobals()

ResourceList Isis::Strategy::getGlobals ( SharedResource myGlobals,
const ResourceList globals 
) const
protected
History:
kbecker (5/11/2015)
Parameters
myGlobalsAdditional source for keyword translation
globalsPre-exiting global pool to add myGlobals
Returns
ResourceList

Definition at line 175 of file Strategy.cpp.

Referenced by importGeometry().

◆ importGeometry()

bool Isis::Strategy::importGeometry ( SharedResource resource,
const ResourceList globals 
) const
protected

Imports a geometry from the given resource.

By default, this method searches the definition PVL object for a GisGeometry keyword. If the PVL contains either the GisGeometryRef or the GisGeometryKey keywords, then the value is used to search the resource's flat map for the geometry. Then, if the RemoveGisKeywordAfterImport keyword is set to true in the PVL, the resource erases the keyword from the flat map.

If a geometry is found, the PVL is searched for a GisGeometryArgs keyword and the arguments are processed, if they exist. Next, the GisType is read from the PVL. The geometry and type are used to construct a GIS geometry and add it to the resource.

Parameters
resourceA shared pointer to the resource from which the geometry will be imported.
globalsThe resource list to be searched.
Returns
bool Indicates whether the geometry was successfully imported.

Definition at line 721 of file Strategy.cpp.

References Isis::PvlFlatMap::allValues(), Isis::PvlFlatMap::exists(), Isis::PvlFlatMap::get(), getDefinitionMap(), getGlobals(), isDebug(), name(), Isis::GisGeometry::points(), processArgs(), Isis::GisGeometry::simplify(), Isis::toBool(), Isis::toDouble(), Isis::toString(), translateKeywordArgs(), Isis::GisGeometry::type(), and type().

◆ initProgress()

bool Isis::Strategy::initProgress ( const int &  nsteps = 0,
const QString &  text = "" 
)
protected

Initializes strategy progress monitor if requested by user.

This method will set up progress monitoring for the user if the "ShowProgress" keyword exists and is set to "True" in any strategy Pvl configuration.

The processed() method will apply status checking to measure progress. For consistency purposes, the resetProcessed() method is always called which resets the internal resource process count to 0.

Strategy implementors must initialize using this method if they rederive apply(ResourceList &resources) or they do not call applyToResources(ResourceList &resources) or appyToIntersectedGeoemtry(ResourceList &resources).

Author
2015-04-02 Kris Becker
Parameters
nstepsNumber of steps to set for progress
textOptional text to set progress message to
Returns
bool True if progress is initialized based upon user preference

Definition at line 1118 of file Strategy.cpp.

References doShowProgress(), Isis::PvlFlatMap::get(), getDefinitionMap(), m_progress, name(), resetProcessed(), Isis::toBool(), and type().

Referenced by applyToIntersectedGeometry(), applyToResources(), and Strategy().

◆ isApplyToDiscarded()

bool Isis::Strategy::isApplyToDiscarded ( ) const
protected

Accessor for the apply discarded variable.

Returns
bool Indicates whether the object will apply strategy algorithms to discarded resources.

Definition at line 332 of file Strategy.cpp.

References m_applyDiscarded.

Referenced by applyToResources().

◆ isDebug()

bool Isis::Strategy::isDebug ( ) const
protected

An accessor method so that inherited classes can determine whether to print debug messages for this object.

Returns
bool Indicates whether to print debug messages for this object.

Definition at line 1080 of file Strategy.cpp.

References m_debug.

Referenced by apply(), applyToIntersectedGeometry(), and importGeometry().

◆ name()

QString Isis::Strategy::name ( ) const

Accessor method to get the name of the strategy.

Returns
QString A string containing the strategy's name.

Definition at line 118 of file Strategy.cpp.

References m_name.

Referenced by applyToIntersectedGeometry(), assetResourceList(), description(), importGeometry(), initProgress(), and setName().

◆ processArgs()

QString Isis::Strategy::processArgs ( const QString &  value,
const QStringList argKeys,
const ResourceList globals,
const QString &  defValue = "" 
) const
protected

Processes the given string value using the given argument list, resource and default resource.

For each argument in the given list, the target string "%i" (where i is the argument number) is replaced with the resource's keyword value corresponding to the argument. If this value doesn't exist, then the default resource's keyword value is used. If both fail, then the target string is replaced with "NULL"

Parameters
valueA keyword value to modified using the given argument list and resources.
argKeysA list of string arguments representing the resource values to be found in the resource's PVL flat map.
globalsA list of resources that will be searched.
defValueA pointer to the default resource whose PVL flat map will be searched for the arguments if they are not found in the main resource PVL flat map.
Returns
QString The modified string value.

Definition at line 587 of file Strategy.cpp.

References findReplacement(), and scanAndReplace().

Referenced by importGeometry(), and translateKeywordArgs().

◆ processed()

unsigned int Isis::Strategy::processed ( )
protected

Increments the total number of resources processed and returns the incremented value.

Returns
int The number of resources processed.

Definition at line 381 of file Strategy.cpp.

References doShowProgress(), m_progress, and m_total.

Referenced by applyToIntersectedGeometry(), and applyToResources().

◆ propagateKeys()

void Isis::Strategy::propagateKeys ( SharedResource source,
SharedResource target 
) const
protected

Adds the PVL definition keywords from the source to the target.

This creates a PVL flat map from the definition pvl. All of the keywords in the map that are also in the source resource are added to the target resource.

Parameters
sourceA reference to the resource to be copied from.
targetA reference to the resource to be added to.

Definition at line 610 of file Strategy.cpp.

References Isis::PvlFlatMap::allValues(), and getDefinitionMap().

◆ qualifiers()

QStringList Isis::Strategy::qualifiers ( const QString &  keyspec,
const QString &  delimiter = "::" 
) const
protected

Splits the given keyspec string into a list using the given delimiter string.

Parameters
keyspecThe string to be split.
delimiterA string containing the characters used to specify the boundary by which to split the string.
Returns
QStringList The list of strings that were split from the given keyspec string using the given delimiter string.

Definition at line 494 of file Strategy.cpp.

◆ queryCallback()

void Isis::Strategy::queryCallback ( void *  item,
void *  userdata 
)
staticprotected

Important GEOS query callback for class and overlap geometry.

This method accumulates the resources that are determined to potentially overlap the resource geometry provided in the GEOS query.

This implementation may not be portable or safe. It most certainly is not threadable. (I am open for suggestions on how to do this better...)

Author
2015-03-27 Kris Becker
Parameters
itemResource to add to overlap list
userdataResourceList to contain overlapping geoemetries

Definition at line 1066 of file Strategy.cpp.

Referenced by applyToIntersectedGeometry().

◆ resetProcessed()

void Isis::Strategy::resetProcessed ( )
protected

Resets the total number of processed resources to zero.

Definition at line 394 of file Strategy.cpp.

References m_total.

Referenced by initProgress().

◆ scanAndReplace()

QString Isis::Strategy::scanAndReplace ( const QString &  input,
const QString &  target,
const QString &  replacement 
) const
protected

Performs a case insensitive scan of the input string for a substring matching the target string and replaces the target substring with the replacement string.

Parameters
inputThe input string to be modified.
targetThe string pattern to find in the input string.
replacementThe string pattern that will replace the target string pattern.
Returns
QString The modified string.

Definition at line 513 of file Strategy.cpp.

Referenced by processArgs().

◆ setApplyToDiscarded()

void Isis::Strategy::setApplyToDiscarded ( )
protected

Sets Resource as discarded.

This mutator tells the object to not apply strategy algorithms to discarded resources.

Definition at line 320 of file Strategy.cpp.

References m_applyDiscarded.

◆ setDoNotApplyToDiscarded()

void Isis::Strategy::setDoNotApplyToDiscarded ( )
protected

Disables the general application of Strategy algorithm for all Resources regardless of state.

Definition at line 341 of file Strategy.cpp.

References m_applyDiscarded.

◆ setName()

void Isis::Strategy::setName ( const QString &  name)
protected

Allow derived strategies to reset name (mostly for default constructors)

Parameters
Astring containing the new name of the strategy.

Definition at line 138 of file Strategy.cpp.

References m_name, and name().

◆ setType()

void Isis::Strategy::setType ( const QString &  type)
protected

Allow derived strategies to reset type (mostly for default constructors)

Parameters
Astring containing the new type of the strategy.

Definition at line 150 of file Strategy.cpp.

References m_type, and type().

◆ totalProcessed()

unsigned int Isis::Strategy::totalProcessed ( ) const

Accessor for the total number of resources processed.

Returns
unsigned int The number of resources processed.

Definition at line 311 of file Strategy.cpp.

References m_total.

◆ translateKeywordArgs()

QString Isis::Strategy::translateKeywordArgs ( const QString &  keyBase,
const ResourceList globals,
const QString &  defValue = "" 
) const
protected

Translates the arguments of the PVL keyword in the PVL definition object.

This method uses the keyBase string to get the keyword value and populate the argument replacement list. The keyword value is then modified by passing it to processArgs() along with using the argument list, resource, and default resource pointers.

If a keyword does not exist, the string provided by defValue is returned. The empty string is returned in the event that defValue is not given an argument.

Parameters
keyBaseA string containing the base of the keyword name.
globalsA list of resources that will be searched.
defValueThe default value to return if the keyBase does not exist
Returns
QString A modified keyword value with appropriate arguments inserted into the appropriate locations.

Definition at line 539 of file Strategy.cpp.

References Isis::PvlFlatMap::allValues(), Isis::PvlFlatMap::exists(), Isis::PvlFlatMap::get(), getDefinitionMap(), and processArgs().

Referenced by importGeometry().

◆ type()

QString Isis::Strategy::type ( ) const

Accessor method to get the type of strategy.

Returns
QString A string containing the strategy's type.

Definition at line 128 of file Strategy.cpp.

References m_type.

Referenced by applyToIntersectedGeometry(), description(), importGeometry(), initProgress(), and setType().

Member Data Documentation

◆ m_applyDiscarded

bool Isis::Strategy::m_applyDiscarded
private

Indicates whether to apply strategy to discarded resources.

This value is initialized to false if not found in the Pvl definition object.

Definition at line 233 of file Strategy.h.

Referenced by isApplyToDiscarded(), setApplyToDiscarded(), setDoNotApplyToDiscarded(), and Strategy().

◆ m_debug

bool Isis::Strategy::m_debug
private

Indicates whether to print debug messages.

This value is initialized to false if not found in the Pvl definition object.

Definition at line 236 of file Strategy.h.

Referenced by isDebug(), and Strategy().

◆ m_definition

SharedPvlObject Isis::Strategy::m_definition
private

A shared pointer to the PvlObject that defines the strategy.

If a definition PvlObject is not passed in on construction, then a pointer to an empty PvlObject is created using the strategy name. See class documentation for an example.

Definition at line 216 of file Strategy.h.

Referenced by description(), and getDefinitionMap().

◆ m_globals

ResourceList Isis::Strategy::m_globals
private

A shared pointer to the global Resource of keywords.

If not provided upon construction, it will be set to NULL. If a SharedResource is passed into the apply() method, this member is temporarily set to the given SharedResource and then restored. The apply() method can not be used as a mutator for this variable.

Definition at line 210 of file Strategy.h.

Referenced by getGlobalDefaults().

◆ m_name

QString Isis::Strategy::m_name
private

A string containing the name of the strategy.

This name is passed into the constructor directly or found in the Pvl definition object. If none is provided, the default name 'Strategy' is set.

Definition at line 221 of file Strategy.h.

Referenced by name(), setName(), and Strategy().

◆ m_progress

QScopedPointer<Progress> Isis::Strategy::m_progress
private

Progress percentage monitor.

Definition at line 239 of file Strategy.h.

Referenced by doShowProgress(), initProgress(), and processed().

◆ m_total

unsigned int Isis::Strategy::m_total
private

The total number of resources processed.

This value is initialized to zero, incremented by the applyToResources() or processed() methods, and can be reset to zero by calling resetProcessed().

Definition at line 229 of file Strategy.h.

Referenced by processed(), resetProcessed(), and totalProcessed().

◆ m_type

QString Isis::Strategy::m_type
private

A string containing the type of strategy.

This type is passed into the constructor directly or found in the Pvl definition object. If none is provided, the default type 'Counter' is set.

Definition at line 225 of file Strategy.h.

Referenced by setType(), Strategy(), and type().


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