[Ktechlab-devel] More on Document / Simulator interface
Julian Bäume
julian at svg4all.de
Sun Jan 3 05:07:08 UTC 2010
Moin,
On Sunday 03 January 2010 02:56:42 P Zoltan wrote:
> Here is some code, describing the interfaces between the simulator and
> document:
> http://sourceforge.net/userapps/trac/zoltan_padrah/wiki/KtechlabDocumentPr
> oposed
>
> We should discuss about it. There are some fixme-s and todo-s, too.
Concerning the float/double question:
on most (all?) of our target platforms, float will have single-precision,
where double offers double-precision. Of course, size differs and float might
be faster on embedded platforms, like arm. I think, as long as we don't
encounter any performance issues, because of matrices with really large
dimensions, we should use double. This will prevent us from any unwanted
precision issues (at least in a better way float does ;))
Concerning the ISimulator * IPin::setVoltage(float, ISimulator *):
Another way to prevent the unwanted external usage of this method is not to
export it as public. We could just make it protected and define ISimulator as
a friend class. This way, ISimulator can set these values and we don't need to
pass a pointer every time this method is called. This way will also keep the
API more clean.
Why is IPin::isLogicPin() needed? Such methods raise some alarm bells in my
brain, because they are mostly needed to fix bad design. Same question for
IElectronicModel::isNonLinear() and IElectronicModel::isReactive(). May be, we
need these methods, I just want to make sure.
There are quite a few methods with the type of "numberOf...". This should IMHO
be expressed in another way. We should provide access to the internal lists
(however they are stored internally) and use count() or size() methods on
these lists. This will be a more flexible solution, since we might want to
iterate all list items anyway (somewhere) and will need these methods.
Example:
instead of ISimulatedDocument myDoc; int wireCount = myDoc.numberOfWires();
you just write:
ISimulatedDocument myDoc; int wireCount = myDoc.wires().count();
This will keep the API more clean and it is readable, too. (Read it as:
"myDoc, give me a list of all your wires and count them for me")
One last note for actual implementation: Interfaces in c++ don't have to be
pure-virtual, as in Java. For example, IWire can be implemented in the
interface. No need to sub-class anything, because everything this class does
is straight-forward. (Just sub-class, if you want to change any behaviour.)
Well, that's all I have to say, for now. :)
May be, we should move this API discussion to git, soon. This way, we can
track changes and express our changes and thoughts in form of patches. I
agree, that sf.net doesn't provide the best front-ends for git to do code-
review. I hope, I can come up with a better solution, soon. We could use trac
hosted by sf.net, but I think, trac's git support is still somewhat poor.
bye then
julian
PS: thanks for your work! I appreciate to see some progress going on.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/ktechlab-devel/attachments/20100103/3482cf9e/attachment.sig>
More information about the Ktechlab-devel
mailing list