Isis 3 Programmer Reference
Strategy.cpp
Go to the documentation of this file.
1 
24 #include "Strategy.h"
25 
26 // Qt library
27 #include <QScopedPointer>
28 #include <QString>
29 #include <QStringList>
30 
31 // boost library
32 #include <boost/foreach.hpp>
33 
34 // other ISIS
35 #include "IException.h"
36 #include "GisGeometry.h"
37 #include "Progress.h"
38 #include "PvlFlatMap.h"
39 #include "PvlObject.h"
40 #include "Resource.h"
41 
42 using namespace std;
43 
44 namespace Isis {
45 
50  Strategy::Strategy() : m_globals(), m_definition(new PvlObject("Strategy")),
51  m_name("Strategy"), m_type("Counter"),
52  m_total(0), m_applyDiscarded(false), m_debug(false),
53  m_progress() {
54  }
55 
56 
64  Strategy::Strategy(const QString &name, const QString &type) :
65  m_globals(),
66  m_definition(new PvlObject(name)),
67  m_name(name), m_type(type), m_total(0),
68  m_applyDiscarded(false), m_debug(false), m_progress() {
69  }
70 
71 
93  Strategy::Strategy(const PvlObject &definition, const ResourceList &globals) :
94  m_globals(globals), m_definition(new PvlObject(definition)),
95  m_name("Strategy"), m_type("Unknown"),
96  m_total(0), m_applyDiscarded(false), m_debug(false), m_progress() {
98  m_name = parms.get("Name");
99  m_type = parms.get("Type");
100  m_applyDiscarded = toBool(parms.get("ApplyToDiscarded", "false"));
101  m_debug = toBool(parms.get("Debug", "false"));
102  initProgress();
103  }
104 
105 
110  }
111 
112 
118  QString Strategy::name() const {
119  return (m_name);
120  }
121 
122 
128  QString Strategy::type() const {
129  return (m_type);
130  }
131 
132 
138  void Strategy::setName(const QString &name) {
139  m_name = name;
140  return;
141  }
142 
143 
150  void Strategy::setType(const QString &type) {
151  m_type = type;
152  return;
153  }
154 
155 
162  return (m_globals);
163  }
164 
165 
176  const ResourceList &globals) const {
177 
178 #if 0
179  ResourceList v_globals(globals);
180  v_globals.append(myGlobals);
181 #else
182  ResourceList v_globals;
183  v_globals.push_back(myGlobals);
184  v_globals.append(globals);
185 #endif
186  return ( v_globals );
187  }
188 
189 
190  const PvlObject &Strategy::getDefinition() const {
191  return (*m_definition);
192  }
193 
194 
203  return ( PvlFlatMap(*m_definition, PvlConstraints::withExcludes(getObjectList(*m_definition))) );
204  }
205 
206 
218  QString Strategy::description() const {
219  if ( m_definition->hasKeyword("Description") ) {
220  return (m_definition->findKeyword("Description")[0]);
221  }
222  else {
223  QString descr = "Strategy::" + name() + " is running a " + type() +
224  " algorithm.";
225  return (descr);
226  }
227  }
228 
229 
242  int Strategy::apply(ResourceList &resources) {
243  return ( apply(resources, getGlobalDefaults()) );
244  }
245 
246 
260  return ( apply( resource, getGlobalDefaults()) );
261  }
262 
263 
285  int Strategy::apply(ResourceList &resources, const ResourceList &globals) {
286  return ( applyToResources(resources, globals) );
287  }
288 
289 
298  int Strategy::apply(SharedResource &resource, const ResourceList &globals) {
299  if ( isDebug() ) {
300  cout << "Empty apply is called...\n";
301  }
302  return (1);
303  }
304 
305 
311  unsigned int Strategy::totalProcessed() const {
312  return (m_total);
313  }
314 
315 
321  m_applyDiscarded = true;
322  return;
323  }
324 
325 
333  return (m_applyDiscarded);
334  }
335 
336 
342  m_applyDiscarded = false;
343  return;
344  }
345 
346 
354  int Strategy::applyToResources(ResourceList &resources, const ResourceList &globals) {
355 
356  initProgress( ( isApplyToDiscarded() ) ? resources.size() : countActive(resources) );
357 
358  int result = 0;
359  BOOST_FOREACH ( SharedResource resource, resources ) {
360  if ( resource->isDiscarded() ) {
361  if (true == isApplyToDiscarded() ) {
362  result += apply(resource, globals);
363  processed();
364  }
365  }
366  else {
367  result += apply(resource, globals);
368  processed();
369  }
370  }
371  return (result);
372  }
373 
374 
381  unsigned int Strategy::processed() {
382  m_total++;
383  if ( doShowProgress() && !m_progress.isNull() ) {
384  m_progress->CheckStatus();
385  }
386 
387  return (m_total);
388  }
389 
390 
395  m_total = 0;
396  return;
397  }
398 
399 
409  int Strategy::countActive(const ResourceList &resources) const {
410  return ( resources.size() - countDiscarded(resources) );
411  }
412 
413 
423  int Strategy::countDiscarded(const ResourceList &resources) const {
424  int n = 0;
425  BOOST_FOREACH ( SharedResource resource, resources ) {
426  if ( resource->isDiscarded() ) { n++; }
427  }
428  return (n);
429  }
430 
431 
442  const QString &name) const {
443  ResourceList alist;
444  if ( resource->hasAsset(name) ) {
445  QVariant v_asset = resource->asset(name);
446  if ( v_asset.canConvert<ResourceList>() ) {
447  alist = v_asset.value<ResourceList>();
448  }
449  }
450 
451  return (alist);
452  }
453 
454 
467  QString Strategy::findReplacement(const QString &target,
468  const ResourceList &globals,
469  const int &index,
470  const QString &defValue) const {
471  BOOST_FOREACH ( const SharedResource keystore, globals ) {
472  if ( keystore->exists(target) ) {
473  if ( keystore->count(target) > index ) {
474  return (keystore->value(target, index));
475  }
476  }
477  }
478 
479  return ( defValue );
480  }
481 
482 
494  QStringList Strategy::qualifiers(const QString &keyspec,
495  const QString &delimiter) const {
496  QStringList parts = keyspec.split(delimiter);
497  return (parts);
498  }
499 
500 
513  QString Strategy::scanAndReplace(const QString &input, const QString &target,
514  const QString &replacement) const {
515  QString str(input);
516  str.replace(target, replacement, Qt::CaseInsensitive);
517  return (str);
518  }
519 
520 
539  QString Strategy::translateKeywordArgs(const QString &keyBase,
540  const ResourceList &globals,
541  const QString &defValue) const {
542 
543  // Get keyword configuration from definition
544  PvlFlatMap keys( getDefinitionMap() );
545 
546  QStringList idArgs; // Argument replacement list
547  QString value;
548 
549  QString keyword = keyBase + "Keyword";
550  if ( keys.exists(keyword) ) {
551  idArgs.push_back(keys.get(keyword));
552  value = keys.get(keyBase, "%1");
553  }
554  else {
555  if ( keys.exists(keyBase + "Args") ) {
556  idArgs = keys.allValues(keyBase + "Args");
557  }
558  value = keys.get(keyBase, defValue);
559  }
560 
561  return (processArgs(value, idArgs, globals, defValue));
562  }
563 
564 
587  QString Strategy::processArgs(const QString &value, const QStringList &argKeys,
588  const ResourceList &globals,
589  const QString &defValue) const {
590 
591  QString result = value;
592  int i = argKeys.size();
593  BOOST_REVERSE_FOREACH ( QString arg, argKeys ) {
594  QString target("%"+QString::number(i));
595  result = scanAndReplace(result, target, findReplacement(arg,globals,0,defValue));
596  i--;
597  }
598  return (result);
599  }
600 
601 
611  const {
612  PvlFlatMap keys( getDefinitionMap() );
613  QStringList keySources = keys.allValues("PropagateKeywords");
614  BOOST_FOREACH ( QString key, keySources ) {
615  if ( source->exists(key) ) {
616  target->add(source->keyword(key));
617  }
618  }
619  return;
620  }
621 
622 
651  SharedResource &resourceB,
652  const QPair<QString, QString> &keySuffix)
653  const {
654 
655  // Create the new resource
656  QString id = resourceA->name() + "_" + resourceB->name();
658 
659  // See if user wants to restrict keyword propagation to a list
660  QStringList keySources = PvlFlatMap( getDefinitionMap() ).allValues("PropagateKeywords");
661  if ( !keySources.isEmpty() ) {
662  // Propogate only specified keywords from each Resource
663  BOOST_FOREACH ( QString key, keySources ) {
664  if ( resourceA->exists(key) ) {
665  PvlKeyword keyword(resourceA->keyword(key));
666  keyword.setName(keyword.name().append(keySuffix.first));
667  composite->add(keyword);
668  }
669 
670  if ( resourceB->exists(key) ) {
671  PvlKeyword keyword(resourceB->keyword(key));
672  keyword.setName(keyword.name().append(keySuffix.second));
673  composite->add(keyword);
674  }
675  }
676  }
677  else {
678  // Propagate all keys from each source to the composite Resource
679  const PvlFlatMap &rkeysA = resourceA->keys();
680  PvlFlatMap::ConstPvlFlatMapIterator pkeys = rkeysA.begin();
681  while ( rkeysA.constEnd() != pkeys) {
682  PvlKeyword keyword(pkeys.value());
683  keyword.setName(keyword.name().append(keySuffix.first));
684  composite->add(keyword);
685  ++pkeys;
686  }
687 
688  const PvlFlatMap &rkeysB = resourceB->keys();
689  pkeys = rkeysB.begin();
690  while ( rkeysB.constEnd() != pkeys) {
691  PvlKeyword keyword(pkeys.value());
692  keyword.setName(keyword.name().append(keySuffix.second));
693  composite->add(keyword);
694  ++pkeys;
695  }
696  }
697  return (composite);
698  }
699 
700 
722  const ResourceList &globals) const {
723  PvlFlatMap keys( getDefinitionMap() );
724 
725  // Assume a specific geometry is present
726  QString geom(keys.get("GisGeometry", ""));
727 
728  QString giskey;
729  if ( keys.exists("GisGeometryRef") ) { giskey = keys.get("GisGeometryRef"); }
730  if ( keys.exists("GisGeometryKey") ) { giskey = keys.get("GisGeometryKey"); }
731 
732  if ( !giskey.isEmpty() ) {
733  if ( !resource->isNull(giskey) ) {
734  geom = resource->value(giskey);
735 
736  // Erase key if requested
737  if ( toBool(keys.get("RemoveGisKeywordAfterImport", "false")) ) {
738  resource->erase(giskey);
739  }
740  }
741  }
742 
743  // Got a geometry.
744  if ( !geom.isEmpty() ) {
745 
746  // Process arguments Allows creation specialized geometry as well
747  if ( keys.exists("GisGeometryArgs") ) {
748  QStringList args = keys.allValues("GisGeometryArgs");
749  geom = processArgs(geom, args, getGlobals(resource, globals));
750  }
751 
752  // Get the type
753  QString gisType = keys.get("GisType");
754  int npoints(0);
755  int npointsOrg(0);
756  double tolerance(0.0);
757 
758  // Check for Geometry. May want to remove it after parsing/conversion.
759  // These text geometries tend to be huge and consume lots of memory.
760  if ( !geom.isEmpty() ) {
761 
762  QScopedPointer<GisGeometry> geosgeom(new GisGeometry(geom, GisGeometry::type(gisType)));
763  if ( geosgeom.isNull() || !geosgeom->isValid() ) return (false);
764 
765  npointsOrg = npoints = geosgeom->points();
766  QString gisTolerance = translateKeywordArgs("GisSimplifyTolerance",
767  getGlobals(resource, globals), "");
768 
769  if ( !gisTolerance.isEmpty() ) {
770  tolerance = toDouble(gisTolerance);
771  GisGeometry *simple = geosgeom->simplify(tolerance);
772  if ( 0 != simple ) geosgeom.reset(simple);
773  npoints = geosgeom->points();
774  }
775 
776  resource->add(geosgeom.take());
777 
778  // Add the geometry point count to the resource if requested
779  QString pointsKey = translateKeywordArgs("GisGeometryPointsKey",
780  getGlobals(resource, globals),
781  "");
782  if ( !pointsKey.isEmpty() ) {
783  resource->add(pointsKey, toString(npoints));
784  resource->add(pointsKey+"Original", toString(npointsOrg));
785  resource->add(pointsKey+"Tolerance", toString(tolerance));
786  }
787 
788  // Status if requested
789  if ( isDebug() ) {
790  cout << " " << type() << ":" << name() << " has a geometry with "
791  << npoints << " points!\n";
792  if ( npoints != npointsOrg ) {
793  cout << " Geometry has been simplified/reduced from original "
794  << npointsOrg << " points.\n";
795  }
796  }
797  return (true);
798  }
799  }
800 
801  // Report geometry status
802  if ( isDebug() ) {
803  cout << " " << type() << ":" << name() << " does not have a geometry!\n";
804  }
805 
806  return (false);
807  }
808 
809 
818  // Create a list of active resources
819  ResourceList v_active;
820  BOOST_FOREACH ( SharedResource resource, resources ) {
821  if ( !resource->isDiscarded() ) { v_active.append(resource); }
822  }
823  return (v_active);
824  }
825 
826 
832  void Strategy::activateList(ResourceList &resources) const {
833  BOOST_FOREACH ( SharedResource resource, resources ) {
834  resource->activate();
835  }
836  }
837 
838 
844  void Strategy::deactivateList(ResourceList &resources) const {
845  BOOST_FOREACH ( SharedResource resource, resources ) {
846  resource->discard();
847  }
848  }
849 
850 
871  ResourceList Strategy::copyList(const ResourceList &resources) const {
872  ResourceList v_copy;
873  BOOST_FOREACH ( SharedResource resource, resources ) {
874  v_copy.append(SharedResource(resource->copy()));
875  }
876  return ( v_copy);
877  }
878 
879 
900  const bool &withAssets) const {
901  ResourceList v_clone;
902  BOOST_FOREACH ( SharedResource resource, resources ) {
903  v_clone.append(SharedResource(resource->clone(resource->name(), withAssets)));
904  }
905  return ( v_clone );
906  }
907 
908 
947  GisGeometry &geom,
948  const ResourceList &globals) {
949 
950  QString method = getDefinitionMap().get("GisMethod", "direct").toLower();
951 
952  // The programmer is required to ensure a valid geometry provides the
953  // source of the intersection operation.
954  if ( !geom.isValid() ) {
955  QString mess = type() + ":" + name() +
956  "Cannot apply RTree search to bad geometry.";
958  }
959 
960  // Create a list of active resources only
961  ResourceList v_active = activeList(resources);
962 
963  // Use direct computation method
964  ResourceList overlaps;
965  if ( "direct" == method ) {
966  if ( isDebug() ) {
967  cout << "Using direct Geom intersects for " << v_active.size() << " geometries...\n";
968  }
969 
970  // Direct intersect computations of overlaps has about the same overhead
971  // of constructing an RTree index and running queries.
972  initProgress(v_active.size());
973  BOOST_FOREACH ( SharedResource resource, v_active ) {
974  if ( resource->hasValidGeometry() ) {
975  if ( geom.intersects( *resource->geometry()) ) {
976  overlaps.append(resource);
977  }
978  }
979  processed();
980  }
981  }
982  else {
983 
984  // Use RTree method to get potenital overlappers...
985  if ( isDebug() ) {
986  cout << "Allocating " << v_active.size() << " RTree geometries.\n";
987  }
988  GEOSSTRtree *rtree = GEOSSTRtree_create(v_active.size());
989  if ( !rtree ) {
990  QString mess = "GEOS RTree allocation failed for " +
991  toString(v_active.size()) + " geometries.";
993  }
994 
995  if ( isDebug() ) {
996  cout << "GEOS RTree allocated " << v_active.size() << " geometry entries.\n";
997  }
998 
999  // Create and query the RTree geometries calling once for each
1000  // strategy::appy(SharedResource &) geometry that intersect the envelope.
1001  initProgress(v_active.size());
1002  int nvalid = 0;
1003  for ( int i = 0 ; i < v_active.size() ; i++ ) {
1004  if ( v_active[i]->hasValidGeometry() ) {
1005  GEOSSTRtree_insert(rtree, v_active[i]->geometry()->geometry(),
1006  &v_active[i]);
1007  nvalid++;
1008  }
1009  processed();
1010  }
1011 
1012  // Report number found...
1013  if ( isDebug() ) {
1014  cout << "Valid Geometries found: " << nvalid << " - running query...\n";
1015  }
1016 
1017  // Run the query
1018  GEOSSTRtree_query(rtree, geom.geometry(), &queryCallback, &overlaps);
1019  GEOSSTRtree_destroy(rtree);
1020  }
1021 
1022  if ( isDebug() ) {
1023  cout << "Potential Intersections Found: " << overlaps.size() << "\n";
1024  }
1025 
1026 
1027  // Now apply all intersected geometries to calling strategy. Note to
1028  // properly reflect the intersected list, we must deactivate the entire
1029  // active list after the query search and activate each one prior to
1030  // applying it in the strategy method, which has the responsibility to
1031  // determine validity, and return the proper Resource list status to the
1032  // next strategy.
1033  deactivateList(v_active);
1034 
1035  initProgress(overlaps.size());
1036  int n = 0; // Result count
1037  BOOST_FOREACH ( SharedResource resource, overlaps ) {
1038  resource->activate();
1039  n += apply(resource, globals);
1040  processed();
1041  }
1042 
1043 
1044  if ( isDebug() ) {
1045  cout << "Total valid Intersections Found: " << n << "\n";
1046  }
1047 
1048  return (n);
1049  }
1050 
1051 
1066  void Strategy::queryCallback(void *item, void *userdata) {
1067  SharedResource *resource = (SharedResource *) item; // Maybe fancy casts?
1068  ResourceList *rlist = (ResourceList *) userdata;
1069  rlist->append(*resource);
1070  return;
1071  }
1072 
1073 
1080  bool Strategy::isDebug() const {
1081  return ( m_debug );
1082  }
1083 
1084 
1090  return ( !m_progress.isNull() );
1091  }
1092 
1093 
1094 
1118  bool Strategy::initProgress(const int &nsteps, const QString &text) {
1119 
1120  QString p_text = text;
1121  resetProcessed();
1122  bool status = false;
1123 
1124  // Check for initialization
1125  if ( !doShowProgress() ) {
1126  PvlFlatMap p_var( getDefinitionMap() );
1127  if ( toBool(p_var.get("ShowProgress", "false")) ) {
1128  m_progress.reset( new Progress() );
1129  if ( p_text.isEmpty() ) {
1130  p_text = type() + "::" + name();
1131  }
1132  }
1133  }
1134 
1135 
1136  // No check if progress is requested
1137  if ( doShowProgress() ) {
1138  if ( !p_text.isEmpty() ) m_progress->SetText(p_text);
1139  m_progress->SetMaximumSteps(nsteps);
1140  if ( nsteps > 0 ) m_progress->CheckStatus();
1141  status = true;
1142  }
1143 
1144  // Set up for systematic processing
1145  return (status);
1146  }
1147 
1148 
1149  QStringList Strategy::getObjectList(const PvlObject &source) const {
1150  QStringList objList;
1151  PvlObject::ConstPvlObjectIterator object = source.beginObject();
1152  while ( object != source.endObject() ) {
1153  objList << object->name();
1154  ++object;
1155  }
1156  return (objList);
1157  }
1158 
1159 
1160 } //namespace Isis
bool initProgress(const int &nsteps=0, const QString &text="")
Initializes strategy progress monitor if requested by user.
Definition: Strategy.cpp:1118
bool m_debug
Indicates whether to print debug messages.
Definition: Strategy.h:236
int apply(ResourceList &resources)
Apply algorithm to resource list.
Definition: Strategy.cpp:242
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:513
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:467
QMap< QString, PvlKeyword >::const_iterator ConstPvlFlatMapIterator
A const iterator for the underling QMap that PvlFlatMap is built on.
Definition: PvlFlatMap.h:240
GisGeometry * simplify(const double &tolerance) const
Simplify complex or overdetermined geoemtry.
static void queryCallback(void *item, void *userdata)
Important GEOS query callback for class and overlap geometry.
Definition: Strategy.cpp:1066
PvlObjectIterator endObject()
Returns the index of the ending object.
Definition: PvlObject.h:265
QString m_type
A string containing the type of strategy.
Definition: Strategy.h:225
ResourceList cloneList(const ResourceList &resources, const bool &withAssets=false) const
Create a clone of a Resource list.
Definition: Strategy.cpp:899
int countDiscarded(const ResourceList &resources) const
Counts the number of non-active (i.e.
Definition: Strategy.cpp:423
QString description() const
Return description for the strategy.
Definition: Strategy.cpp:218
void setApplyToDiscarded()
Sets Resource as discarded.
Definition: Strategy.cpp:320
virtual ~Strategy()
Destroys the Strategy object.
Definition: Strategy.cpp:109
void setName(const QString &name)
Allow derived strategies to reset name (mostly for default constructors)
Definition: Strategy.cpp:138
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:494
ResourceList m_globals
A shared pointer to the global Resource of keywords.
Definition: Strategy.h:210
bool doShowProgress() const
Definition: Strategy.cpp:1089
void setName(QString name)
Sets the keyword name.
Definition: PvlKeyword.cpp:136
bool intersects(const GisGeometry &target) const
Computes a new geometry from the intersection of the two geomtries.
Namespace for the standard library.
bool exists(const QString &key) const
Determines whether a given keyword exists in the PvlFlatMap.
Definition: PvlFlatMap.cpp:453
SharedPvlObject m_definition
A shared pointer to the PvlObject that defines the strategy.
Definition: Strategy.h:216
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:164
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
unsigned int totalProcessed() const
Accessor for the total number of resources processed.
Definition: Strategy.cpp:311
QScopedPointer< Progress > m_progress
Progress percentage monitor.
Definition: Strategy.h:239
QStringList allValues(const QString &key) const
Gets all the values associated with a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:658
void setType(const QString &type)
Allow derived strategies to reset type (mostly for default constructors)
Definition: Strategy.cpp:150
QString name() const
Accessor method to get the name of the strategy.
Definition: Strategy.cpp:118
bool isValid() const
Determines validity of the geometry contained in this object.
Program progress reporter.
Definition: Progress.h:58
ResourceList getGlobals(SharedResource &myGlobals, const ResourceList &globals) const
Definition: Strategy.cpp:175
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:650
QString get(const QString &key, const int &index=0) const
Gets the value of a keyword in the PvlFlatMap.
Definition: PvlFlatMap.cpp:593
bool isDebug() const
An accessor method so that inherited classes can determine whether to print debug messages for this o...
Definition: Strategy.cpp:1080
Provides a flat map of PvlKeywords.
Definition: PvlFlatMap.h:236
QString type() const
Accessor method to get the type of strategy.
Definition: Strategy.cpp:128
void deactivateList(ResourceList &resources) const
Deactivate all resources contained in the resource list.
Definition: Strategy.cpp:844
PvlFlatMap getDefinitionMap() const
Returns the keyword definitions found in the Strategy object.
Definition: Strategy.cpp:202
This class provides a resource of PVL keywords for Strategy classes.
Definition: Resource.h:71
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
bool m_applyDiscarded
Indicates whether to apply strategy to discarded resources.
Definition: Strategy.h:233
int applyToIntersectedGeometry(ResourceList &resources, GisGeometry &geom, const ResourceList &globals)
Identify and apply Strategy to Resources that intersect a geometry.
Definition: Strategy.cpp:946
bool isApplyToDiscarded() const
Accessor for the apply discarded variable.
Definition: Strategy.cpp:332
ResourceList copyList(const ResourceList &resources) const
Make a copy of the resource list that is independently managed.
Definition: Strategy.cpp:871
A single keyword-value pair.
Definition: PvlKeyword.h:98
int points() const
Get number of points in geometry.
void setDoNotApplyToDiscarded()
Disables the general application of Strategy algorithm for all Resources regardless of state...
Definition: Strategy.cpp:341
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:441
Strategy()
Constructs default Strategy object of name "Strategy" and type "Counter".
Definition: Strategy.cpp:50
static PvlConstraints withExcludes(const QStringList &excludes)
Static method to construct a PvlConstraints object from a list of names for the PvlObjects and PvlGro...
Definition: PvlFlatMap.cpp:71
void activateList(ResourceList &resources) const
Activate all resources contained in the resource list.
Definition: Strategy.cpp:832
unsigned int processed()
Increments the total number of resources processed and returns the incremented value.
Definition: Strategy.cpp:381
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:587
ResourceList activeList(ResourceList &resources) const
Get list of all active Resources only - no discarded Resources.
Definition: Strategy.cpp:817
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:539
void resetProcessed()
Resets the total number of processed resources to zero.
Definition: Strategy.cpp:394
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition: IString.cpp:53
Type type() const
Returns the type (origin) of the geometry.
void propagateKeys(SharedResource &source, SharedResource &target) const
Adds the PVL definition keywords from the source to the target.
Definition: Strategy.cpp:610
QSharedPointer< Resource > SharedResource
Defintion of a SharedResource, a shared pointer to a Resource object.
Definition: Resource.h:183
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
const GEOSGeometry * geometry() const
Returns the GEOSGeometry object to extend functionality.
ResourceList getGlobalDefaults() const
Accessor method to get the global defaults.
Definition: Strategy.cpp:161
unsigned int m_total
The total number of resources processed.
Definition: Strategy.h:229
QString m_name
A string containing the name of the strategy.
Definition: Strategy.h:221
Encapsulation class provides support for GEOS-C API.
Definition: GisGeometry.h:67
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
PvlObjectIterator beginObject()
Returns the index of the beginning object.
Definition: PvlObject.h:247
int countActive(const ResourceList &resources) const
Counts the number of active (i.e.
Definition: Strategy.cpp:409
int applyToResources(ResourceList &resources, const ResourceList &globals)
Applies the strategy algorithms to the resources in the given list.
Definition: Strategy.cpp:354
bool importGeometry(SharedResource &resource, const ResourceList &globals) const
Imports a geometry from the given resource.
Definition: Strategy.cpp:721