dynamic casting

New Message Reply Date view Thread view Subject view Author view

Larry Ramey (ramey++at++ccpo.odu.edu)
Tue, 15 Dec 1998 09:58:31 -0500


pfPeople->hello(),

        I am genrateing a configureable VR program and have run across this
issue....
I have regestered a Callback wich a switch node. In the callback
function I get the node from the traverser. _I_ know that this node is a
switch, how do I convince performer that it is a switch?

here is the callback (it is a dumb test, just to prove to myself I can
do this <g>)

int flipSwitch(pfTraverser* trav, void* data){
// pfSwitch* mySwitch = trav->getNode();//PERFORMER REALLY DOESN'T LIKE
THIS
// So I changed it to this

        pfSwitch* mySwitch = (pfSwitch*)trav->getNode();
//which works... but I have real reservations about a type cast (even a
dynamic cast....)

        float time = getTime(); //Gets some global data (from Shared mem)
        int n;
        if(time <= .3)
                n = 0;
        else if(time <=.45)
                n=1;
        else if(time <=.61)
                n=2;
        else if (time <=.88)
                n=3;
        else if (time<=1.0)
                n=4;
        else n=PFSWITCH_OFF;
        mySwitch->setVal(n);
        return NULL;
}

If this faculty doesn't exist I think it should be added. How hard would
it be to add a virtual whatAmI() meathod that wanders down the
inheritance tree and returns this?

        Larry->thanks();

Larry E. Ramey ramey++at++ccpo.odu.edu

"Misery can be a heavy load" -Social Distortion

"All science is either physics or stamp collecting" - Rutherford


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Tue Dec 15 1998 - 06:58:49 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.