res
2013-09-02 17:00:30 UTC
@@ -164,29 +238,82 @@
* calculation only once. This is more efficient and it also generates
* a better tree as more information is available then.
*/
- 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 * calculation only once. This is more efficient and it also generates
* a better tree as more information is available then.
*/
- 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;
+ };
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.