So, to implement the Focusmanager I found out, that there is another small technology needed. Basically, I need some kind of an association system to link arbitrary typed instances to the scenegraph nodes. While rendering the scenegraph, this could have multiple uses:
The requirements for such a thing are:
Interesting, before writing this blog entry I was pretty sure that these requirements are some kind of a new thought, but now I see a direct similarity to the COM (common object model) and clones.
Nevertheless, the first implementation suggestion was to implement a std::list of boost::any in the node to support the attachments (thanks to Alex for pointing this out). There are two drawbacks of this solution:
std::list requires an additional memory allocation.boost::any compares types by using RTTI information of C++. It compares the types by calling the == operator of the type_info record, which is implemented as a simple string compare on the gcc and cl compilers (the two I am using at the moment to compile the framework with). This comparison is pretty slow, compared with a simple pointer comparison.So first, I will replace the std::list with the elists I have created (ooops, sorry the documentation and specification of the elists is not yet online, I am working on the last review, but the reference documentation is available from libsmart.com).
Then I need a kind of a type information for each instance needed to be attached. I don’t think I’d like to use RTTI, and so a simple per instance static entry and a templated wrapper will make the type comparisons a simple pointer compare (resulting in a ten times faster queries).
The performance characteristics of the queries are linear. I don’t think that there will be more than 5 attachments per node at any time.
This is the next step to do for my scenegraph evolution, I hopefully have some time the next days to implement it and write a paper about it.
Happy scenegraph dreams.