17 changed files with 497 additions and 306 deletions
-
2.bzrignore
-
1CMakeLists.txt
-
12CMakeModules/TokenList2DsnLexer.cmake
-
24common/CMakeLists.txt
-
51eeschema/CMakeLists.txt
-
1eeschema/template_fieldnames.cpp
-
2include/dsnlexer.h
-
19new/CMakeLists.txt
-
218new/design.h
-
23new/make-dir-lib-source-test-data.sh
-
45new/sch_dir_lib_source.cpp
-
7new/sch_lib.h
-
31new/sch_lib_table.cpp
-
207new/sch_lib_table.h
-
5new/sch_lib_table.keywords
-
42new/sch_part.cpp
-
113new/sch_part.h
@ -0,0 +1,23 @@ |
|||
#!/bin/sh |
|||
|
|||
BASEDIR=/tmp/eeschema-lib |
|||
|
|||
CATEGORIES="lions tigers kitties" |
|||
|
|||
PARTS="eyes ears feet" |
|||
|
|||
REVS="rev1 rev5 rev10" |
|||
|
|||
|
|||
|
|||
for C in ${CATEGORIES}; do |
|||
|
|||
mkdir -p $BASEDIR/$C |
|||
|
|||
for P in ${PARTS}; do |
|||
for R in ${REVS}; do |
|||
echo "#$R: (part $C/$P)" > $BASEDIR/$C/$P.part.$R |
|||
done |
|||
done |
|||
done |
|||
|
|||
@ -0,0 +1,31 @@ |
|||
/*
|
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2010-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* 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 |
|||
*/ |
|||
|
|||
#include <sch_lib_table.h>
|
|||
|
|||
|
|||
int main( int argc, char** argv ) |
|||
{ |
|||
return 0; |
|||
} |
|||
@ -0,0 +1,207 @@ |
|||
/* |
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* 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 SCH_LIB_TABLE_H_ |
|||
#define SCH_LIB_TABLE_H_ |
|||
|
|||
#include <string> |
|||
#include <boost/ptr_container/ptr_set.hpp> |
|||
#include <sch_lib.h> |
|||
|
|||
|
|||
namespace SCH { |
|||
|
|||
class LIB_TABLE_LEXER; |
|||
|
|||
|
|||
/** |
|||
* Class LIB_TABLE |
|||
* holds LIB_TABLE::ROW records, and can be searched in a very high speed |
|||
* way based on logical library name. |
|||
* |
|||
* @author Dick Hollenbeck |
|||
*/ |
|||
class LIB_TABLE |
|||
{ |
|||
public: |
|||
|
|||
/** |
|||
* Class ROW |
|||
* holds a record identifying a LIB in the LIB_TABLE. |
|||
*/ |
|||
class ROW |
|||
{ |
|||
public: |
|||
|
|||
bool operator<( const ROW& other ) const |
|||
{ |
|||
return logicalName < other.logicalName; |
|||
} |
|||
|
|||
/** |
|||
* Function GetLogicalName |
|||
* returns the logical name of this library table entry. |
|||
*/ |
|||
const STRING& GetLogicalName() const |
|||
{ |
|||
return logicalName; |
|||
} |
|||
|
|||
/** |
|||
* Function GetType |
|||
* returns the type of LIB represented by this record. |
|||
*/ |
|||
const STRING& GetType() const |
|||
{ |
|||
return libType; |
|||
} |
|||
|
|||
/** |
|||
* Function GetFullURI |
|||
* returns the full location specifying URI for the LIB. |
|||
*/ |
|||
const STRING& GetFullURI() const |
|||
{ |
|||
return fullURI; |
|||
} |
|||
|
|||
/** |
|||
* Function GetOptions |
|||
* returns the options string, which may hold a password or anything else needed to |
|||
* instantiate the underlying LIB_SOURCE. |
|||
*/ |
|||
const STRING& GetOptions() const |
|||
{ |
|||
return options; |
|||
} |
|||
|
|||
~ROW() |
|||
{ |
|||
delete lib; |
|||
} |
|||
|
|||
protected: |
|||
|
|||
ROW() : |
|||
lib( 0 ) |
|||
{} |
|||
|
|||
/** |
|||
* Function SetLogicalName |
|||
* changes the logical name of this library, useful for an editor. |
|||
*/ |
|||
void SetLogicalName( const STRING& aLogicalName ) |
|||
{ |
|||
logicalName = aLogicalName; |
|||
} |
|||
|
|||
/** |
|||
* Function SetType |
|||
* changes the type represented by this record. |
|||
*/ |
|||
void SetType( const STRING& aType ) |
|||
{ |
|||
libType = aType; |
|||
} |
|||
|
|||
/** |
|||
* Function SetFullURI |
|||
* changes the full URI for the library, useful from a library table editor. |
|||
*/ |
|||
void SetFullURI( const STRING& aFullURI ) |
|||
{ |
|||
fullURI = aFullURI; |
|||
} |
|||
|
|||
/** |
|||
* Function SetOptions |
|||
* changes the options string for this record, and is useful from |
|||
* the library table editor. |
|||
*/ |
|||
void SetOptions( const STRING& aOptions ) |
|||
{ |
|||
options = aOptions; |
|||
} |
|||
|
|||
private: |
|||
STRING logicalName; |
|||
STRING libType; |
|||
STRING fullURI; |
|||
STRING options; |
|||
|
|||
LIB* lib; |
|||
}; |
|||
|
|||
|
|||
/** |
|||
* 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 ) |
|||
throw( PARSE_ERROR ) |
|||
{ |
|||
// 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. |
|||
} |
|||
|
|||
|
|||
protected: |
|||
/** |
|||
* Function Parse |
|||
* fills this object from information in the input stream \a aSpec, which |
|||
* is a DSN_LEXER customized for the grammar needed to describe instances of this object. |
|||
* The entire textual element spec is <br> |
|||
* (lib_table (logical _yourfieldname_)(value _yourvalue_) visible)) |
|||
* |
|||
* <pre> |
|||
* (lib_table |
|||
* (lib (logical "LOGICAL")(type "TYPE")(fullURI "FULL_URI")(options "OPTIONS")) |
|||
* (lib (logical "LOGICAL")(type "TYPE")(fullURI "FULL_URI")(options "OPTIONS")) |
|||
(lib (logical "LOGICAL")(type "TYPE")(fullURI "FULL_URI")(options "OPTIONS")) |
|||
* </pre> |
|||
* |
|||
* When this function is called, the input token stream given by \a aSpec |
|||
* is assumed to be positioned at the '^' in the following example, i.e. just after the |
|||
* identifying keyword and before the content specifying stuff.<br> |
|||
* (lib_table ^ (....) ) |
|||
* |
|||
* @param aSpec is the input token stream of keywords and symbols. |
|||
*/ |
|||
void Parse( LIB_TABLE_LEXER* aLexer ) throw( PARSE_ERROR ); |
|||
|
|||
private: |
|||
|
|||
typedef boost::ptr_set<ROW> ROWS; |
|||
|
|||
ROWS rows; |
|||
}; |
|||
|
|||
} // namespace SCH |
|||
|
|||
#endif // SCH_LIB_TABLE_H_ |
|||
@ -0,0 +1,5 @@ |
|||
lib_table |
|||
logical |
|||
type |
|||
full_uri |
|||
options |
|||
@ -0,0 +1,42 @@ |
|||
/*
|
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#include "sch_part.h"
|
|||
|
|||
using namespace SCH; |
|||
|
|||
void PART::Parse( LIB* aLexer ) throw( PARSE_ERROR ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
#if 1
|
|||
|
|||
int main( int argc, char** argv ) |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
#endif
|
|||
|
|||
@ -0,0 +1,113 @@ |
|||
/* |
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* 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 SCH_PART_H_ |
|||
#define SCH_PART_H_ |
|||
|
|||
#include <sch_lib.h> |
|||
|
|||
|
|||
namespace SCH { |
|||
|
|||
/** |
|||
* Class PART |
|||
* will have to be unified with what Wayne is doing. I want a separate copy |
|||
|
|||
* here until I can get the state management correct. Since a PART only lives |
|||
* within a cache called a LIB, its constructor is private (only a LIB |
|||
* can instantiate one), and it exists in various states of freshness and |
|||
* completeness relative to the LIB_SOURCE within the LIB. |
|||
*/ |
|||
class PART |
|||
{ |
|||
/// LIB class has great license to modify what's in here, nobody else does. |
|||
/// Modification is done through the LIB so it can track the state of the |
|||
/// PART and take action as needed. Actually most of the modification will |
|||
/// be done by PARTS_LIST, a class derived from LIB. |
|||
friend class LIB; |
|||
|
|||
|
|||
/// a private constructor, only a LIB can instantiate a PART. |
|||
PART() {} |
|||
|
|||
|
|||
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 |
|||
|
|||
STRING name; ///< example "passives/R", immutable. |
|||
|
|||
/// s-expression text for the part, initially empty, and read in as this part |
|||
/// actually becomes cached in RAM. |
|||
STRING body; |
|||
|
|||
// 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: |
|||
|
|||
/** |
|||
* Function Inherit |
|||
* is a specialized assignment function that copies a specific subset, enough |
|||
* 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( LIB* aLexer ) throw( PARSE_ERROR ); |
|||
|
|||
}; |
|||
|
|||
} // namespace PART |
|||
|
|||
#endif // SCH_PART_ |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue