Type system class Many of the classes in the FreeCAD must have their type information registered before any instances are created (including, but not limited to: App::Feature, App::Property, Gui::ViewProvider ). More...

#include <Type.h>

Public Types

typedef void *(* instantiationMethod) (void)
 

Public Member Functions

void * createInstance (void)
 creates a instance of this type More...
 
unsigned int getKey (void) const
 
const char * getName (void) const
 
const Type getParent (void) const
 
bool isBad (void) const
 
bool isDerivedFrom (const Type type) const
 
bool operator!= (const Type type) const
 
bool operator< (const Type type) const
 
bool operator<= (const Type type) const
 
void operator= (const Type type)
 
bool operator== (const Type type) const
 
bool operator> (const Type type) const
 
bool operator>= (const Type type) const
 
 Type (const Type &type)
 Construction. More...
 
 Type (void)
 A constructor. More...
 
virtual ~Type ()
 Destruction. More...
 

Static Public Member Functions

static Type badType (void)
 
static void * createInstanceByName (const char *TypeName, bool bLoadModule=false)
 creates a instance of the named type More...
 
static const Type createType (const Type parent, const char *name, instantiationMethod method=0)
 
static void destruct (void)
 
static Type fromKey (unsigned int key)
 
static Type fromName (const char *name)
 
static int getAllDerivedFrom (const Type type, std::vector< Type > &List)
 
static int getNumTypes (void)
 
static void importModule (const char *TypeName)
 
static void init (void)
 

Static Protected Member Functions

static std::string getModuleName (const char *ClassName)
 

Detailed Description

Type system class Many of the classes in the FreeCAD must have their type information registered before any instances are created (including, but not limited to: App::Feature, App::Property, Gui::ViewProvider ).

The use of Type to store this information provides lots of various functionality for working with class hierarchies, comparing class types, instantiating objects from classnames, etc etc.

It is for instance possible to do things like this:

void getRightFeature(Base::Base * anode)
{
assert(anode->getTypeId().isDerivedFrom(App::Feature::getClassTypeId()));
if (anode->getTypeId() == Mesh::MeshFeature::getClassTypeId()) {
// do something..
}
else if (anode->getTypeId() == Part::PartFeature::getClassTypeId()) {
// do something..
}
else {
Base::Console().Warning("getRightFeature", "Unknown feature type %s!\n",
anode->getTypeId().getName());
}
}

A notable feature of the Type class is that it is only 16 bits long and therefore should be passed around by value for efficiency reasons.

One important note about the use of Type to register class information: super classes must be registered before any of their derived classes are.

Member Typedef Documentation

◆ instantiationMethod

typedef void*(* Base::Type::instantiationMethod) (void)

Constructor & Destructor Documentation

◆ Type() [1/2]

◆ Type() [2/2]

◆ ~Type()

Type::~Type ( )
virtual

Destruction.

A destructor.

A more elaborate description of the destructor.

Member Function Documentation

◆ badType()

◆ createInstance()

◆ createInstanceByName()

◆ createType()

const Type Type::createType ( const Type  parent,
const char *  name,
instantiationMethod  method = 0 
)
static

◆ destruct()

void Type::destruct ( void  )
static

◆ fromKey()

Type Type::fromKey ( unsigned int  key)
static

References badType().

Referenced by Base::TypePy::fromKey().

◆ fromName()

Type Type::fromName ( const char *  name)
static

References badType().

Referenced by PartGui::Mirroring::accept(), StdCmdAlignment::activated(), Gui::Application::activateWorkbench(), App::ExtensionContainerPy::addExtension(), App::Document::addObjects(), FemGui::ViewProviderFemAnalysis::canDragObject(), Part::AttachExtension::changeAttacherType(), Part::FaceMaker::ConstructFromType(), Gui::SelectionSingleton::countObjectsOfType(), createInstanceByName(), Part::GeometryPy::deleteExtensionOfType(), Gui::Dialog::DlgAddProperty::DlgAddProperty(), Part::AttachExtension::extHandleChangedPropertyName(), App::DocumentPy::findObjects(), Base::TypePy::fromName(), Base::TypePy::getAllDerived(), Base::TypePy::getAllDerivedFrom(), Part::GeometryPy::getExtensionOfType(), PartGui::ViewProviderBoolean::getIcon(), Gui::SelectionSingleton::getObjectsOfType(), Gui::View3DInventorPy::getViewProvidersOfType(), Gui::DAG::FilterOrigin::goFilter(), Gui::DAG::FilterTyped::goFilter(), TechDraw::DrawViewBalloon::handleChangedPropertyName(), PartDesign::Boolean::handleChangedPropertyName(), Fem::FemAnalysis::handleChangedPropertyName(), PartGui::ViewProvider2DObject::handleChangedPropertyType(), App::ExtensionContainerPy::hasExtension(), Part::GeometryPy::hasExtensionOfType(), App::Extension::initExtensionSubclass(), Base::BaseClass::initSubclass(), Base::BaseClassPy::isDerivedFrom(), Base::TypePy::isDerivedFrom(), Gui::SelectionObjectPy::isObjectTypeOf(), Mesh::Exporter::isSupported(), Gui::DocumentPy::mdiViewsOfType(), Gui::Node_Object::Node_Object(), Part::BodyBase::onBeforeChange(), Gui::View3DInventor::OnChange(), Gui::GraphicsView3D::OnChange(), Gui::NavigationStyle::openPopupMenu(), Gui::Dialog::find_transform::operator()(), Gui::Dialog::find_placement::operator()(), Attacher::AttachEnginePy::PyInit(), TechDraw::PropertyCenterLineList::Restore(), Part::PropertyGeometryList::Restore(), TechDraw::PropertyCosmeticVertexList::Restore(), TechDraw::PropertyGeomFormatList::Restore(), TechDraw::PropertyCosmeticEdgeList::Restore(), Part::Primitive::Restore(), Part::Geometry::Restore(), PartDesign::Transformed::Restore(), App::ExtensionContainer::restoreExtensions(), Gui::TreeView::rowsInserted(), Gui::Application::sActivateView(), Gui::Application::sActiveView(), Gui::View3DInventorPy::setNavigationType(), App::PropertyPersistentObject::setValue(), AttacherGui::AttacherGuiPy::sGetModeStrings(), InspectionGui::ViewProviderInspection::updateData(), and InspectionGui::VisualInspection::VisualInspection().

◆ getAllDerivedFrom()

◆ getKey()

unsigned int Base::Type::getKey ( void  ) const

◆ getModuleName()

string Type::getModuleName ( const char *  ClassName)
staticprotected

Referenced by importModule().

◆ getName()

◆ getNumTypes()

int Type::getNumTypes ( void  )
static

◆ getParent()

const Type Type::getParent ( void  ) const

◆ importModule()

◆ init()

void Type::init ( void  )
static

◆ isBad()

◆ isDerivedFrom()

bool Type::isDerivedFrom ( const Type  type) const

References badType(), and getParent().

Referenced by PartDesignGui::TaskDlgSketchBasedParameters::accept(), PartDesignGui::TaskDlgFeatureParameters::accept(), StdCmdGroup::activated(), Gui::Application::activateWorkbench(), App::ExtensionContainerPy::addExtension(), Path::FeaturePathCompoundPy::addObject(), MeshGui::DlgEvaluateMeshImp::addViewProvider(), PartGui::SweepWidget::Private::EdgeSelection::allow(), PartDesignGui::ReferenceSelection::allow(), SketcherGui::FilletSelection::allow(), SketcherGui::ExternalSelection::allow(), Gui::QuantitySpinBox::apply(), PartDesignGui::collectMovableDependencies(), Gui::Document::createView(), MeshGui::ViewProviderMeshCurvature::curvatureInfoCallback(), Sketcher::SketchObject::evaluateSupport(), PartDesign::Body::execute(), TechDraw::DrawViewDetail::execute(), Surface::Filling::execute(), Raytracing::RayFeature::execute(), Raytracing::LuxFeature::execute(), Surface::Extend::execute(), PartDesign::Pipe::execute(), Drawing::FeatureViewSpreadsheet::execute(), TechDraw::DrawViewSpreadsheet::execute(), Robot::Edge2TracObject::execute(), Robot::TrajectoryDressUpObject::execute(), Drawing::FeatureViewPart::execute(), Drawing::FeatureProjection::execute(), Inspection::Feature::execute(), MeshGui::ViewProviderMesh::faceInfoCallback(), MeshGui::ViewProviderMesh::fillHoleCallback(), PartDesign::ProfileBased::getAxis(), InspectionGui::ViewProviderInspection::getIcon(), PartDesign::Feature::getPointFromFace(), TechDraw::ShapeExtractor::getShapesFromObject(), PartDesign::Transformed::getSketchObject(), PartDesign::ProfileBased::getSupportFace(), PartDesign::Mirrored::getTransformations(), PartDesign::MultiTransform::getTransformations(), PartDesign::Scaled::getTransformations(), PartDesign::LinearPattern::getTransformations(), PartDesign::PolarPattern::getTransformations(), AttacherGui::getUIStrings(), PartGui::ViewProvider2DObject::handleChangedPropertyType(), App::ExtensionContainerPy::hasExtension(), Gui::Dialog::DlgPropertyLink::init(), InspectionGui::ViewProviderInspection::inspectCallback(), InspectionGui::ViewProviderInspection::inspectDistance(), Base::BaseClassPy::isDerivedFrom(), Base::TypePy::isDerivedFrom(), Base::BaseClass::isDerivedFrom(), PartDesignGui::isFeatureMovable(), TechDrawGui::QGIProjGroup::itemChange(), PartDesignGui::TaskFeaturePick::makeCopy(), MeshGui::ViewProviderMesh::markPartCallback(), Gui::TreeView::mouseDoubleClickEvent(), Gui::Dialog::DlgMaterialPropertiesImp::on_ambientColor_changed(), Gui::Dialog::DlgMaterialPropertiesImp::on_diffuseColor_changed(), Gui::Dialog::DlgMaterialPropertiesImp::on_emissiveColor_changed(), Gui::Dialog::DlgMaterialPropertiesImp::on_shininess_valueChanged(), Gui::Dialog::DlgMaterialPropertiesImp::on_specularColor_changed(), PartDesignGui::TaskBooleanParameters::onSelectionChanged(), Gui::ManualAlignment::probePickedCallback(), Sketcher::SketchObject::rebuildExternalGeometry(), App::ExtensionContainer::registerExtension(), DrawSketchHandlerFillet::releaseButton(), PartDesignGui::relinkToOrigin(), Path::FeaturePathCompoundPy::removeObject(), Part::Primitive::Restore(), PartDesign::Transformed::Restore(), App::PropertyLinkList::Restore(), App::ExtensionContainer::restoreExtensions(), Gui::Document::setHide(), Gui::Document::setShow(), Gui::Application::setupContextMenu(), Gui::Dialog::DlgMaterialPropertiesImp::setViewProviders(), Gui::Document::slotDeletedObject(), Gui::ManualAlignment::slotDeletedObject(), FemGui::TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(), Gui::TaskView::TaskSelectLinkProperty::TaskSelectLinkProperty(), Gui::SelectionFilter::test(), Gui::PropertyEditor::PropertyMatrixItem::toolTip(), Gui::PropertyEditor::PropertyPlacementItem::toolTip(), Gui::PropertyEditor::PropertyMaterialItem::toolTip(), Gui::PropertyEditor::PropertyMaterialListItem::toolTip(), InspectionGui::ViewProviderInspection::updateData(), PathGui::ViewProviderPathShape::updateData(), MeshGui::ViewProviderMeshCurvature::updateData(), PartGui::ViewProviderCustom::updateData(), SketcherGui::ViewProviderCustom::updateData(), PathGui::ViewProviderArea::updateData(), PartGui::ViewProviderMultiFuse::updateData(), PartGui::ViewProviderBoolean::updateData(), PathGui::ViewProviderAreaView::updateData(), PartGui::ViewProviderCompound::updateData(), PartGui::ViewProviderMultiCommon::updateData(), Sketcher::SketchObject::validateExternalLinks(), SketcherGui::PropertyConstraintListItem::value(), Gui::PropertyEditor::PropertyStringItem::value(), Gui::PropertyEditor::PropertyFontItem::value(), Gui::PropertyEditor::PropertyIntegerItem::value(), Gui::PropertyEditor::PropertyIntegerConstraintItem::value(), Gui::PropertyEditor::PropertyFloatItem::value(), Gui::PropertyEditor::PropertyUnitItem::value(), Gui::PropertyEditor::PropertyFloatConstraintItem::value(), Gui::PropertyEditor::PropertyBoolItem::value(), Gui::PropertyEditor::PropertyVectorItem::value(), Gui::PropertyEditor::PropertyVectorDistanceItem::value(), Gui::PropertyEditor::PropertyMatrixItem::value(), Gui::PropertyEditor::PropertyPlacementItem::value(), Gui::PropertyEditor::PropertyEnumItem::value(), Gui::PropertyEditor::PropertyStringListItem::value(), Gui::PropertyEditor::PropertyFloatListItem::value(), Gui::PropertyEditor::PropertyIntegerListItem::value(), Gui::PropertyEditor::PropertyColorItem::value(), Gui::PropertyEditor::PropertyMaterialItem::value(), Gui::PropertyEditor::PropertyMaterialListItem::value(), Gui::PropertyEditor::PropertyFileItem::value(), Gui::PropertyEditor::PropertyPathItem::value(), Gui::PropertyEditor::PropertyTransientFileItem::value(), and MeshPartGui::CurveOnMeshHandler::Private::vertexCallback().

◆ operator!=()

bool Base::Type::operator!= ( const Type  type) const

◆ operator<()

bool Base::Type::operator< ( const Type  type) const

◆ operator<=()

bool Base::Type::operator<= ( const Type  type) const

◆ operator=()

void Base::Type::operator= ( const Type  type)

◆ operator==()

bool Base::Type::operator== ( const Type  type) const

◆ operator>()

bool Base::Type::operator> ( const Type  type) const

◆ operator>=()

bool Base::Type::operator>= ( const Type  type) const

The documentation for this class was generated from the following files:
  • src/Base/Type.h
  • src/Base/Type.cpp
virtual void Warning(const char *pMsg,...)
Prints a warning Message.
Definition: Console.cpp:289
ConsoleSingleton & Console(void)
Access to the Console This method is used to gain access to the one and only instance of the ConsoleS...
Definition: Console.h:625