Commit 7798e51d authored by Dick Hollenbeck's avatar Dick Hollenbeck

more /new work, create a place for Wayne to work on PART::Parser()

parents 916f80f1 364132cb
......@@ -6,6 +6,8 @@ eeschema/cmp_library_keywords.*
eeschema/template_fieldnames_keywords.*
eeschema/template_fieldnames_lexer.h
new/html
new/sch_lib_table_keywords.cpp
new/sch_lib_table_lexer.h
pcbnew/dialogs/dialog_freeroute_exchange_help_html.h
Makefile
CMakeFiles
......
......@@ -120,6 +120,7 @@ mark_as_advanced(KICAD_BIN
KICAD_DEMOS
KICAD_TEMPLATE)
include(Functions)
#================================================
# Find libraries that are needed to build KiCad.
......
# 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 AUTHORS.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
#
# Function make_lexer
# is a standard way to invoke TokenList2DsnLexer.cmake
function( make_lexer inputFile outHeaderFile outCppFile enum )
add_custom_command(
OUTPUT ${outHeaderFile}
${outCppFile}
COMMAND ${CMAKE_COMMAND}
-Denum=${enum}
-DinputFile=${inputFile}
-DoutHeaderFile=${outHeaderFile}
-DoutCppFile=${outCppFile}
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
DEPENDS ${inputFile}
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
COMMENT "TokenList2DsnLexer.cmake creating:
${outHeaderFile} and
${outCppFile} from
${inputFile}"
)
endfunction()
......@@ -144,8 +144,8 @@ set( sourceFileHeader
* your DSN lexer.
*/
#include \"fctsys.h\"
#include \"macros.h\"
//#include \"fctsys.h\"
//#include \"macros.h\"
#include \"${result}_lexer.h\"
......@@ -241,9 +241,9 @@ public:
/**
* Constructor ${RESULT}_LEXER
* takes @a aFile already opened for reading and @a aFilename as parameters.
* The opened file is not closed by this class, and is assumed to be positioned
* at the beginning of the file for purposes of accurate line number reporting
* in error messages.
* The opened file is assumed to be positioned at the beginning of the file
* for purposes of accurate line number reporting in error messages. The
* FILE is closed by this instance when its destructor is called.
* @param aFile is a FILE already opened for reading.
* @param aFilename is the name of the opened file, needed for error reporting.
*/
......@@ -333,7 +333,7 @@ class ${RESULT}_PARSER : public ${RESULT}_LEXER
file( APPEND "${outCppFile}"
"};
const unsigned ${result}_keyword_count = DIM( ${result}_keywords );
const unsigned ${result}_keyword_count = unsigned( sizeof( ${result}_keywords )/sizeof( ${result}_keywords[0] ) );
} // End namespace DSN
"
......
......@@ -105,25 +105,11 @@ set(PCB_COMMON_SRCS
add_library(pcbcommon ${PCB_COMMON_SRCS})
# auto-generate netlist_lexer.h and netlist_keywords.cpp
set( inputFile ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords )
set( outHeaderFile ${PROJECT_SOURCE_DIR}/include/netlist_lexer.h )
set( outCppFile ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp )
set( enum NL_T )
add_custom_command(
OUTPUT ${outHeaderFile}
${outCppFile}
COMMAND ${CMAKE_COMMAND}
-Denum=${enum}
-DinputFile=${inputFile}
-DoutHeaderFile=${outHeaderFile}
-DoutCppFile=${outCppFile}
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
COMMENT "TokenList2DsnLexer.cmake creating:
${outHeaderFile} and
${outCppFile} from
${inputFile}"
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
${PROJECT_SOURCE_DIR}/include/netlist_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp
NL_T
)
# The dsntest may not build properly using MS Visual Studio.
......
......@@ -170,47 +170,18 @@ endif(APPLE)
# auto-generate cmp_library_lexer.h and cmp_library_keywords.cpp for the component
# library format.
set( inputFile ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords )
set( outHeaderFile ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h )
set( outCppFile ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp )
set( enum TLIB_T )
add_custom_command(
OUTPUT ${outHeaderFile}
${outCppFile}
COMMAND ${CMAKE_COMMAND}
-Denum=${enum}
-DinputFile=${inputFile}
-DoutHeaderFile=${outHeaderFile}
-DoutCppFile=${outCppFile}
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
COMMENT "TokenList2DsnLexer.cmake creating:
${outHeaderFile} and
${outCppFile} from
${inputFile}"
)
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp
TLIB_T
)
set( inputFile ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords )
set( outHeaderFile ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_lexer.h )
set( outCppFile ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_keywords.cpp )
set( enum TFIELD_T )
add_custom_command(
OUTPUT ${outHeaderFile}
${outCppFile}
COMMAND ${CMAKE_COMMAND}
-Denum=${enum}
-DinputFile=${inputFile}
-DoutHeaderFile=${outHeaderFile}
-DoutCppFile=${outCppFile}
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
COMMENT "TokenList2DsnLexer.cmake creating:
${outHeaderFile} and
${outCppFile} from
${inputFile}"
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords
${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_keywords.cpp
TFIELD_T
)
add_executable(eeschema WIN32 MACOSX_BUNDLE ${EESCHEMA_SRCS} ${EESCHEMA_EXTRA_SRCS}
......
......@@ -2,6 +2,7 @@
#include "template_fieldnames.h"
#include "dsnlexer.h"
#include "fctsys.h"
#include "macros.h"
using namespace DSN; // enum TFIELD_T is in this namespace
......
......@@ -29,7 +29,7 @@
#include <string>
#include <boost/ptr_container/ptr_vector.hpp>
#include "fctsys.h"
//#include "fctsys.h"
#include "richio.h"
......
......@@ -40,6 +40,8 @@ if( STAND_ALONE )
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
endif(CMAKE_COMPILER_IS_GNUCXX)
include(Functions)
endif()
......@@ -59,8 +61,19 @@ endif()
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
add_executable( test_dir_lib_source sch_dir_lib_source.cpp )
#add_executable( test_dir_lib_source EXCLUDE_FROM_ALL sch_dir_lib_source.cpp )
target_link_libraries( test_dir_lib_source ${wxWidgets_LIBRARIES} )
#target_link_libraries( test_dir_lib_source common ${wxWidgets_LIBRARIES} )
add_executable( test_lib_table sch_lib_table.cpp sch_lib_table_keywords.cpp )
target_link_libraries( test_lib_table ${wxWidgets_LIBRARIES} )
add_executable( test_sch_part sch_part.cpp )
target_link_libraries( test_lib_table ${wxWidgets_LIBRARIES} )
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table.keywords
${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table_keywords.cpp
ELT_T
)
......@@ -371,84 +371,6 @@ const STRING StrEmpty = "";
/** @} exception_types Exception Types */
/**
* 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( DSN_LEXER* aLexer ) throw( PARSE_EXCEPTION );
};
/**
* Class LPID (aka GUID)
......@@ -601,8 +523,6 @@ public:
};
/**
* Class SVN_LIB_SOURCE
* implements a LIB_SOURCE in a subversion repository.
......@@ -651,56 +571,6 @@ protected:
};
/**
* Class LIBS
* houses a handful of functions that manage all the RAM resident LIBs, and
* provide for a global part lookup function, GetPart(), which can be the basis
* of a cross LIB hyperlink.
*/
class LIBS
{
public:
/**
* Function GetPart
* finds and loads a PART, and parses it. As long as the part is
* accessible in any LIB_SOURCE, opened or not opened, this function
* will find it and load it into its containing LIB, even if that means
* having to load a new LIB as given in the library table.
*/
static PART* GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR );
/**
* Function GetLib
* is first a lookup function and then if needed, a factory function.
* If aLogicalLibraryName has been opened, then return the already opened
* LIB. If not, then instantiate the library and fill the initial
* library PARTs (unparsed) and categories, and add it to LIB::libraries
* for future reference.
*/
static LIB* GetLib( const STRING& aLogicalLibraryName ) throw( IO_ERROR );
/**
* Function GetOpenedLibNames
* returns the logical library names of LIBs that are already opened.
* @see LPID::GetLogicalLibraries()
*/
static STRINGS GetOpendedLogicalLibNames();
/**
* Function CloseLibrary
* closes an open library @a aLibrary and removes it from class LIBS.
*/
static void CloseLibrary( LIB* aLibrary ) throw( IO_ERROR );
private:
/// collection of LIBs, searchable by logical name.
static std::map< STRING, LIB* > libraries; // owns the LIBs.
};
/**
* Class PARTS_LIST
* is a LIB which resides in a SCHEMATIC, and it is a table model for a
......@@ -721,94 +591,6 @@ public:
};
/**
* 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
......
#!/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
......@@ -62,6 +62,20 @@ using namespace SCH;
#include <vector>
using namespace std;
/// This file extension is an implementation detail specific to this LIB_SOURCE
/// implementation, and to a corresponding LIB_SINK.
/// Core EESCHEMA should never have to see this.
#define SWEET_EXT ".part"
/* __func__ is C99 prescribed, but just in case:
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=338
#if defined(__GNUG__) // The GNU C++ compiler defines this
#define FUNC_NAME(x) // nothing, GNU C++ defines __func__ just fine.
#else
#define FUNC_NAME(x) static const char __func__[] = #x;
#endif
*/
/**
......@@ -140,7 +154,7 @@ static const char* endsWithRev( const char* start, const char* tail, char separa
{
bool sawDigit = false;
while( tail>start && isdigit(*--tail) )
while( tail > start && isdigit( *--tail ) )
{
sawDigit = true;
}
......@@ -202,6 +216,7 @@ bool BY_REV::operator() ( const STRING& s1, const STRING& s2 ) const
int rnum1 = atoi( rev1+3 );
int rnum2 = atoi( rev2+3 );
// higher numbered revs are "less" so that they bubble to top.
return rnum1 > rnum2;
}
......@@ -212,9 +227,9 @@ bool BY_REV::operator() ( const STRING& s1, const STRING& s2 ) const
bool DIR_LIB_SOURCE::makePartName( STRING* aPartName, const char* aEntry,
const STRING& aCategory )
{
const char* cp = strrstr( aEntry, ".part" );
const char* cp = strrstr( aEntry, SWEET_EXT );
// if base name is not empty, contains ".part", && cp is not NULL
// if base name is not empty, contains SWEET_EXT, && cp is not NULL
if( cp > aEntry )
{
const char* limit = cp + strlen( cp );
......@@ -222,7 +237,7 @@ bool DIR_LIB_SOURCE::makePartName( STRING* aPartName, const char* aEntry,
// If versioning, then must find a trailing "revN.." type of string.
if( useVersioning )
{
const char* rev = endsWithRev( cp + sizeof(".part") - 1, limit, '.' );
const char* rev = endsWithRev( cp + sizeof(SWEET_EXT) - 1, limit, '.' );
if( rev )
{
if( aCategory.size() )
......@@ -241,7 +256,7 @@ bool DIR_LIB_SOURCE::makePartName( STRING* aPartName, const char* aEntry,
// so we don't even bother to try and load any other partfile down here.
else
{
// if file extension is exactly ".part", and no rev
// if file extension is exactly SWEET_EXT, and no rev
if( cp==limit-5 )
{
if( aCategory.size() )
......@@ -272,13 +287,14 @@ STRING DIR_LIB_SOURCE::makeFileName( const STRING& aPartName )
{
int basePartLen = rev - aPartName.c_str() - 1; // omit '/' separator
fileName.append( aPartName, 0, basePartLen );
fileName += ".part."; // add '.' separator before rev
fileName += SWEET_EXT;
fileName += '.';
fileName += rev;
}
else
{
fileName += aPartName;
fileName += ".part";
fileName += SWEET_EXT;
}
return fileName;
......@@ -370,7 +386,7 @@ void DIR_LIB_SOURCE::GetCategoricalPartNames( STRINGS* aResults, const STRING& a
partnames.end();
PN_ITER it = aCategory.size() ?
partnames.lower_bound( aCategory + "/" ) :
partnames.upper_bound( aCategory + "/" ) :
partnames.begin();
aResults->clear();
......@@ -408,7 +424,6 @@ void DIR_LIB_SOURCE::GetCategoricalPartNames( STRINGS* aResults, const STRING& a
void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const STRING& aRev )
throw( IO_ERROR )
{
STRING fileName;
STRING partName = aPartName; // appended with aRev too if not empty
const char* rev = endsWithRev( partName, '/' );
......@@ -441,8 +456,9 @@ void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const S
{
STRING search = partName + '/';
// no rev on partName string. First the first, which should be
// the highnest numbered rev because of BY_REV compare method.
// There's no rev on partName string. Find the most recent rev, i.e. highest,
// which will be first because of the BY_REV compare method, which treats
// higher numbered revs as first.
PN_ITER it = partnames.upper_bound( search );
// verify that this one that is greater than partName is a match and not
......@@ -582,9 +598,9 @@ int main( int argc, char** argv )
// initially, only the NAME_CACHE sweets and STRING categories are loaded:
uut.Show();
uut.GetCategoricalPartNames( &partnames, "Category" );
uut.GetCategoricalPartNames( &partnames, "lions" );
printf( "\nGetCategoricalPartNames( aCatagory = 'Category' ):\n" );
printf( "\nGetCategoricalPartNames( aCatagory = 'lions' ):\n" );
for( STRINGS::const_iterator it = partnames.begin(); it!=partnames.end(); ++it )
{
printf( " '%s'\n", it->c_str() );
......@@ -592,7 +608,7 @@ int main( int argc, char** argv )
uut.ReadParts( &sweets, partnames );
printf( "\nSweets for Category = 'Category' parts:\n" );
printf( "\nSweets for Category = 'lions' parts:\n" );
pn = partnames.begin();
for( STRINGS::const_iterator it = sweets.begin(); it!=sweets.end(); ++it, ++pn )
{
......@@ -632,4 +648,3 @@ int main( int argc, char** argv )
}
#endif
......@@ -231,6 +231,8 @@ protected: // constructor is not public, called from LIBS only.
{
}
public:
~LIB()
{
delete source;
......@@ -238,8 +240,6 @@ protected: // constructor is not public, called from LIBS only.
}
public:
/**
* Function HasSink
* returns true if this library has write/save capability. Most LIBs
......@@ -348,5 +348,4 @@ protected:
const STRING StrEmpty = "";
#endif // SCH_LIB_H_
#endif // SCH_LIB_H_
/*
* 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;
}
/*
* 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_
lib_table
logical
type
full_uri
options
/*
* 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
/*
* 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_
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