SoQtObject(3)

πŸ“¦
version 1.6.2 Β· 3 versions
, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

Okay so welcome to SoQtObject(3) from the SoQt manual, bestie ✨ SoQtObject is the common superclass for all SoQt component classes β€” like, every single one. That’s the whole vibe. πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <Inventor/Qt/SoQtObject.h>

Inherited by SoQtComponent, and SoQtDevice.

πŸ’… Public Member Functions

  • virtual SoType getTypeId (void) const =0 β€” pure virtual type-ID getter; full tea is below.
  • SbBool isOfType (SoType type) const β€” checks the object’s type against type; full tea is below.

🫢 Static Public Member Functions

  • static void initClass (void) β€” sets up class-wide init data; details below.
  • static SoType getClassTypeId (void) β€” hands you the SoType for this class; details below.
  • static void init (void) β€” boots the type system; details below.

🌈 Detailed Description 🌈

So SoQtObject is the common superclass for all SoQt component classes. No cap.

The whole reason it’s the superclass of all SoQt device, component and viewer classes is so you can do runtime type checking on the SoQt objects. It’s giving main character energy for the type system πŸ‘‘

You can drop the macro SOQT_OBJECT_HEADER(classname,parentname) inside a class definition header for SoQt extension components, and it automatically provides the necessary definitions for setting up a runtime type system for your extension classes:

#ifndef MYSPECIALVIEWER_H
#define MYSPECIALVIEWER_H

class MySpecialViewer : public SoQtExaminerViewer {
  SOQT_OBJECT_HEADER(MySpecialViewer, SoQtExaminerViewer);
  // [rest of class definition follows]
};

#endif // !MYSPECIALVIEWER_H

Then put the SOQT_OBJECT_SOURCE(classname) macro within the actual implementation source code file to include the necessary code for the runtime type system:

#include <MySpecialViewer.h>

SOQT_OBJECT_SOURCE(MySpecialViewer);

// [rest of class implementation]

Also go peek at the documentation of the SoType class in Coin or Inventor β€” iykyk πŸ’…

πŸ‘‘ Member Function Documentation πŸ‘‘

✨ void SoQtObject::initClass (void ) [static]

This static setup move gets the data that’s common to all instances of this class ready, and it submits the necessary information to the internal SoQt type system. Slay, initialization handled ✨

✨ SoType SoQtObject::getClassTypeId (void ) [static]

This static method returns the SoType object associated with objects of this class. Literally the class’s type-ID hookup 🫢

✨ virtual SoType SoQtObject::getTypeId (void ) const [pure virtual]

This returns the type identification of an object derived from a class inheriting SoQtObject. It’s used for runtime type checking and "downward" casting. It’s pure virtual, so your subclass has to bring its own implementation β€” periodt πŸ’…

Usage example:

void foo(SoQtViewer * comp)
{
  if (comp->getTypeId() == SoQtExaminerViewer::getClassTypeId()) {
    // safe downward cast, knows the type
    SoQtExaminerViewer * exviewer = (SoQtExaminerViewer *)comp;
  }
  else if (comp->getTypeId().isOfType(SoQtFlyViewer::getClassTypeId())) {
    // safe downward cast, knows the type
    SoQtFlyViewer * flyviewer = (SoQtFlyViewer *)comp;
    // then something else
  }
}

Implemented in SoQtComponent.

✨ SbBool SoQtObject::isOfType (SoType type) const

Pass in a SoType type; this returns TRUE if the type of this object is either of the same type or inherited from type. Vibe check for type inheritance βœ…

✨ void SoQtObject::init (void ) [static]

This initializes the type system of SoQtObject, all SoQt device classes and all SoQt components (including viewers). It’s the big type-system glow-up for the whole crew 🌟

πŸ¦‹ Author πŸ¦‹

Generated automatically by Doxygen for SoQt from the source code. Not me writing it by hand, bestie β€” the robots handled this one πŸ€–πŸ’–


Catch you later, bestie 🫢 SoQtObject(3) β€” Version 1.6.2, dated Sat Jan 6 2024 12:20:55. Slay. πŸ’–

πŸ“¦ where this page comes from