kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #39723
Re: Patch: Extract LIB_PART read/write from SCH_LEGACY_PLUGIN_CACHE
-
To:
kicad-developers@xxxxxxxxxxxxxxxxxxx
-
From:
Wayne Stambaugh <stambaughw@xxxxxxxxx>
-
Date:
Wed, 13 Mar 2019 19:11:29 -0400
-
Autocrypt:
addr=stambaughw@xxxxxxxxx; prefer-encrypt=mutual; keydata= mQGiBEM0hxQRBAC2fNh3YOVLu1d5GZ0SbrTNldGiGnCJPLqzEnqFX9v6jmf33TMt6EmSLkl6 Wtfkoj0nVwKxcYmJkA8DX0QAokBkwNIzhSsBzQvthBLIk/5LnPVVKrEXOcL4mUyH1doKlkaE slgJozNa6Av+oavcvD02o1zJOloBbaHlNlyRt7fKswCgtIFlVjWggVH/15KfWk+Qo5JVPbME AIUBAQyL2OAx0n60AWec2WHnO9buHuG0ibtICgUMkE+2MRmYyKwYRdyVwGoIUemFuOyHp0AJ InX4T+vy2E7vkwODqjtMLfIoRkokW74Fi4nrvjlhOAw/vdq/twLbAmR9MOfPTpR4y7kQy1O2 /n+RkkRvh26vTzfbQmrH7cBJhk6aA/9Uwvu3E4zNJgHVZeS0HyWtmR1eOPPRbnkPgJTToX5O KMKzTJI/FX6kT7cFoCamitHrW3BJP4Dx+cMMsa47EGxqVTdbVJ4LjogsXTXxb+0Fn1u4zBdx x3Cer6O7+hqWy7zvpzeC6nSREjqDKa5CgHtv/GLm5uFPOmsjAsnHj2tlBrQmV2F5bmUgU3Rh bWJhdWdoIDxzdGFtYmF1Z2h3QGdtYWlsLmNvbT6IeAQTEQIAOBYhBOffs6CbblRzBkv33BtR cWlZ+CReBQJbFBS2AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEBtRcWlZ+CReMI8A nRbrLkzp7+c2f0vX7sfg4ICX8LAKAJ9uClo4uJajmZa5zZrL2nKdZlUwIrkCDQRDNIcxEAgA gCru+3/aOC6RCjpvYC72wY+d5SmHphC6yeiV2/mOumyt5MLo/Ps2GznZr11JspqFk5K/Zpvp MMLqqjDZ39+50a2iKRQFJ6NlK+hJWMmj6eJygQrCwYo3Gjc6CqfrqUv+8VSnf/i5sIZmtOVA 4ZjML18MuBvMSsNdVLFJd5HNnYb1iOECpvqdPVh/21LLCEw7MUUGGnHBhCrmk2aJe5hFmcSN g4ldBcXrgMQBwf7aMVoobXBMFDb/IENByXn0llB7Gr2IFMRmNS9/p8s/II1Yl2bTqyX4FSz8 cfn7C9KEz7faZ7wzAcpwHFC/zs3JoAjJ0IEKdNUpIwAlKMzT3CzctwADBQf/cxpG28MKyrqk nNmq/8LQLy+x6FSYXBLjxQz9BiBNYeesDZQ6J5UbL1mjpJzMa5tLZypPYo4bbGyR22hrbyDF K7m6AcVaMIJKl98g4ukMutFfAJyRDaREH5Zl/X1P4u1Z/yaAIy9mKaNbaK1/5djNJ5wCTFen TUgAp9xdc30kGkFDdLJFp5uxDY4P0vaZiZdjUCvDM3Zjv5IzpNOfxVqTUBQNUP/BnnKhkk0p DTD6s3X8S+D0rOtEBQ8K0cwERI/E8EFa8nj0TNw4e2MYGR8wg+SxqJ7z5f0zPY0bO6G9DDFB wYCqzzPWGqdAh9vA5971TAbPERtdFybhkurozp2SfYhJBBgRAgAJBQJDNIcxAhsMAAoJEBtR cWlZ+CResHUAniULLCWiT26ieRTl7N2vS6vBo/DuAJ4m7Ss/gyiW6ybTn1ctDXAUgm2QVQ==
-
In-reply-to:
<a5640580-c2e8-afb7-85da-3634fcd503dd@gmail.com>
-
Openpgp:
preference=signencrypt
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1
Brian,
On 3/13/19 6:32 PM, Brian wrote:
> Wayne,
>
>> What exactly are you serializing to and from? If it's just a string
>> saved to a loaded from a database, why not just add public methods to
>> the plugin object to serialize to and from a string?
> My goal is to have my database contain legacy-format symbol data (since
> the new format doesn't exist in code yet -- my goal is not to roll my
> own format or implement a different one, but only to divert what would
> be in a file into a database instead). I chose to encapsulate the way I
> did because:
>
> 1. SCH_LEGACY_PLUGIN_CACHE has no public interface in any header file;
> it is declared and defined solely within sch_legacy_plugin.cpp. (There
> is only a forward declaration in sch_legacy_plugin.h) To do as you
> suggest, I would have to write an entire, correct declaration for
> SCH_LEGACY_PLUGIN_CACHE that my plugin code could see. That seems like
> a lot of extra work just to share a small subset of the functionality.
You only write what you need for each plugin. We have plugins that only
load symbol libraries and will complain if you try to write the library
or read/write the schematic. The library caching technique is
completely up to the implementer.
> 2. My plugin doesn't need any other part of SCH_LEGACY_PLUGIN_CACHE or
> SCH_LEGACY_PLUGIN, as it only handles symbols and not entire schematics
> and has its own caching scheme.
The reason I wrote it this way is because I knew that the current file
format was going to be short lived and I didn't want to expose it any
more than I had to. That being said, I still don't know exactly what
your are parsing and formatting. Is it the full symbol library file
format definition or just LIB_PART definition? If it's just LIB_PART
(which I suspect it is), then there is no need to break out all of the
symbol library file parser code. Only loadPart(), savePart(), and its
dependencies need to be broken out.
> 3. All of the actual serialization code could be static, but is defined
> as member methods on SCH_LEGACY_PLUGIN_CACHE (the only actual member
> variable dependency is version number, which is easily passed as an
> argument). I don't want my plugin to have to instantiate an entire
> SCH_LEGACY_PLUGIN_CACHE just to turn a LIB_PART to/from a string. Ergo,
> LEGACY_PART_READER / LEGACY_PART_WRITER are entirely static.
You could make them static in the SCH_LEGACY_PLUGIN_CACHE as well and
access them through the SCH_LEGACY_PLUGIN as static.
> 4. I could have just copied the entirety of the to/from string code from
> SCH_LEGACY_PLUGIN_CACHE into my plugin's code, but that seemed like the
> wrong thing to do for several reasons; code reuse being the primary.
This code is almost identical to the legacy footprint library code.
It's on my todo list to factor out the common code from these two
objects and create a reusable base object.
>
>> That's how we
>> handled this in the board plugin. I would also prefer to leave the
>> parsing and formatting code in the current file. The formatter part of
>> this is going to go away most likely during v7 development but possibly
>> during v6 development depending upon how fast I can get the new file
>> format implemented.
> A rebuttal:
>
> I believe this is a way in which our underlying coding philosophies
> differ. I am a fan of tight encapsulation and small-as-practical .cpp
> files. While I will occasionally embed trivially-small helper classes
> in the headers/implementations of other classes, I generally tend to
> take a header-and-implementation-per-class approach. The entirety of
> EESCHEMA could live in a single .cpp file, or every function definition
> could be in a separate file. Beyond the requirements of the language,
> how code is divided into files is a religious argument. I'm happy to
> defer to your seniority, but I wanted to explain the reason I made the
> choices I made.
Your coding philosophy is not much different than mine. I just had the
advantage of knowing that half the code in sch_legacy_plugin.cpp/h was
going away and that I didn't want anybody messing with it. That's why
it lives in a single file. The board file format parser and formatter
live in separate files precisely for this reason.
>
> As an aside, having my modifications removing large swaths of
> planned-obsolete code from sch_legacy_plugin.cpp seems like it would
> make your job easier when it comes time to eradicate it from the plugin;
> I've already sifted through and yanked out all of the helper methods.
I agree but once the legacy plugin is truly legacy, it will be frozen
except for bug fixes. I only have to keep an eye on one file to make
sure no one makes any unapproved changes to it. As project lead, that
make my life easier.
>
> As a second aside, having the read/write code for the new s-expression
> format similarly encapsulated would be awfully nice, so that I can
> change my ODBC plugin to use it when it's published, without having to
> go on another refactoring mission, and maintain all the same points as
> mentioned above.
When the new symbol library and schematic file format plugin is written,
the parser and formatter will be split out for general purpose use.
>
>> Also, please do not force the GCC ABI version in the CMake config. You
>> should be passing -DCMAKE_C_FLAGS="-fabi-version=2" and/or
>> -DCMAKE_CXX_FLAGS="-fabi-version=2" on the command line when you call
>> CMake to generate the build files if you need a specific GCC ABI version
>> or any other personal compiler flags. This kind of thing can cause all
>> kind of headaches for developers so it's frowned upon by most projects.
> Understood. On that, I have no argument!
>
> Kind regards,
> -Brian
>>
>> Cheers,
>>
>> Wayne
>>
>> On 3/13/2019 12:16 PM, Brian wrote:
> <snip>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
Follow ups
References