diff --git a/new/Doxyfile b/new/Doxyfile index 1fbf05dd93..e6b11073e4 100644 --- a/new/Doxyfile +++ b/new/Doxyfile @@ -297,7 +297,7 @@ SYMBOL_CACHE_SIZE = 0 # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = YES +EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. @@ -336,7 +336,7 @@ EXTRACT_ANON_NSPACES = NO # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. @@ -357,7 +357,7 @@ HIDE_FRIEND_COMPOUNDS = NO # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. -HIDE_IN_BODY_DOCS = NO +HIDE_IN_BODY_DOCS = YES # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set @@ -402,7 +402,7 @@ INLINE_INFO = YES # alphabetically by member name. If set to NO the members will appear in # declaration order. -SORT_MEMBER_DOCS = YES +SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically @@ -1390,7 +1390,7 @@ HIDE_UNDOC_RELATIONS = YES # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = NO +HAVE_DOT = YES # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This diff --git a/new/design.h b/new/design.h index 6b4fd74cfd..ef5f9fb870 100644 --- a/new/design.h +++ b/new/design.h @@ -1,4 +1,5 @@ +namespace SCH { /** @mainpage @@ -45,7 +46,7 @@ can be library specializations or niches.

Often a found part is close to what is needed but not exactly what is needed. This Distributed Library System design incorporates the concept of part -inheritance using a part description language called (Sweet). Sweet is +inheritance using a part description language called Sweet. Sweet is based on s-expression syntax. Inheritance is the ability to incrementally change an existing part without completely re-designing it. It is sometimes easier to modify an existing part than it is to create the new part entirely from scratch. @@ -75,16 +76,21 @@ nest within grammars. So once you are inside a grammatical element, it will have its own set of rules as to which nested elements it may hold, and once you enter one of those nested elements, then that nested element's grammar pertains, etc.

In the case of the grammar for a part, the grammar itself is being given -the name "Sweet". The name does not extend to the grammar for the schematic, +the name Sweet. The name does not extend to the grammar for the schematic, only the part grammar.

Schematic
This consists of one or more sheets and will be different -in three ways from existing schematics. Within the sheets of the -schematic will be components.
+in three ways from existing schematics. + +Within the sheets of the schematic will be components.
Component
A component is an instantiated part. The keyword for component is (comp). A component does not have any of its own properties other @@ -98,7 +104,7 @@ BOM can be made simply from the parts_list.
Component, again for good measure.
A component is an instantiation of a part. A component exists within a schematic which has a parts list containing the part from which the component is instantiated. A component has a -unique reference designator, component ref, its own location, orientation, +unique reference designator, part ref, its own location, orientation, stuff/DNS, and text attributes but not its own text fields/strings (other than reference designator). The part which is instantiated must exist in the parts list of the same schematic.
@@ -137,6 +143,42 @@ a library source and a library sink is that a source is a readable entity. written to for future reading. The difference between a library source and a library sink is that a library sink is a writable entity. +
Symbol
The term "symbol" is not used in a specific way in this +document. There is no symbol in any of the grammars, so use of it on the +developers list will not be understood without explanation. Of course it is +possible to have multiple parts all extend a common base part, and you can think +of the base part as having most if not all the graphical lines for any +derivatives. But we do not need to use the term symbol to describe that +relationship, the term "part" is sufficient.
+ +
LPID
This stand for "Logical Part ID", and is a reference to any +part within any known library. The term "logical" is used because the contained +library name is logical, not a full library name. The LPID consists of 3 main +portions: logical library name, part name, and revision number.
+ +
Library Table
This is a lookup table that maps a logical library +name (i.e. a short name) into a fully specified library name and library type. +An applicable library table consists of rows from (at least) two sources:
    +
  1. A schematic resident library table. +
  2. A personal library table. +
+ +These rows from the two sources are conceptually concatonated (although they may +not be physically concatonated in the implementation, TBD). The schematic +resident rows take presedence over the personal library table if there are +logical library names duplicately defined. (Or we will simply ask that any remote +(i.e. public) libraries use uppercase first letters in logical names, TBD.) + +

Eventually there will be an external publicly available internet based +logical library table also, but this will need to be glued down at a hard coded +URL that we have control over. The internet based library table allows us to +advertise remote libraries without having to issue an update to Kicad.

+ +
Query Language
This is a means of searching for something that is +contained within a container. Since some library sources are remote, it is +important to be able to ask the library source for a part that matches some +criteria, for performance reasons.
+ @@ -154,14 +196,14 @@ Here are some of the changes required: @@ -276,7 +321,7 @@ resolvable. http://msdn.microsoft.com/en-us/library/ms364057%28VS.80%29.aspx Even with NRVO provided by most C++ compilers, I don't see it being as lean as -having class LIB keep expanded members STRING fetch and STRINGS vfetched for the +having class LIB keep expanded members STRING fetch and STRINGS vfetch for the aResults values. But at the topmost API, client convenience is worth a minor sacrifice in speed, so the topmost API does return these complex string objects for convenience. So there is a different strategy underneath the hood than what @@ -294,14 +339,14 @@ library in the new design is LIB.

Show architecture here. - Click here to see an architectural drawing. + Click here to see an architectural drawing. */ /** - * \defgroup STRING Types + * \defgroup string_types STRING Types * Provide some string types for use within the API. * @{ */ @@ -324,10 +369,29 @@ typedef std::dequeue STRING_TOKS; typedef std::dequeue STRINGS; +//typedef std::vector WSTRINGS; + const STRING StrEmpty = ""; -/** @} STRING Types */ +/** @} string_types STRING Types */ + +/** + * \defgroup exception_types Exception Types + * Provide some exception types for use within the API. + * @{ + */ + +/** + * Class PARSE_ERROR + * contains a filename or source description, a line number, a character offset, + * and an error message. + */ +struct PARSE_ERROR : public IO_ERROR +{ +}; + +/** @} exception_types Exception Types */ /** @@ -348,11 +412,13 @@ class PART friend class LIB; - /// a private constructor, only a LIB can instantiate one. + /// a private constructor, only a LIB can instantiate a PART. PART() {} -protected: // not likely to have descendants, but protected none-the-less. +protected: // not likely to have C++ descendants, but protected none-the-less. + + bool parsed; ///< true if the body as been parsed already. LIB* owner; ///< which LIB am I a part of (pun if you want) STRING extends; ///< LPID of base part @@ -363,7 +429,21 @@ protected: // not likely to have descendants, but protected none-the-less. /// actually becomes cached in RAM. STRING body; - // lots of other stuff. + // 3 separate lists for speed: + + /// A property list. + PROPERTIES properties; + + /// A drawing list for graphics + DRAWINGS drawings; + + /// A pin list + PINS pins; + + /// Alternate body forms. + ALTERNATES alternates; + + // lots of other stuff, like the mandatory properties. public: @@ -371,16 +451,25 @@ public: /** * Function Inherit * is a specialized assignment function that copies a specific subset, enough - * to fulfill the requirements of the sweet s-expression language. + * to fulfill the requirements of the Sweet s-expression language. */ void Inherit( const PART& aBasePart ); + /** * Function Owner * returns the LIB* owner of this part. */ LIB Owner() { return owner; } + /** + * Function Parse + * translates the \a body string into a binary form that is represented + * by the normal fields of this class. Parse is expected to call Inherit() + * if this part extends any other. + */ + void Parse( DSN_LEXER* aLexer ) throw( PARSE_EXCEPTION ); + }; @@ -388,7 +477,7 @@ public: * Class LPID (aka GUID) * is a Logical Part ID and consists of various portions much like a URI. It * relies heavily on a logical library name to hide where actual physical library - * sources reside. Its static functions serve as managers of the library table to + * sources reside. Its static functions serve as managers of the "library table" to * map logical library names to actual library sources. *

* Example LPID string: @@ -403,12 +492,12 @@ public: * *

* This class owns the library table, which is like fstab in concept and maps logical - * library name to library URI, type, and password. It has the following columns: + * library name to library URI, type, and options. It has the following columns: *

*

* For now, the Library Type can be one of: @@ -429,19 +518,26 @@ public: *

  • "http://kicad.org/partlib" * *

    - * The library table is built up from several sources, and is a concatenation - * of those sources. + * The applicable library table is built up from several additive rows (table fragments), + * and the final table is a merging of the table fragments. Two anticipated sources of + * the rows are a personal table, and a schematic resident table. The schematic + * resident table rows are considered a higher priority in the final dynamically + * assembled library table. A row in the schematic contribution to the library table + * will take precedence over the personal table if there is a collision on logical + * library name, otherwise the rows simply combine without issue to make up the + * applicable library table. */ class LPID // aka GUID { +public: /** * Constructor LPID * takes aLPID string and parses it. A typical LPID string uses a logical * library name followed by a part name. * e.g.: "kicad:passives/R/rev2", or - * e.g.: "me:R33" + * e.g.: "mylib:R33" */ - LPID( const STRING& aLPID = StrEmpty ) throw( PARSE_ERROR ); + LPID( const STRING& aLPID ) throw( PARSE_ERROR ); /** * Function GetLogLib @@ -491,26 +587,40 @@ class LPID // aka GUID * Function GetLogicalLibraries * returns the logical library names, all of them that are in the * library table. + * @param aSchematic provides access to the full library table inclusive + * of the schematic contribution, or may be NULL to exclude the schematic rows. */ - static STRINGS GetLogicalLibraries(); + static STRINGS GetLogicalLibraries( SCHEMATIC* aSchematic=NULL ); /** * Function GetLibraryURI * returns the full library path from a logical library name. + * @param aLogicalLibraryName is the short name for the library of interest. + * @param aSchematic provides access to the full library table inclusive + * of the schematic contribution, or may be NULL to exclude the schematic rows. */ - static STRING GetLibraryURI( const STRING& aLogicalLibraryName ) const; + static STRING GetLibraryURI( const STRING& aLogicalLibraryName, + SCHEMATIC* aSchematic=NULL ) const; /** * Function GetLibraryType * returns the type of a logical library. + * @param aLogicalLibraryName is the short name for the library of interest. + * @param aSchematic provides access to the full library table inclusive + * of the schematic contribution, or may be NULL to exclude the schematic rows. */ - static STRING GetLibraryType( const STRING& aLogicalLibraryName ) const; + static STRING GetLibraryType( const STRING& aLogicalLibraryName, + SCHEMATIC* aSchematic=NULL ) const; /** - * Function GetPassword - * returns the password for this type of a logical library. + * Function GetOptions + * returns the options string for \a aLogicalLibraryName. + * @param aLogicalLibraryName is the short name for the library of interest. + * @param aSchematic provides access to the full library table inclusive + * of the schematic contribution, or may be NULL to exclude the schematic rows. */ - static STRING GetPassword( const STRING& aLogicalLibraryName ) const; + static STRING GetPassword( const STRING& aLogicalLibraryName, + SCHEMATIC* aSchematic=NULL ) const; }; @@ -584,9 +694,10 @@ protected: ///< derived classes must implement * the actual library data is remotely located, otherwise it will be too slow * to honor this portion of the API contract. * - * @param aQuery is a string holding a domain specific language expression. One candidate - * here is an s-expression that uses (and ..) and (or ..) operators. For example - * "(and (footprint 0805)(value 33ohm)(category passives))" + * @param aQuery is a string holding a domain specific query language expression. One candidate + * here is an s-expression that uses (and ..) and (or ..) operators and uses them as RPN. For example + * "(and (footprint 0805)(value 33ohm)(category passives))". + * The UI can shield the user from this if it wants. * * @param aResults is a place to put the fetched part names, one part per STRING. */ @@ -599,28 +710,6 @@ protected: }; -/** - * Class DIR_LIB_SOURCE - * implements a LIB_SOURCE in a file system directory. - */ -class DIR_LIB_SOURCE : public LIB_SOURCE -{ - friend class LIBS; ///< LIBS::GetLib() can construct one. - -protected: - - /** - * Constructor DIR_LIB_SOURCE( const STRING& aDirectoryPath ) - * sets up a LIB_SOURCE using aDirectoryPath in a file system. - * @see LIBS::GetLibrary(). - * - * @param aDirectoryPath is a full pathname of a directory which contains - * the library source of part files. Examples might be "C:\kicad_data\mylib" or - * "/home/designer/mylibdir". - */ - DIR_LIB_SOURCE( const STRING& aDirectoryPath ) throws( IO_ERROR ); -}; - /** * Class SVN_LIB_SOURCE @@ -646,17 +735,18 @@ protected: /** - * Class PARTS_LIST_LIB_SOURCE - * implements a LIB_SOURCE in a schematic file. + * Class SCHEMATIC_LIB_SOURCE + * implements a LIB_SOURCE in by reading a parts list from schematic file + * unrelated to the schematic currently being edited. */ -class PARTS_LIST_LIB_SOURCE : public LIB_SOURCE +class SCHEMATIC_LIB_SOURCE : public LIB_SOURCE { friend class LIBS; ///< constructor the LIB uses these functions. protected: /** - * Constructor PARTS_LIST_LIB_SOURCE( const STRING& aSchematicFile ) + * Constructor SCHEMATIC_LIB_SOURCE( const STRING& aSchematicFile ) * sets up a LIB_SOURCE using aSchematicFile which is a full path and filename * for a schematic not related to the schematic being editing in * this EESCHEMA session. @@ -665,7 +755,7 @@ protected: * @param aSchematicFile is a full path and filename. Example: * "/home/user/kicadproject/design.sch" */ - PARTS_LIST_LIB_SOURCE( const STRING& aSchematicFile ) throws( IO_ERROR ); + SCHEMATIC_LIB_SOURCE( const STRING& aSchematicFile ) throws( IO_ERROR ); }; @@ -688,8 +778,10 @@ protected: ///< derived classes must implement * portion present. If it is not present, and a overwrite of an existhing * part is done, then LIB::ReloadPart() must be called on this same part * and all parts that inherit it must be reparsed. + * @return STRING - if the LIB_SINK support revision numbering, then return a + * evision name that was next in the sequence, e.g. "rev22", else StrEmpty. */ - virtual void WritePart( const STRING& aPartName, + virtual STRING WritePart( const STRING& aPartName, const STRING& aSExpression ) throw( IO_ERROR ) = 0; @@ -795,7 +887,7 @@ public: * returns true if this library has write/save capability. Most LIBs * are read only. */ - bool HasSave() { return sink != NULL; } + bool HasSink() { return sink != NULL; } /** * Function LogicalName @@ -841,17 +933,10 @@ public: /** * Function WritePart - * saves the part to non-volatile storage. @a aPartName may have the revision - * portion present. If it is not present, and a overwrite of an existing - * part is done, then all parts that inherit it must be re-parsed. - * This is why most library sources are read only. An exception is the PARTS_LIST, - * not to be confused with a LIB based on a parts list in another schematic. - * The PARTS_LIST is in the the schematic being edited and is by definition the - * last to inherit, so editing in the current schematic's PARTS_LIST should be harmless. - * There can be some self referential issues that mean all the parts in the PARTS_LIST - * have to re-parsed. + * saves the part to non-volatile storage and returns the next new revision + * name in the sequence established by the LIB_SINK. */ - virtual void WritePart( PART* aPart ) throw( IO_ERROR ); + virtual STRING WritePart( PART* aPart ) throw( IO_ERROR ); virtual void SetPartBody( PART* aPart, const STRING& aSExpression ) throw( IO_ERROR ); @@ -884,8 +969,8 @@ public: private: - STRING fetch; ///< scratch, used to fetch things, grows to worst case size. - STRINGS vfetch; ///< scratch, used to fetch things. + STRING fetch; // scratch, used to fetch things, grows to worst case size. + STRINGS vfetch; // scratch, used to fetch things. LIB_SOURCE* source; LIB_SINK* sink; @@ -896,11 +981,120 @@ private: STRINGS categories; - typedef boost::ptr_vector PARTS; - PARTS parts; - - std::vector orderByName; }; + +/** + * 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. + */ +class PARTS_LIST : public LIB +{ +public: + + /** + * 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. + */ + SPREADSHEET_TABLE_MODEL* GetModel(); +}; + + +/** + * Class LIB_TABLE_ROW + * holds a record identifying a LIB in the LIB_TABLE. + */ +class LIB_TABLE_ROW +{ + +protected: + + /** + * Function SetLogicalName + * changes the logical name of this library, useful for an editor. + */ + void SetLogicalName( const STRING& aLogicalName ); + + /** + * Function SetType + * changes the type represented by this record. + */ + void SetType( const STRING& aType ); + + /** + * Function SetFullURI + * changes the full URI for the library, useful from a library table editor. + */ + void SetFullURI( const STRING& aFullURI ); + + /** + * Function SetOptions + * changes the options string for this record, and is useful from + * the library table editor. + */ + void SetOptions( const STRING& aOptions ); + + +public: + + /** + * Function GetLogicalName + * returns the logical name of this library table entry. + */ + const STRING& GetLogicalName(); + + + /** + * Function GetType + * returns the type of LIB represented by this record. + */ + const STRING& GetType(); + + /** + * Function GetFullURI + * returns the full location specifying URI for the LIB. + */ + const STRING& GetFullURI(); + + /** + * Function GetOptions + * returns the options string, which may hold a password or anything else needed to + * instantiate the underlying LIB_SOURCE. + */ + const STRING& GetOptions(); +}; + +/** + * Class LIB_TABLE + * holds LIB_TABLE_ROW records, and can be searched in a very high speed way based on + * logical library name. + */ +class LIB_TABLE +{ +public: + + /** + * Constructor LIB_TABLE + * builds a library table from an s-expression form of the library table. + * @param aLibraryTable is an s-expression form of all the rows in a library + * table fragment. These rows take presedence over rows in @a aFallBackTable. + * @param aFallBackTable is another LIB_TABLE which is searched only when + * a record is not found in this table. + */ + LIB_TABLE( const STRING& aLibraryTable, LIB_TABLE* aFallBackTable = NULL ) + { + // s-expression is chosen so we can read a table fragment from either + // a schematic or a disk file, for schematic resident or + // personal table, respectively. + } +}; + +} // namespace SCH + + // EOF diff --git a/new/drawing.png b/new/drawing.png new file mode 100644 index 0000000000..eea6114d67 Binary files /dev/null and b/new/drawing.png differ diff --git a/new/drawing.svg b/new/drawing.svg new file mode 100644 index 0000000000..1afc681570 --- /dev/null +++ b/new/drawing.svg @@ -0,0 +1,964 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + schematic + + HTTP_LIB_SOURCE + + + + comp + + + + + + parts_list + + + + + part + + + + + + part + + + + + + part + + + + + + comp + + + + + + comp + + + + + + part + + + + LIBS manager + + + is + + + + is + + + + is + + + extends + + + + part + + + + + + part + + + + + + part + + + + + extends + extends + + extends + + DIR_LIB_SOURCE + SCHEMATIC_LIB_SOURCE + + + + + + + + part + + + + + + part + + + All sheets are in one schematic object + + + + + part + + + + + + part + + + other schematic + + Internet + + LIB + + part files in a dir + LIB + LIB + + + + part + + + + + + part + + + + LIB + + diff --git a/new/make-html.sh b/new/make-html.sh new file mode 100755 index 0000000000..67f03c4b66 --- /dev/null +++ b/new/make-html.sh @@ -0,0 +1,3 @@ + +# run this from the /new directory +doxygen diff --git a/new/sch_dir_lib_source.cpp b/new/sch_dir_lib_source.cpp new file mode 100644 index 0000000000..ad88bac9b5 --- /dev/null +++ b/new/sch_dir_lib_source.cpp @@ -0,0 +1,134 @@ + +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2010 SoftPLC Corporation, + * Copyright (C) 2010 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DIR_LIB_SOURCE_H_ +#define DIR_LIB_SOURCE_H_ + + +/* Note: this LIB_SOURCE implementation relies on the posix specified opendir() and + related functions. Mingw and unix, linux, & osx will all have these posix functions. + MS Visual Studio may need the posix compatible opendir() functions brought in + http://www.softagalleria.net/dirent.php + wx has these but they are based on wxString and wx should not be introduced + at a level this low. +*/ + + + +namespace SCH { + + +/** + * Class DIR_LIB_SOURCE + * implements a LIB_SOURCE in a file system directory. + * + * @author Dick Hollenbeck + */ +class DIR_LIB_SOURCE : public LIB_SOURCE +{ + friend class LIBS; ///< LIBS::GetLib() can construct one. + + STRING path; ///< base directory path of LIB_SOURCE + + +protected: + + /** + * Constructor DIR_LIB_SOURCE( const STRING& aDirectoryPath ) + * sets up a LIB_SOURCE using aDirectoryPath in a file system. + * @see LIBS::GetLibrary(). + * + * @param aDirectoryPath is a full pathname of a directory which contains + * the library source of part files. Examples might be "C:\kicad_data\mylib" or + * "/home/designer/mylibdir". + */ + DIR_LIB_SOURCE( const STRING& aDirectoryPath ) throws( IO_ERROR, PARSE_ERROR ); + + +}; + +} // namespace SCH + +#endif // DIR_LIB_SOURCE_H_ + + + +#include +#include +#include + +#include + + +/** + * Class DIR_WRAP + * provides a destructor which may be invoked if an exception is thrown, + * thereby closing the DIR. + */ +class DIR_WRAP +{ + DIR* dir; + +public: + DIR_WRAP( DIR* aDir ) : dir( aDir ) {} + + ~DIR_WRAP() + { + if( dir ) + closedir( dir ); + } + + DIR* operator->() { return dir; } +}; + + +DIR_LIB_SOURCE::DIR_LIB_SOURCE( const STRING& aDirectoryPath ) throws( IO_ERROR, PARSE_ERROR ) +{ + DIR_WRAP* dir = opendir( aDirectoryPath.c_str() ); + + if( !dir ) + { + char buf[256]; + + strerror_r( errno, buf, sizeof(buf) ); + throw( IO_ERROR( buf ) ); + } + + path = aDirectoryPath; + + +} + + + +#if 1 || defined( TEST_DIR_LIB_SOURCE ) + +int main( int argv, char** argv ) +{ +} + +#endif + +