polymorphic handles
<p>I have handles of different types inside a hierarchy.</p>

<pre><code>class Handle { common data }
class HandleA : Handle { data specific to a }
class HandleB : Handle { data specific to b }
</code></pre>

<p>Most parts of the code only deal with handles. But some parts ( the "managers" for HandleA/HandleB ) need access to the data in the child classes.
eg:</p>

<pre><code>void ManagerA::DoSomething(Handle handle)
{
    // needs access to data in handleA
}
</code></pre>

<p>Are there any solutions to this that don't involve casting?</p>

<p>My ideas so far:<br />
 - Save the additional data inside a map in ManagerA/B and use the handle to lookup that data (additional hashtable lookup)<br />
 - Have polymorphic methods in the handles  ( handle.DoSomething()) that call the appropiate manager methods (needs an additional pointer in every handle)<br />
 - Screw it and use casts  </p>

<p>Any ideas? Am I missing something?</p>

<p>Thanks</p>
