File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
Strategy.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "Strategy.h"
8
9// Qt library
10#include <QScopedPointer>
11#include <QString>
12#include <QStringList>
13
14// boost library
15#include <boost/foreach.hpp>
16
17// other ISIS
18#include "IException.h"
19#include "GisGeometry.h"
20#include "Progress.h"
21#include "PvlFlatMap.h"
22#include "PvlObject.h"
23#include "Resource.h"
24
25using namespace std;
26
27namespace Isis {
28
34 m_name("Strategy"), m_type("Counter"),
35 m_total(0), m_applyDiscarded(false), m_debug(false),
36 m_progress() {
37 }
38
39
47 Strategy::Strategy(const QString &name, const QString &type) :
48 m_globals(),
51 m_applyDiscarded(false), m_debug(false), m_progress() {
52 }
53
54
76 Strategy::Strategy(const PvlObject &definition, const ResourceList &globals) :
77 m_globals(globals), m_definition(new PvlObject(definition)),
78 m_name("Strategy"), m_type("Unknown"),
79 m_total(0), m_applyDiscarded(false), m_debug(false), m_progress() {
81 m_name = parms.get("Name");
82 m_type = parms.get("Type");
83 m_applyDiscarded = toBool(parms.get("ApplyToDiscarded", "false"));
84 m_debug = toBool(parms.get("Debug", "false"));
86 }
87
88
94
95
101 QString Strategy::name() const {
102 return (m_name);
103 }
104
105
111 QString Strategy::type() const {
112 return (m_type);
113 }
114
115
121 void Strategy::setName(const QString &name) {
122 m_name = name;
123 return;
124 }
125
126
133 void Strategy::setType(const QString &type) {
134 m_type = type;
135 return;
136 }
137
138
147
148
159 const ResourceList &globals) const {
160
161#if 0
162 ResourceList v_globals(globals);
163 v_globals.append(myGlobals);
164#else
165 ResourceList v_globals;
166 v_globals.push_back(myGlobals);
167 v_globals.append(globals);
168#endif
169 return ( v_globals );
170 }
171
172
173 const PvlObject &Strategy::getDefinition() const {
174 return (*m_definition);
175 }
176
177
188
189
201 QString Strategy::description() const {
202 if ( m_definition->hasKeyword("Description") ) {
203 return (m_definition->findKeyword("Description")[0]);
204 }
205 else {
206 QString descr = "Strategy::" + name() + " is running a " + type() +
207 " algorithm.";
208 return (descr);
209 }
210 }
211
212
226 return ( apply(resources, getGlobalDefaults()) );
227 }
228
229
243 return ( apply( resource, getGlobalDefaults()) );
244 }
245
246
268 int Strategy::apply(ResourceList &resources, const ResourceList &globals) {
269 return ( applyToResources(resources, globals) );
270 }
271
272
281 int Strategy::apply(SharedResource &resource, const ResourceList &globals) {
282 if ( isDebug() ) {
283 cout << "Empty apply is called...\n";
284 }
285 return (1);
286 }
287
288
294 unsigned int Strategy::totalProcessed() const {
295 return (m_total);
296 }
297
298
304 m_applyDiscarded = true;
305 return;
306 }
307
308
316 return (m_applyDiscarded);
317 }
318
319
325 m_applyDiscarded = false;
326 return;
327 }
328
329
337 int Strategy::applyToResources(ResourceList &resources, const ResourceList &globals) {
338
339 initProgress( ( isApplyToDiscarded() ) ? resources.size() : countActive(resources) );
340
341 int result = 0;
342 BOOST_FOREACH ( SharedResource resource, resources ) {
343 if ( resource->isDiscarded() ) {
344 if (true == isApplyToDiscarded() ) {
345 result += apply(resource, globals);
346 processed();
347 }
348 }
349 else {
350 result += apply(resource, globals);
351 processed();
352 }
353 }
354 return (result);
355 }
356
357
364 unsigned int Strategy::processed() {
365 m_total++;
366 if ( doShowProgress() && !m_progress.isNull() ) {
367 m_progress->CheckStatus();
368 }
369
370 return (m_total);
371 }
372
373
378 m_total = 0;
379 return;
380 }
381
382
392 int Strategy::countActive(const ResourceList &resources) const {
393 return ( resources.size() - countDiscarded(resources) );
394 }
395
396
406 int Strategy::countDiscarded(const ResourceList &resources) const {
407 int n = 0;
408 BOOST_FOREACH ( SharedResource resource, resources ) {
409 if ( resource->isDiscarded() ) { n++; }
410 }
411 return (n);
412 }
413
414
425 const QString &name) const {
426 ResourceList alist;
427 if ( resource->hasAsset(name) ) {
428 QVariant v_asset = resource->asset(name);
429 if ( v_asset.canConvert<ResourceList>() ) {
430 alist = v_asset.value<ResourceList>();
431 }
432 }
433
434 return (alist);
435 }
436
437
450 QString Strategy::findReplacement(const QString &target,
451 const ResourceList &globals,
452 const int &index,
453 const QString &defValue) const {
454 BOOST_FOREACH ( const SharedResource keystore, globals ) {
455 if ( keystore->exists(target) ) {
456 if ( keystore->count(target) > index ) {
457 return (keystore->value(target, index));
458 }
459 }
460 }
461
462 return ( defValue );
463 }
464
465
477 QStringList Strategy::qualifiers(const QString &keyspec,
478 const QString &delimiter) const {
479 QStringList parts = keyspec.split(delimiter);
480 return (parts);
481 }
482
483
496 QString Strategy::scanAndReplace(const QString &input, const QString &target,
497 const QString &replacement) const {
498 QString str(input);
499 str.replace(target, replacement, Qt::CaseInsensitive);
500 return (str);
501 }
502
503
522 QString Strategy::translateKeywordArgs(const QString &keyBase,
523 const ResourceList &globals,
524 const QString &defValue) const {
525
526 // Get keyword configuration from definition
528
529 QStringList idArgs; // Argument replacement list
530 QString value;
531
532 QString keyword = keyBase + "Keyword";
533 if ( keys.exists(keyword) ) {
534 idArgs.push_back(keys.get(keyword));
535 value = keys.get(keyBase, "%1");
536 }
537 else {
538 if ( keys.exists(keyBase + "Args") ) {
539 idArgs = keys.allValues(keyBase + "Args");
540 }
541 value = keys.get(keyBase, defValue);
542 }
543
544 return (processArgs(value, idArgs, globals, defValue));
545 }
546
547
570 QString Strategy::processArgs(const QString &value, const QStringList &argKeys,
571 const ResourceList &globals,
572 const QString &defValue) const {
573
574 QString result = value;
575 int i = argKeys.size();
576 BOOST_REVERSE_FOREACH ( QString arg, argKeys ) {
577 QString target("%"+QString::number(i));
578 result = scanAndReplace(result, target, findReplacement(arg,globals,0,defValue));
579 i--;
580 }
581 return (result);
582 }
583
584
594 const {
596 QStringList keySources = keys.allValues("PropagateKeywords");
597 BOOST_FOREACH ( QString key, keySources ) {
598 if ( source->exists(key) ) {
599 target->add(source->keyword(key));
600 }
601 }
602 return;
603 }
604
605
634 SharedResource &resourceB,
635 const QPair<QString, QString> &keySuffix)
636 const {
637
638 // Create the new resource
639 QString id = resourceA->name() + "_" + resourceB->name();
641
642 // See if user wants to restrict keyword propagation to a list
643 QStringList keySources = PvlFlatMap( getDefinitionMap() ).allValues("PropagateKeywords");
644 if ( !keySources.isEmpty() ) {
645 // Propogate only specified keywords from each Resource
646 BOOST_FOREACH ( QString key, keySources ) {
647 if ( resourceA->exists(key) ) {
648 PvlKeyword keyword(resourceA->keyword(key));
649 keyword.setName(keyword.name().append(keySuffix.first));
650 composite->add(keyword);
651 }
652
653 if ( resourceB->exists(key) ) {
654 PvlKeyword keyword(resourceB->keyword(key));
655 keyword.setName(keyword.name().append(keySuffix.second));
656 composite->add(keyword);
657 }
658 }
659 }
660 else {
661 // Propagate all keys from each source to the composite Resource
662 const PvlFlatMap &rkeysA = resourceA->keys();
663 PvlFlatMap::ConstPvlFlatMapIterator pkeys = rkeysA.begin();
664 while ( rkeysA.constEnd() != pkeys) {
665 PvlKeyword keyword(pkeys.value());
666 keyword.setName(keyword.name().append(keySuffix.first));
667 composite->add(keyword);
668 ++pkeys;
669 }
670
671 const PvlFlatMap &rkeysB = resourceB->keys();
672 pkeys = rkeysB.begin();
673 while ( rkeysB.constEnd() != pkeys) {
674 PvlKeyword keyword(pkeys.value());
675 keyword.setName(keyword.name().append(keySuffix.second));
676 composite->add(keyword);
677 ++pkeys;
678 }
679 }
680 return (composite);
681 }
682
683
705 const ResourceList &globals) const {
707
708 // Assume a specific geometry is present
709 QString geom(keys.get("GisGeometry", ""));
710
711 QString giskey;
712 if ( keys.exists("GisGeometryRef") ) { giskey = keys.get("GisGeometryRef"); }
713 if ( keys.exists("GisGeometryKey") ) { giskey = keys.get("GisGeometryKey"); }
714
715 if ( !giskey.isEmpty() ) {
716 if ( !resource->isNull(giskey) ) {
717 geom = resource->value(giskey);
718
719 // Erase key if requested
720 if ( toBool(keys.get("RemoveGisKeywordAfterImport", "false")) ) {
721 resource->erase(giskey);
722 }
723 }
724 }
725
726 // Got a geometry.
727 if ( !geom.isEmpty() ) {
728
729 // Get decision keys
730 bool repairGeom = toBool(keys.get("RepairInvalidGeometry", "true"));
731
732 QString geomAction = keys.get("InvalidGeometryAction", "disable").toLower();
733 if ( !QString("disable error continue").contains(geomAction) ) {
734 if ( isDebug() ) {
735 cout << " Invalid value for InvalidGeometryAction (" << geomAction
736 << ") - set to disable!\n";
737 }
738 geomAction = "disable";
739 }
740
741 // Process arguments Allows creation specialized geometry as well
742 if ( keys.exists("GisGeometryArgs") ) {
743 QStringList args = keys.allValues("GisGeometryArgs");
744 geom = processArgs(geom, args, getGlobals(resource, globals));
745 }
746
747 // Get the type
748 QString gisType = keys.get("GisType");
749 int npoints(0);
750 int npointsOrg(0);
751 double tolerance(0.0);
752
753 // Check for Geometry. May want to remove it after parsing/conversion.
754 // These text geometries tend to be huge and consume lots of memory.
755 if ( !geom.isEmpty() ) {
756
757 QScopedPointer<GisGeometry> geosgeom(new GisGeometry(geom, GisGeometry::type(gisType)));
758 if ( geosgeom.isNull() ) {
759 if ( isDebug() ) {
760 cout << resource->name() << " geometry failed to construct\n";
761 }
762 if ("continue" == geomAction) return (false);
763 if ( "disable" == geomAction ) {
764 resource->discard();
765 return ( false );
766 }
767
768 // Throw an error
769 QString mess = resource->name() + " failed to construct geometry!";
770 throw IException(IException::Programmer, mess, _FILEINFO_);
771 }
772
773 // Check validity and take appropriate action
774 if ( !geosgeom->isValid() ) {
775
776 QString geomError = geosgeom->isValidReason();
777 if ( isDebug() ) {
778 cout << " Geometry error: " << geomError << "\n";
779 }
780
781 // Attempt repair if requested
782 if ( repairGeom ) {
783 if (isDebug()) {
784 cout << " " << resource->name() << " geometry is invalid..."
785 << "attempting buffer(0) to fix it!\n";
786 }
787 geosgeom.reset( geosgeom->buffer(0) );
788 if ( isDebug() ) {
789 if (geosgeom.isNull() || !geosgeom->isValid() ) {
790 cout << " Geometry could not be repaired!\n";
791 }
792 else {
793 cout << " Geometry was successfully repaired!\n";
794 }
795 }
796 }
797
798 // Now check state and take final action regarding a failed
799 // geometry
800
801 if (geosgeom.isNull() || !geosgeom->isValid() ) {
802 if ( isDebug() ) {
803 cout << " All efforts to convert geometry failed!\n";
804 }
805 if ("continue" == geomAction) return (false);
806 if ( "disable" == geomAction ) {
807 resource->discard();
808 return ( false );
809 }
810
811 // Throw an error
812 QString mess = resource->name() + " failed to construct geometry - Error: " +
813 geomError;
814 throw IException(IException::Programmer, mess, _FILEINFO_);
815 }
816 }
817
818 npointsOrg = npoints = geosgeom->points();
819 QString gisTolerance = translateKeywordArgs("GisSimplifyTolerance",
820 getGlobals(resource, globals), "");
821
822 if ( !gisTolerance.isEmpty() ) {
823 tolerance = toDouble(gisTolerance);
824 GisGeometry *simple = geosgeom->simplify(tolerance);
825 if ( 0 != simple ) geosgeom.reset(simple);
826 npoints = geosgeom->points();
827 }
828
829 resource->add(geosgeom.take());
830
831 // Add the geometry point count to the resource if requested
832 QString pointsKey = translateKeywordArgs("GisGeometryPointsKey",
833 getGlobals(resource, globals),
834 "");
835 if ( !pointsKey.isEmpty() ) {
836 resource->add(pointsKey, toString(npoints));
837 resource->add(pointsKey+"Original", toString(npointsOrg));
838 resource->add(pointsKey+"Tolerance", toString(tolerance));
839 }
840
841 // Status if requested
842 if ( isDebug() ) {
843 cout << " " << type() << ":" << name() << " has a geometry with "
844 << npoints << " points!\n";
845 if ( npoints != npointsOrg ) {
846 cout << " Geometry has been simplified/reduced from original "
847 << npointsOrg << " points.\n";
848 }
849 }
850 return (true);
851 }
852 }
853
854 // Report geometry status
855 if ( isDebug() ) {
856 cout << " " << type() << ":" << name() << " does not have a geometry!\n";
857 }
858
859 return (false);
860 }
861
862
871 // Create a list of active resources
872 ResourceList v_active;
873 BOOST_FOREACH ( SharedResource resource, resources ) {
874 if ( !resource->isDiscarded() ) { v_active.append(resource); }
875 }
876 return (v_active);
877 }
878
879
885 void Strategy::activateList(ResourceList &resources) const {
886 BOOST_FOREACH ( SharedResource resource, resources ) {
887 resource->activate();
888 }
889 }
890
891
897 void Strategy::deactivateList(ResourceList &resources) const {
898 BOOST_FOREACH ( SharedResource resource, resources ) {
899 resource->discard();
900 }
901 }
902
903
925 ResourceList v_copy;
926 BOOST_FOREACH ( SharedResource resource, resources ) {
927 v_copy.append(SharedResource(resource->copy()));
928 }
929 return ( v_copy);
930 }
931
932
953 const bool &withAssets) const {
954 ResourceList v_clone;
955 BOOST_FOREACH ( SharedResource resource, resources ) {
956 v_clone.append(SharedResource(resource->clone(resource->name(), withAssets)));
957 }
958 return ( v_clone );
959 }
960
961
1000 GisGeometry &geom,
1001 const ResourceList &globals) {
1002
1003 QString method = getDefinitionMap().get("GisMethod", "direct").toLower();
1004
1005 // The programmer is required to ensure a valid geometry provides the
1006 // source of the intersection operation.
1007 if ( !geom.isValid() ) {
1008 QString mess = type() + ":" + name() +
1009 "Cannot apply RTree search to bad geometry.";
1010 throw IException(IException::Programmer, mess, _FILEINFO_);
1011 }
1012
1013 // Create a list of active resources only
1014 ResourceList v_active = activeList(resources);
1015
1016 // Use direct computation method
1017 ResourceList overlaps;
1018 if ( "direct" == method ) {
1019 if ( isDebug() ) {
1020 cout << "Using direct Geom intersects for " << v_active.size() << " geometries...\n";
1021 }
1022
1023 // Direct intersect computations of overlaps has about the same overhead
1024 // of constructing an RTree index and running queries.
1025 initProgress(v_active.size());
1026 BOOST_FOREACH ( SharedResource resource, v_active ) {
1027 if ( resource->hasValidGeometry() ) {
1028 if ( geom.intersects( *resource->geometry()) ) {
1029 overlaps.append(resource);
1030 }
1031 }
1032 processed();
1033 }
1034 }
1035 else {
1036
1037 // Use RTree method to get potenital overlappers...
1038 if ( isDebug() ) {
1039 cout << "Allocating " << v_active.size() << " RTree geometries.\n";
1040 }
1041 GEOSSTRtree *rtree = GEOSSTRtree_create(v_active.size());
1042 if ( !rtree ) {
1043 QString mess = "GEOS RTree allocation failed for " +
1044 toString(v_active.size()) + " geometries.";
1045 throw IException(IException::Programmer, mess, _FILEINFO_);
1046 }
1047
1048 if ( isDebug() ) {
1049 cout << "GEOS RTree allocated " << v_active.size() << " geometry entries.\n";
1050 }
1051
1052 // Create and query the RTree geometries calling once for each
1053 // strategy::appy(SharedResource &) geometry that intersect the envelope.
1054 initProgress(v_active.size());
1055 int nvalid = 0;
1056 for ( int i = 0 ; i < v_active.size() ; i++ ) {
1057 if ( v_active[i]->hasValidGeometry() ) {
1058 GEOSSTRtree_insert(rtree, v_active[i]->geometry()->geometry(),
1059 &v_active[i]);
1060 nvalid++;
1061 }
1062 processed();
1063 }
1064
1065 // Report number found...
1066 if ( isDebug() ) {
1067 cout << "Valid Geometries found: " << nvalid << " - running query...\n";
1068 }
1069
1070 // Run the query
1071 GEOSSTRtree_query(rtree, geom.geometry(), &queryCallback, &overlaps);
1072 GEOSSTRtree_destroy(rtree);
1073 }
1074
1075 if ( isDebug() ) {
1076 cout << "Potential Intersections Found: " << overlaps.size() << "\n";
1077 }
1078
1079
1080 // Now apply all intersected geometries to calling strategy. Note to
1081 // properly reflect the intersected list, we must deactivate the entire
1082 // active list after the query search and activate each one prior to
1083 // applying it in the strategy method, which has the responsibility to
1084 // determine validity, and return the proper Resource list status to the
1085 // next strategy.
1086 deactivateList(v_active);
1087
1088 initProgress(overlaps.size());
1089 int n = 0; // Result count
1090 BOOST_FOREACH ( SharedResource resource, overlaps ) {
1091 resource->activate();
1092 n += apply(resource, globals);
1093 processed();
1094 }
1095
1096
1097 if ( isDebug() ) {
1098 cout << "Total valid Intersections Found: " << n << "\n";
1099 }
1100
1101 return (n);
1102 }
1103
1104
1119 void Strategy::queryCallback(void *item, void *userdata) {
1120 SharedResource *resource = (SharedResource *) item; // Maybe fancy casts?
1121 ResourceList *rlist = (ResourceList *) userdata;
1122 rlist->append(*resource);
1123 return;
1124 }
1125
1126
1133 bool Strategy::isDebug() const {
1134 return ( m_debug );
1135 }
1136
1137
1143 return ( !m_progress.isNull() );
1144 }
1145
1146
1147
1171 bool Strategy::initProgress(const int &nsteps, const QString &text) {
1172
1173 QString p_text = text;
1175 bool status = false;
1176
1177 // Check for initialization
1178 if ( !doShowProgress() ) {
1179 PvlFlatMap p_var( getDefinitionMap() );
1180 if ( toBool(p_var.get("ShowProgress", "false")) ) {
1181 m_progress.reset( new Progress() );
1182 if ( p_text.isEmpty() ) {
1183 p_text = type() + "::" + name();
1184 }
1185 }
1186 }
1187
1188
1189 // No check if progress is requested
1190 if ( doShowProgress() ) {
1191 if ( !p_text.isEmpty() ) m_progress->SetText(p_text);
1192 m_progress->SetMaximumSteps(nsteps);
1193 if ( nsteps > 0 ) m_progress->CheckStatus();
1194 status = true;
1195 }
1196
1197 // Set up for systematic processing
1198 return (status);
1199 }
1200
1201
1202 QStringList Strategy::getObjectList(const PvlObject &source) const {
1203 QStringList objList;
1204 PvlObject::ConstPvlObjectIterator object = source.beginObject();
1205 while ( object != source.endObject() ) {
1206 objList << object->name();
1207 ++object;
1208 }
1209 return (objList);
1210 }
1211
1212
1213} //namespace Isis
Encapsulation class provides support for GEOS-C API.
Definition GisGeometry.h:55
Type type() const
Returns the type (origin) of the geometry.
bool intersects(const GisGeometry &target) const
Computes a new geometry from the intersection of the two geomtries.
const GEOSGeometry * geometry() const
Returns the GEOSGeometry object to extend functionality.
bool isValid() const
Determines validity of the geometry contained in this object.
GisGeometry * simplify(const double &tolerance) const
Simplify complex or overdetermined geoemtry.
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
Program progress reporter.
Definition Progress.h:42
static PvlConstraints withExcludes(const QStringList &excludes)
Static method to construct a PvlConstraints object from a list of names for the PvlObjects and PvlGro...
Provides a flat map of PvlKeywords.
Definition PvlFlatMap.h:218
QStringList allValues(const QString &key) const
Gets all the values associated with a keyword in the PvlFlatMap.
QString get(const QString &key, const int &index=0) const
Gets the value of a keyword in the PvlFlatMap.
bool exists(const QString &key) const
Determines whether a given keyword exists in the PvlFlatMap.
QMap< QString, PvlKeyword >::const_iterator ConstPvlFlatMapIterator
A const iterator for the underling QMap that PvlFlatMap is built on.
Definition PvlFlatMap.h:222
A single keyword-value pair.
Definition PvlKeyword.h:87
void setName(QString name)
Sets the keyword name.
QString name() const
Returns the keyword name.
Definition PvlKeyword.h:103
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
PvlObjectIterator beginObject()
Returns the index of the beginning object.
Definition PvlObject.h:235
PvlObjectIterator endObject()
Returns the index of the ending object.
Definition PvlObject.h:253
This class provides a resource of PVL keywords for Strategy classes.
Definition Resource.h:54
static void queryCallback(void *item, void *userdata)
Important GEOS query callback for class and overlap geometry.
QString type() const
Accessor method to get the type of strategy.
Definition Strategy.cpp:111
int apply(ResourceList &resources)
Apply algorithm to resource list.
Definition Strategy.cpp:225
QScopedPointer< Progress > m_progress
Progress percentage monitor.
Definition Strategy.h:229
unsigned int totalProcessed() const
Accessor for the total number of resources processed.
Definition Strategy.cpp:294
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 r...
Definition Strategy.cpp:496
void propagateKeys(SharedResource &source, SharedResource &target) const
Adds the PVL definition keywords from the source to the target.
Definition Strategy.cpp:593
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.
Definition Strategy.cpp:570
int countActive(const ResourceList &resources) const
Counts the number of active (i.e.
Definition Strategy.cpp:392
virtual ~Strategy()
Destroys the Strategy object.
Definition Strategy.cpp:92
Strategy()
Constructs default Strategy object of name "Strategy" and type "Counter".
Definition Strategy.cpp:33
void setApplyToDiscarded()
Sets Resource as discarded.
Definition Strategy.cpp:303
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.
Definition Strategy.cpp:633
int applyToIntersectedGeometry(ResourceList &resources, GisGeometry &geom, const ResourceList &globals)
Identify and apply Strategy to Resources that intersect a geometry.
Definition Strategy.cpp:999
void deactivateList(ResourceList &resources) const
Deactivate all resources contained in the resource list.
Definition Strategy.cpp:897
PvlFlatMap getDefinitionMap() const
Returns the keyword definitions found in the Strategy object.
Definition Strategy.cpp:185
int countDiscarded(const ResourceList &resources) const
Counts the number of non-active (i.e.
Definition Strategy.cpp:406
QString name() const
Accessor method to get the name of the strategy.
Definition Strategy.cpp:101
bool importGeometry(SharedResource &resource, const ResourceList &globals) const
Imports a geometry from the given resource.
Definition Strategy.cpp:704
ResourceList m_globals
A shared pointer to the global Resource of keywords.
Definition Strategy.h:200
ResourceList getGlobalDefaults() const
Accessor method to get the global defaults.
Definition Strategy.cpp:144
QString m_name
A string containing the name of the strategy.
Definition Strategy.h:211
QString findReplacement(const QString &target, const ResourceList &globals, const int &index=0, const QString &defValue="") const
Find keyword replacement value in globals list.
Definition Strategy.cpp:450
QString description() const
Return description for the strategy.
Definition Strategy.cpp:201
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,...
Definition Strategy.cpp:424
unsigned int processed()
Increments the total number of resources processed and returns the incremented value.
Definition Strategy.cpp:364
QString m_type
A string containing the type of strategy.
Definition Strategy.h:215
ResourceList copyList(const ResourceList &resources) const
Make a copy of the resource list that is independently managed.
Definition Strategy.cpp:924
int applyToResources(ResourceList &resources, const ResourceList &globals)
Applies the strategy algorithms to the resources in the given list.
Definition Strategy.cpp:337
QString translateKeywordArgs(const QString &value, const ResourceList &globals, const QString &defValue="") const
Translates the arguments of the PVL keyword in the PVL definition object.
Definition Strategy.cpp:522
void setName(const QString &name)
Allow derived strategies to reset name (mostly for default constructors)
Definition Strategy.cpp:121
ResourceList getGlobals(SharedResource &myGlobals, const ResourceList &globals) const
Definition Strategy.cpp:158
ResourceList activeList(ResourceList &resources) const
Get list of all active Resources only - no discarded Resources.
Definition Strategy.cpp:870
QStringList qualifiers(const QString &keyspec, const QString &delimiter="::") const
Splits the given keyspec string into a list using the given delimiter string.
Definition Strategy.cpp:477
void activateList(ResourceList &resources) const
Activate all resources contained in the resource list.
Definition Strategy.cpp:885
void setDoNotApplyToDiscarded()
Disables the general application of Strategy algorithm for all Resources regardless of state.
Definition Strategy.cpp:324
bool doShowProgress() const
ResourceList cloneList(const ResourceList &resources, const bool &withAssets=false) const
Create a clone of a Resource list.
Definition Strategy.cpp:952
bool isApplyToDiscarded() const
Accessor for the apply discarded variable.
Definition Strategy.cpp:315
bool isDebug() const
An accessor method so that inherited classes can determine whether to print debug messages for this o...
void setType(const QString &type)
Allow derived strategies to reset type (mostly for default constructors)
Definition Strategy.cpp:133
bool initProgress(const int &nsteps=0, const QString &text="")
Initializes strategy progress monitor if requested by user.
unsigned int m_total
The total number of resources processed.
Definition Strategy.h:219
SharedPvlObject m_definition
A shared pointer to the PvlObject that defines the strategy.
Definition Strategy.h:206
bool m_applyDiscarded
Indicates whether to apply strategy to discarded resources.
Definition Strategy.h:223
bool m_debug
Indicates whether to print debug messages.
Definition Strategy.h:226
void resetProcessed()
Resets the total number of processed resources to zero.
Definition Strategy.cpp:377
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
QList< SharedResource > ResourceList
Defintion of a ResourceList, a list of SharedResource types.
Definition Resource.h:169
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition IString.cpp:38
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
QSharedPointer< Resource > SharedResource
Defintion of a SharedResource, a shared pointer to a Resource object.
Definition Resource.h:166
Namespace for the standard library.
This is free and unencumbered software released into the public domain.