From: John M. <jo...@eb...> - 2012-09-25 10:50:12
|
Hi Egon, Yep I got the update have just tested and works as expected. I had to replace enum IDoubleBondStereo..Stereo with Conformation in the test but otherwise it worked as expected. As I understood form the last mail you're happy to renamed it Conformation - either way I'm happy to sign off just need one that will compile. I had a quick go at using a visitor to confer the stereo elements - I haven't added documentation yet but have knocked up a working implementation. It allows us to replace all the if else's in the InChIGenerator and process all the stereo elements in a single loop. > IStereoElementVisitor<IStereoElement, JniInchiStereo0D, CDKException> visitor = > new StereoElementDispatcher<JniInchiStereo0D>( > new DoubleBondStereoElementVisitor(atomMap), > new TetrahedralStereoElementVisitor(input, atomMap), > new AtomParityVisitor(input, atomMap)); > > // Process all stereo elements > for (IStereoElement stereoElem : atomContainer.stereoElements()) { > input.addStereo0D(stereoElem.accept(visitor)); > } There is probably some overhead of doing the dispatch but I would imagine it is very little and doing the expensive 'instanceof' only once per class (opposed to each instance) might actually be quicker. One thing I couldn't work out was how to use CDKException in the interfaces so I used some generics magic to get the visitors to throw the correct exception on the 'accept()' method but that might be a little confusing. I have tested and the new stereo tests for InChI generator are still working. J Here's the patches (requires the IDoubleBond patch and the InChI Double bond patch): |