Commit dda28ed6 authored by dickelbeck's avatar dickelbeck

more new search stuff, beautification

parent 6f7209aa
...@@ -231,7 +231,7 @@ std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os ) ...@@ -231,7 +231,7 @@ std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os )
// see base_struct.h // see base_struct.h
SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
INSPECTOR* inspector, void* testData, const KICAD_T scanTypes[] ) INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] )
{ {
EDA_BaseStruct* p = listStart; EDA_BaseStruct* p = listStart;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
...@@ -245,7 +245,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, ...@@ -245,7 +245,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
// see base_struct.h // see base_struct.h
SEARCH_RESULT EDA_BaseStruct::Traverse( INSPECTOR* inspector, void* testData, SEARCH_RESULT EDA_BaseStruct::Traverse( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
......
...@@ -88,7 +88,7 @@ class EDA_BaseStruct; ...@@ -88,7 +88,7 @@ class EDA_BaseStruct;
* Class INSPECTOR * Class INSPECTOR
* is an abstract class that is used to inspect and possibly collect the * is an abstract class that is used to inspect and possibly collect the
* (search) results of Iterating over a list or tree of KICAD_T objects. * (search) results of Iterating over a list or tree of KICAD_T objects.
* Extend from this class and implment the Inspect function and provide for * Extend from this class and implement the Inspect function and provide for
* a way for the extension to collect the results of the search/scan data and * a way for the extension to collect the results of the search/scan data and
* provide them to the caller. * provide them to the caller.
*/ */
...@@ -99,15 +99,18 @@ public: ...@@ -99,15 +99,18 @@ public:
/** /**
* Function Inspect * Function Inspect
* is the function type that can be passed to the Iterate function, * is the examining function within the INSPECTOR which is passed to the
* used primarily for searching, but not exclusively. * Iterate function. It is used primarily for searching, but not limited to
* that. It can also collect or modify the scanned objects.
*
* @param testItem An EDA_BaseStruct to examine.
* @param testData is arbitrary data needed by the inspector to determine * @param testData is arbitrary data needed by the inspector to determine
* if the EDA_BaseStruct under test meets its match criteria. * if the EDA_BaseStruct under test meets its match criteria.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE; * else SCAN_CONTINUE;
*/ */
SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem, SEARCH_RESULT virtual Inspect( EDA_BaseStruct* testItem,
void* testData ) = 0; const void* testData ) = 0;
// derived classes add more functions for collecting and subsequent // derived classes add more functions for collecting and subsequent
// retrieval here. // retrieval here.
...@@ -199,27 +202,27 @@ public: ...@@ -199,27 +202,27 @@ public:
/** /**
* Function IterateForward * Function IterateForward
* walks through the object tree calling the testFunc on each object * walks through the object tree calling the testFunc on each object
* type requested in structTypes. * type requested in scanTypes.
* *
* @param listStart The first in a list of EDA_BaseStructs to iterate over. * @param listStart The first in a list of EDA_BaseStructs to iterate over.
* @param inspector Is an INSPECTOR to call on each object that is of one of * @param inspector Is an INSPECTOR to call on each object that is one of
* the requested itemTypes. * the requested scanTypes.
* @param testData Is an aid to testFunc, and should be sufficient to * @param testData Is an aid to testFunc, and should be sufficient to
* allow it to fully determine if an item meets the match criteria, but it * allow it to fully determine if an item meets the match criteria, but it
* may also be used to collect output. * may also be used to collect output.
* @param scanTypes Is a char array of KICAD_T that is EOT * @param scanTypes A KICAD_T array that is EOT
* terminated, and provides both the order and interest level of of * terminated, and provides both the order and interest level of of
* the types of objects to be iterated over. * the types of objects to be iterated over.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the called INSPECTOR returned
* else SCAN_CONTINUE; * SEARCH_QUIT, else SCAN_CONTINUE;
*/ */
static SEARCH_RESULT IterateForward( EDA_BaseStruct* listStart, static SEARCH_RESULT IterateForward( EDA_BaseStruct* listStart,
INSPECTOR* inspector, void* testData, const KICAD_T scanTypes[] ); INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] );
/** /**
* Function Traverse * Function Traverse
* should be re-implemented for each derrived class in order to handle * should be re-implemented for each derived class in order to handle
* all the types given by its member data. Implementations should call * all the types given by its member data. Implementations should call
* inspector->Inspect() on types in scanTypes[], and may use IterateForward() * inspector->Inspect() on types in scanTypes[], and may use IterateForward()
* to do so on lists of such data. * to do so on lists of such data.
...@@ -230,7 +233,7 @@ public: ...@@ -230,7 +233,7 @@ public:
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE; * else SCAN_CONTINUE;
*/ */
virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, void* testData, virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
......
...@@ -300,7 +300,7 @@ public: ...@@ -300,7 +300,7 @@ public:
{ {
} }
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, void* testData ) SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
{ {
const wxPoint* refPos = (const wxPoint*) testData; const wxPoint* refPos = (const wxPoint*) testData;
...@@ -336,9 +336,9 @@ EDA_BaseStruct* BOARD::FindModuleOrPad( const wxPoint& refPos ) ...@@ -336,9 +336,9 @@ EDA_BaseStruct* BOARD::FindModuleOrPad( const wxPoint& refPos )
{ {
ModuleOrPad inspector; ModuleOrPad inspector;
static const KICAD_T scanTypes[] = { TYPEMODULE, TYPEPAD, EOT }; static const KICAD_T scanTypes[] = { TYPEPAD, TYPEMODULE, EOT };
if( SEARCH_QUIT == IterateForward( m_Modules, &inspector, (void*) &refPos, scanTypes ) ) if( SEARCH_QUIT == IterateForward( m_Modules, &inspector, &refPos, scanTypes ) )
return inspector.found; return inspector.found;
return NULL; return NULL;
......
...@@ -1188,7 +1188,7 @@ void MODULE::Show( int nestLevel, std::ostream& os ) ...@@ -1188,7 +1188,7 @@ void MODULE::Show( int nestLevel, std::ostream& os )
// see class_module.h // see class_module.h
SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, void* testData, SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
......
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE; * else SCAN_CONTINUE;
*/ */
virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, void* testData, virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ); const KICAD_T scanTypes[] );
#endif #endif
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment