rgheck wrote:

Attached is my attempt at using type safety to make Layout objects safer to use. I tried several things, and this may well not be best. But other efforts---going back to a vector<Layout *>, e.g.---all had their own problems, usually, that they make iterators behave badly. (In that case, e.g., you have to doubly dereference to use the iterator. E.g.: (*it)->name().) This one simply makes LayoutPtr a thin wrapper around a Layout * and then (a) requires that LayoutPtr objects be passed to Paragraph::setLayout() and (b) makes the LayoutPtr constructor private, so that only TextClass can construct these objects.

By far most of the patch is e.g.: s/layout./layout->/. All the action is in LayoutPtr.h and TextClass.{h,cpp}.

Comments most welcome.

Quite frankly, I don't see the benefit. Type safety is nice to have if possible but it is not mandatory. AFAICS there isn't hundreds of problematic cases so, I'd rather see the problematic cases properly documented in source rather than going this way. Just my humble opinion, I am fine with whatever solution you choose as long as you are comfortable with it ;-)

Abdel.

Reply via email to