Re: Trouble subclassing pfDCS.

New Message Reply Date view Thread view Subject view Author view

Michael Boccara (boccara++at++MIT.EDU)
Mon, 07 Sep 1998 18:04:21 -0700


Ken,

Whenever you have to subclass a pfNode, you have to care about the type mecanism
inherent to Performer.
The node's type is checked at almost every database traversal, and thus you
can't mess with it...

Your subclass should look like that :

(pfSubDCS.h)

class pfSubDCS : public pfDCS
{
  private:
    static pfType *classType;
  public:
    static void init();
    static pfType* getClassType() { return classType; }
    virtual const char* getTypeName(void) const { return "mbGrabBall"; }
   

/* whatever you want */
};

(pfSubDCS.C)

// necessary initialisation of static data
pfType* pfSubDCS::classType = NULL;

void
pfSubDCS::init(void)
{
// once
  if (classType == NULL) {
    pfDCS::init();
    classType =
      new pfType(pfDCS::getClassType(), "pfSubDCS");
  }
}

(main.C)
main()
{
  pfInit();
...
// has to be called for type to be recognized later
  pfSubDCS::init();
...

}

___________________________________________________________________
Michael Boccara Massachusetts Institute of Technology
                    Research Laboratory of Electronics
(617) 253 0005 Virtual Environment Technologies for Training


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Sep 07 1998 - 15:03:41 PDT

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