Class PARTS_LIST is a LIB which resides in a SCHEMATIC, and it is a table model for a spread sheet both. More...
#include <design.h>
Inheritance diagram for SCH::PARTS_LIST:
Collaboration diagram for SCH::PARTS_LIST:Public Member Functions | |
| SPREADSHEET_TABLE_MODEL * | GetModel () |
| Function GetModel returns a spreadsheet table model that allows both reading and writing to rows in a spreadsheet. | |
| bool | HasSink () |
| Function HasSink returns true if this library has write/save capability. | |
| STRING | LogicalName () |
| Function LogicalName returns the logical name of this LIB. | |
| PART * | LookupPart (const LPID &aLPID, LIB_TABLE *aLibTable) throw ( IO_ERROR ) |
| Function LookupPart returns a PART given aPartName, such as "passives/R". | |
| void | ReloadPart (PART *aPart) throw ( IO_ERROR ) |
| Function ReloadPart will reload the part assuming the library source has a changed content for it. | |
| STRINGS | GetCategories () throw ( IO_ERROR ) |
| Function GetCategories returns all categories of parts within this LIB into aResults. | |
| STRINGS | GetCategoricalPartNames (const STRING &aCategory="") throw ( IO_ERROR ) |
| Function GetCategoricalPartNames returns the part names for aCategory, and at the same time creates cache entries for the very same parts if they do not already exist in this LIB (i.e. | |
| STRING | WritePart (PART *aPart) throw ( IO_ERROR ) |
| Function WritePart saves the part to non-volatile storage and returns the next new revision name in the sequence established by the LIB_SINK. | |
| STRINGS | GetRevisions (const STRING &aPartName) throw ( IO_ERROR ) |
| Function GetRevisions returns the revisions of aPartName that are present in this LIB. | |
| STRINGS | FindParts (const STRING &aQuery) throw ( IO_ERROR ) |
| Function FindParts returns part names for all parts matching the criteria given in aQuery, into aResults. | |
Protected Member Functions | |
| const PART * | lookupPart (const LPID &aLPID) throw ( IO_ERROR ) |
| Function lookupPart looks up a PART, returns NULL if cannot find in source. | |
Protected Attributes | |
| PARTS * | parts |
| < is true only after reading categories | |
Class PARTS_LIST is a LIB which resides in a SCHEMATIC, and it is a table model for a spread sheet both.
When columns are added or removed to/from the spreadsheet, this is adding or removing fields/properties to/from ALL the contained PARTS.
Definition at line 452 of file design.h.
| SPREADSHEET_TABLE_MODEL* SCH::PARTS_LIST::GetModel | ( | ) |
Function GetModel returns a spreadsheet table model that allows both reading and writing to rows in a spreadsheet.
The UI holds the actual screen widgets, but this is the table model, i.e. the PARTS_LIST is.
| bool SCH::LIB::HasSink | ( | ) | [inline, inherited] |
Function LookupPart returns a PART given aPartName, such as "passives/R".
No ownership is given to the PART, it stays in the cache that is this LIB.
| aLPID | is the part to lookup. The logicalLibName can be empty in it since yes, we know which LIB is in play. | |
| aLibTable | is the LIB_TABLE view that is in effect for inheritance, and comes from the big containing SCHEMATIC object. |
| IO_ERROR | if the part cannot be found or loaded. |
Definition at line 231 of file sch_lib.cpp.
References SCH::PART::body, and SCH::PART::Parse().
Referenced by SCH::LIB_TABLE::LookupPart().
{
PART* part = (PART*) lookupPart( aLPID );
if( !part ) // part does not exist in this lib
{
wxString msg = wxString::Format( _("part '%s' not found in lib %s" ),
wxString::FromUTF8( aLPID.GetPartNameAndRev().c_str() ).GetData(),
wxString::FromUTF8( logicalName.c_str() ).GetData() );
THROW_IO_ERROR( msg );
}
if( part->body.empty() )
{
// load body
source->ReadPart( &part->body, aLPID.GetPartName(), aLPID.GetRevision() );
#if 0 && defined(DEBUG)
const STRING& body = part->body;
printf( "body: %s", body.c_str() );
if( !body.size() || body[body.size()-1] != '\n' )
printf( "\n" );
#endif
// @todo consider changing ReadPart to return a "source"
SWEET_PARSER sp( part->body, wxString::FromUTF8( aLPID.Format().c_str() ) );
part->Parse( &sp, aLibTable );
}
return part;
}
| STRINGS SCH::LIB::GetCategoricalPartNames | ( | const STRING & | aCategory = "" |
) | throw ( IO_ERROR ) [inherited] |
Function GetCategoricalPartNames returns the part names for aCategory, and at the same time creates cache entries for the very same parts if they do not already exist in this LIB (i.e.
cache).
Function GetRevisions returns the revisions of aPartName that are present in this LIB.
The returned STRINGS will look like "rev1", "rev2", etc.
Function FindParts returns part names for all parts matching the criteria given in aQuery, into aResults.
The query string is designed to be easily marshalled, i.e. serialized, so that long distance queries can be made with minimal overhead. The library source needs to have an intelligent friend on the other end if the actual library data is remotely located, otherwise it will be too slow to honor this portion of the API contract.
| aQuery | is a string holding a domain specific language expression. One candidate here is an RPN s-expression that uses (and ..) and (or ..) operators. For example "(and (footprint 0805)(value 33ohm)(category passives))" |
Definition at line 315 of file sch_lib.h.
{
// run the query on the cached data first for any PARTS which are fully
// parsed (i.e. cached), then on the LIB_SOURCE to find any that
// are not fully parsed, then unify the results.
return STRINGS();
}
Function lookupPart looks up a PART, returns NULL if cannot find in source.
Does not parse the part. Does not even load the part's Sweet string. No ownership is given to the PART, it stays in the cache that is this LIB.
| IO_ERROR | if there is some kind of communications error reading the original list of parts. |
Definition at line 158 of file sch_lib.cpp.
References SCH::LPID::Format().
{
if( !parts )
{
parts = new PARTS;
source->GetCategoricalPartNames( &vfetch );
// insert a PART_REVS for each part name
for( STRINGS::const_iterator it = vfetch.begin(); it!=vfetch.end(); ++it )
{
D(printf("lookupPart:%s\n", it->c_str() );)
(*parts)[*it] = new PART_REVS;
}
}
// load all the revisions for this part name, only if it has any
PARTS::iterator pi = parts->find( aLPID.GetPartName() );
PART_REVS* revs = pi != parts->end() ? pi->second : NULL;
// D(printf("revs:%p partName:%s\n", revs, aLPID.GetPartName().c_str() );)
// if the key for parts has no aLPID.GetPartName() the part is not in this lib
if( revs )
{
if( revs->size() == 0 ) // assume rev list has not been loaded yet
{
// load all the revisions for this part.
source->GetRevisions( &vfetch, aLPID.GetPartName() );
// create a PART_REV entry for each revision, but leave the PART* NULL
for( STRINGS::const_iterator it = vfetch.begin(); it!=vfetch.end(); ++it )
{
D(printf("lookupPartRev:%s\n", it->c_str() );)
(*revs)[*it] = 0;
}
}
PART_REVS::iterator rev;
// If caller did not say what revision, find the highest numbered one and return that.
if( !aLPID.GetRevision().size() && revs->size() )
{
rev = revs->begin(); // sort order has highest rev first
if( !rev->second ) // the PART has never been instantiated before
{
rev->second = new PART( this, LPID::Format( "", aLPID.GetPartName(), rev->first ) );
}
D(printf("lookupPartLatestRev:%s\n", rev->second->partNameAndRev.c_str() );)
return rev->second;
}
else
{
rev = revs->find( aLPID.GetRevision() );
if( rev != revs->end() )
{
if( !rev->second ) // the PART has never been instantiated before
{
rev->second = new PART( this, aLPID.GetPartNameAndRev() );
}
return rev->second;
}
}
}
return 0; // no such part name in this lib
}
PARTS* SCH::LIB::parts [protected, inherited] |
< is true only after reading categories
parts are in various states of readiness: 1) not even loaded (if cachedParts is false) 2) present, but without member 'body' having been read() yet. 3) body has been read, but not parsed yet. 4) parsed and inheritance if any has been applied.
1.7.1