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());
}
}
virtual void Warning(const char *pMsg,...)
Prints a warning Message.
Definition: Console.cpp:292
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:623

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(), Sketcher::ExternalGeometryFacadePy::deleteExtensionOfType(), Sketcher::GeometryFacadePy::deleteExtensionOfType(), Gui::Dialog::DlgAddProperty::DlgAddProperty(), Part::AttachExtension::extHandleChangedPropertyName(), App::DocumentPy::findObjects(), Base::TypePy::fromName(), Base::TypePy::getAllDerived(), Base::TypePy::getAllDerivedFrom(), Part::GeometryPy::getExtensionOfType(), Sketcher::ExternalGeometryFacadePy::getExtensionOfType(), Sketcher::GeometryFacadePy::getExtensionOfType(), PartGui::ViewProviderBoolean::getIcon(), Gui::SelectionSingleton::getObjectsOfType(), Gui::View3DInventorPy::getViewProvidersOfType(), Gui::DAG::FilterOrigin::goFilter(), Gui::DAG::FilterTyped::goFilter(), Fem::FemAnalysis::handleChangedPropertyName(), Part::BodyBase::handleChangedPropertyName(), PartDesign::Boolean::handleChangedPropertyName(), Surface::Extend::handleChangedPropertyName(), TechDraw::DrawViewBalloon::handleChangedPropertyName(), PartGui::ViewProvider2DObjectGrid::handleChangedPropertyType(), App::ExtensionContainerPy::hasExtension(), Part::GeometryPy::hasExtensionOfType(), Sketcher::ExternalGeometryFacadePy::hasExtensionOfType(), Sketcher::GeometryFacadePy::hasExtensionOfType(), Gui::ViewProviderExtensionPy::ignoreOverlayIcon(), App::Extension::initExtensionSubclass(), Base::BaseClass::initSubclass(), Base::BaseClassPy::isDerivedFrom(), Base::TypePy::isDerivedFrom(), Gui::SelectionObjectPy::isObjectTypeOf(), Gui::DocumentPy::mdiViewsOfType(), Gui::Node_Object::Node_Object(), Gui::View3DInventor::OnChange(), Gui::GraphicsView3D::OnChange(), Gui::NavigationStyle::openPopupMenu(), Gui::Dialog::find_placement::operator()(), Gui::Dialog::find_transform::operator()(), Attacher::AttachEnginePy::PyInit(), Fem::FemVTKTools::readResult(), Part::Geometry::Restore(), Part::PropertyGeometryList::Restore(), PartDesign::Transformed::Restore(), TechDraw::PropertyCenterLineList::Restore(), TechDraw::PropertyCosmeticEdgeList::Restore(), TechDraw::PropertyCosmeticVertexList::Restore(), TechDraw::PropertyGeomFormatList::Restore(), Part::Primitive::Restore(), App::ExtensionContainer::restoreExtensions(), Gui::TreeView::rowsInserted(), Gui::Application::sActivateView(), Gui::Application::sActiveView(), Gui::ViewProviderExtensionPy::setIgnoreOverlayIcon(), 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::TaskDlgFeatureParameters::accept(), PartDesignGui::TaskDlgSketchBasedParameters::accept(), StdCmdGroup::activated(), Gui::Application::activateWorkbench(), App::ExtensionContainerPy::addExtension(), Path::FeaturePathCompoundPy::addObject(), MeshGui::DlgEvaluateMeshImp::addViewProvider(), PartGui::SweepWidget::Private::EdgeSelection::allow(), SketcherGui::FilletSelection::allow(), PartDesignGui::ReferenceSelection::allow(), SketcherGui::ExternalSelection::allow(), Gui::QuantitySpinBox::apply(), PartDesignGui::collectMovableDependencies(), Gui::Document::createView(), MeshGui::ViewProviderMeshCurvature::curvatureInfoCallback(), Sketcher::SketchObject::evaluateSupport(), Drawing::FeatureProjection::execute(), Drawing::FeatureViewPart::execute(), Drawing::FeatureViewSpreadsheet::execute(), Inspection::Feature::execute(), PartDesign::Pipe::execute(), Raytracing::LuxFeature::execute(), Raytracing::RayFeature::execute(), Robot::Edge2TracObject::execute(), Robot::TrajectoryDressUpObject::execute(), Surface::Filling::execute(), TechDraw::DrawViewSpreadsheet::execute(), PartDesign::Body::execute(), Surface::Extend::execute(), TechDraw::DrawViewDetail::execute(), MeshGui::ViewProviderMesh::faceInfoCallback(), MeshGui::ViewProviderMesh::fillHoleCallback(), PartDesign::ProfileBased::getAxis(), PartDesign::Feature::getBaseObject(), InspectionGui::ViewProviderInspection::getIcon(), TechDraw::ShapeExtractor::getShapesFromObject(), PartDesign::Transformed::getSketchObject(), PartDesign::ProfileBased::getSupportFace(), PartDesign::MultiTransform::getTransformations(), PartDesign::Scaled::getTransformations(), PartDesign::LinearPattern::getTransformations(), PartDesign::Mirrored::getTransformations(), PartDesign::PolarPattern::getTransformations(), AttacherGui::getUIStrings(), PartGui::ViewProvider2DObjectGrid::handleChangedPropertyType(), App::ExtensionContainerPy::hasExtension(), Gui::Dialog::DlgPropertyLink::init(), InspectionGui::ViewProviderInspection::inspectCallback(), InspectionGui::ViewProviderInspection::inspectDistance(), PartDesign::Feature::isDatum(), Base::BaseClass::isDerivedFrom(), Base::BaseClassPy::isDerivedFrom(), Base::TypePy::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(), Part::CurveConstraintPy::PyInit(), Sketcher::SketchObject::rebuildExternalGeometry(), App::ExtensionContainer::registerExtension(), DrawSketchHandlerFillet::releaseButton(), PartDesignGui::relinkToOrigin(), Path::FeaturePathCompoundPy::removeObject(), PartDesign::Transformed::Restore(), App::PropertyLinkList::Restore(), Part::Primitive::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(), MeshGui::ViewProviderMeshCurvature::updateData(), PartGui::ViewProviderBoolean::updateData(), PartGui::ViewProviderMultiFuse::updateData(), PartGui::ViewProviderMultiCommon::updateData(), PartGui::ViewProviderCompound::updateData(), PartGui::ViewProviderCustom::updateData(), PathGui::ViewProviderArea::updateData(), PathGui::ViewProviderAreaView::updateData(), PathGui::ViewProviderPathShape::updateData(), SketcherGui::ViewProviderCustom::updateData(), Sketcher::SketchObject::validateExternalLinks(), 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::PropertyVectorListItem::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(), SketcherGui::PropertyConstraintListItem::value(), and MeshPartGui::CurveOnMeshHandler::Private::vertexCallback().

◆ operator!=()

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

References getKey().

◆ operator<()

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

References getKey().

◆ operator<=()

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

References getKey().

◆ operator=()

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

◆ operator==()

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

References getKey().

◆ operator>()

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

References getKey().

◆ operator>=()

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

References getKey().


The documentation for this class was generated from the following files:
  • Sources/FreeCAD/src/Base/Type.h
  • Sources/FreeCAD/src/Base/Type.cpp