RE: C++ Draw Callback?

New Message Reply Date view Thread view Subject view Author view

BOCCARA Michael (MICHAEL.BOCCARA++at++siege.aerospatiale.fr)
Thu, 28 Nov 1996 15:12:08 +0100


      I also wondered this question about callback functions as class member
     methods.
     The type of the callback function is determined by the tyope of the returned
     function a,nd the type of the arguments. A C++ method is also determined by
     the calling class
     an (int*)(pfTraverser*, void*)
     is different type from
     an (int*)pfTruc::(pfTraverser*, void*)
     so the C++ compiler doesn't recognize the function type in setTravFuncs, and
     you know how irrascible C++ is about type matching ...

     What I can advice you is to set a global function as a traversal callback
     (you can set it as a friend), and in that callback call a member function of
     the class. Example :

     class pfBidouille : public pfObject
     (
     public:
       static void init....

     public:
       pfBidouille(void);
       ...

     protected:
     // the member callback
       int preDrawCB(pfTraverser*, void*);

     // the global callback
     friend int _preDrawCB(pfTraverser*, void*);
     );

     pfBidouille::pfBidouille()
     (
        setType...

        setTravFuncs(PFTRAV_DRAW, _preDrawCB, DO_NOTHING);
     )

     int
     _preDrawCB(pfTraverser* trav, void* data)
     (
        pfBidouille *bidouille = (pfBidouille*)trav->getNode();
        return bidouille->preDrawCB(trav, data);
     )

     int
     pfBidouille::preDrawCB(pfTraverser* trav, void* data)
     (
        ... your treatment ...
     )

     If you are a C++ purist, you may be satisfied by this method.
     For my concern, it fits to my object oriented spirit...

     cheers, regards, etc.
     Michael Boccara
     _______________________________________________________________________________
     _
     De: P=INTERNET; DDA.TYPE=RFC-822; DDA.VALUE=guest(a)holodeck.csd.sgi.com le
     Jeu 28 Nov 1996 1:05
     Objet: C++ Draw Callback?
     A: P=INTERNET; DDA.TYPE=RFC-822; DDA.VALUE=info-performer(a)sgi.com; BOCCARA
     Michael
     Fichiers: BDY581.TXT

     RFC-822-Headers:
     Posted-Date: Wed, 27 Nov 1996 23:29:29 GMT
     X-Mailer: ELM [version 2.4 PL25]
     MIME-Version: 1.0
     Content-Type: text/plain; charset=US-ASCII
     Content-Transfer-Encoding: 7bit
     Content-Length: 618

===================================List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:02 PDT

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