Re: [Crystal-cvs] SF.net SVN: crystal:[39676] CS/branches/soc2013/culling

res <[email protected]> Mon, 02 Sep 2013 19:00:30 +0200
Newsgroups gmane.comp.graphics.crystalspace.devel
Message-ID <[email protected]>
On 30.08.2013 16:14, [email protected] wrote:
> @@ -164,29 +238,82 @@
>   * calculation only once. This is more efficient and it also generates
>   * a better tree as more information is available then.
>   */
> -class CS_CRYSTALSPACE_EXPORT csKDTree :
> -  public scfImplementation1<csKDTree, iDebugHelper>
> +template<class Child>
> +class KDTree : public scfImplementation1<KDTree<Child>, iDebugHelper>
>  {
> +  struct iObjectDescriptor : public virtual iBase
> +  {
> +    SCF_INTERFACE (iObjectDescriptor, 0, 0, 1);
> +
> +    virtual csPtr<iString> DescribeObject (Child* child) = 0;
> +  };

On first sight, this looks like it could be problematic at runtime –
different specializations of iObjectDescriptor are not
“QueryInterface-safe”:
The problem is that _all_ specializations return the same interface ID
(for “iObjectDescriptor”); thus, if you ask a class that implements
KDTree<X>::iObjectDescriptor for the interface
KDTree<Y>::iObjectDescriptor, you'll get something back – but an <X>
interface, not the <Y> interface you asked for…

Unfortunately, templated interfaces are somewhat cumbersome to support
(see the iArray*<> interfaces for a practical example).
But maybe an SCF-interface isn't needed?
Since this is a template already, the templating ObjectDescriptor could
work well here. Same for UserData.
(The compatibility typedefs would then use csRef<…>s for these arguments.)

-f.r.

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk

_______________________________________________
Crystal-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-develop
signature.asc (application/pgp-signature, 263 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlIkxDIACgkQNCTzcE/07exrYgCcDOen4BRhl1ARJJbmk3TuQw5l
dNMAn2pEll1z0dx8Yrkg9gtSYwxX5W0j
=5xMD
-----END PGP SIGNATURE-----