Base::Type Class Reference

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) ()
 

Public Member Functions

void * createInstance ()
 creates a instance of this type More...
 
unsigned int getKey () const
 
const char * getName () const
 
const Type getParent () const
 
bool isBad () 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 ()
 A constructor. More...
 
 Type (const Type &type)
 Construction. More...
 
virtual ~Type ()
 Destruction. More...
 

Static Public Member Functions

static Type badType ()
 
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=nullptr)
 
static void destruct ()
 
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 ()
 
static Type getTypeIfDerivedFrom (const char *name, const Type parent, bool bLoadModule=false)
 Returns the given named type if is derived from parent type, otherwise return bad type. More...
 
static void importModule (const char *TypeName)
 
static void init ()
 

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) ()

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()

void * Type::createInstanceByName ( const char *  TypeName,
bool  bLoadModule = false 
)
static

◆ createType()

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

◆ destruct()

void Type::destruct ( )
static

◆ fromKey()

Type Type::fromKey ( unsigned int  key)
static

References badType().

◆ fromName()

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

References badType().

Referenced by PartGui::Mirroring::accept(), StdCmdAlignment::activated(), Gui::Application::activateWorkbench(), FemGui::ViewProviderFemAnalysis::canDragObject(), Part::AttachExtension::changeAttacherType(), Part::FaceMaker::ConstructFromType(), Gui::SelectionSingleton::countObjectsOfType(), createInstanceByName(), Gui::Dialog::DlgAddProperty::DlgAddProperty(), Part::AttachExtension::extHandleChangedPropertyName(), PartGui::ViewProviderBoolean::getIcon(), Fem::FemPostFilter::getInputData(), Gui::SelectionSingleton::getObjectsOfType(), TechDrawGui::QGVPage::getStyleType(), getTypeIfDerivedFrom(), Gui::View3DInventorPy::getViewProvidersOfType(), Gui::DAG::FilterOrigin::goFilter(), Gui::DAG::FilterTyped::goFilter(), Fem::FemAnalysis::handleChangedPropertyName(), Part::Circle::handleChangedPropertyName(), Part::Ellipse::handleChangedPropertyName(), Part::BodyBase::handleChangedPropertyName(), PartDesign::Boolean::handleChangedPropertyName(), Surface::Extend::handleChangedPropertyName(), TechDraw::DrawViewBalloon::handleChangedPropertyName(), PartGui::ViewProvider2DObjectGrid::handleChangedPropertyType(), PartDesign::Transformed::handleChangedPropertyType(), Part::Primitive::handleChangedPropertyType(), App::Extension::initExtensionSubclass(), Base::BaseClass::initSubclass(), Gui::Node_Object::Node_Object(), Gui::View3DInventor::OnChange(), Gui::GraphicsView3D::OnChange(), FemGui::ViewProviderFemPostObject::onChanged(), Gui::NavigationStyle::openPopupMenu(), Gui::Dialog::find_placement::operator()(), Gui::Dialog::find_transform::operator()(), Fem::FemVTKTools::readResult(), Part::Geometry::Restore(), Part::PropertyGeometryList::Restore(), TechDraw::PropertyCenterLineList::Restore(), TechDraw::PropertyCosmeticEdgeList::Restore(), TechDraw::PropertyCosmeticVertexList::Restore(), TechDraw::PropertyGeomFormatList::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(), App::PropertyLinkSubList::upgrade(), and InspectionGui::VisualInspection::VisualInspection().

◆ getAllDerivedFrom()

int Type::getAllDerivedFrom ( const Type  type,
std::vector< Type > &  List 
)
static

◆ getKey()

◆ getModuleName()

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

Referenced by importModule().

◆ getName()

◆ getNumTypes()

int Type::getNumTypes ( )
static

◆ getParent()

const Type Type::getParent ( ) const

◆ getTypeIfDerivedFrom()

Type Type::getTypeIfDerivedFrom ( const char *  name,
const Type  parent,
bool  bLoadModule = false 
)
static

◆ 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(), MeshGui::DlgEvaluateMeshImp::addViewProvider(), SketcherGui::FilletSelection::allow(), SketcherGui::TrimmingSelection::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(), TechDraw::FeatureProjection::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(), Fem::FemPostFilter::getInputData(), 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(), PartDesign::Transformed::handleChangedPropertyType(), Part::Primitive::handleChangedPropertyType(), Gui::Dialog::DlgPropertyLink::init(), InspectionGui::ViewProviderInspection::inspectCallback(), InspectionGui::ViewProviderInspection::inspectDistance(), PartDesign::Feature::isDatum(), 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(), SketcherGui::DrawSketchHandlerFillet::releaseButton(), SketcherGui::DrawSketchHandlerTrimming::releaseButton(), PartDesignGui::relinkToOrigin(), App::PropertyLinkList::Restore(), App::ExtensionContainer::restoreExtensions(), PartGui::FaceColors::Private::selectionCallback(), 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::PropertyRotationItem::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::PropertyRotationItem::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: