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>

List of all members.

Public Types

typedef void *(* instantiationMethod )(void)

Public Member Functions

void * createInstance (void)
 creates a instance of this type
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 (void)
 A constructor.
 Type (const Type &type)
 Construction.
virtual ~Type ()
 Destruction.

Static Public Member Functions

static Type badType (void)
static void * createInstanceByName (const char *TypeName, bool bLoadModule=false)
 creates a instance of the named type
static const Type createType (const Type parent, const char *name, instantiationMethod method=0)
static void destruct (void)
static Type fromName (const char *name)
static int getAllDerivedFrom (const Type type, std::vector< Type > &List)
static int getNumTypes (void)
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.

Definition at line 77 of file Base/type.h.


Member Typedef Documentation

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

Definition at line 91 of file Base/type.h.


Constructor & Destructor Documentation

Type::Type ( const Type type  ) 

Construction.

Definition at line 71 of file Type.cpp.

Type::Type ( void   ) 

A constructor.

A more elaborate description of the constructor.

Definition at line 65 of file Type.cpp.

Type::~Type (  )  [virtual]

Destruction.

A destructor.

A more elaborate description of the destructor.

Definition at line 81 of file Type.cpp.


Member Function Documentation

Type Type::badType ( void   )  [static]
void * Type::createInstance ( void   ) 
void * Type::createInstanceByName ( const char *  TypeName,
bool  bLoadModule = false 
) [static]
const Type Type::createType ( const Type  parent,
const char *  name,
instantiationMethod  method = 0 
) [static]

Definition at line 142 of file Type.cpp.

References getKey().

Referenced by Base::BaseClass::init(), and Base::BaseClass::initSubclass().

void Type::destruct ( void   )  [static]

Definition at line 167 of file Type.cpp.

Type Type::fromName ( const char *  name  )  [static]
int Type::getAllDerivedFrom ( const Type  type,
std::vector< Type > &  List 
) [static]
unsigned int Base::Type::getKey ( void   )  const [inline]
string Type::getModuleName ( const char *  ClassName  )  [static, protected]

Definition at line 123 of file Type.cpp.

References RobotExample::pos.

Referenced by createInstanceByName().

const char * Type::getName ( void   )  const
int Type::getNumTypes ( void   )  [static]

Definition at line 225 of file Type.cpp.

const Type Type::getParent ( void   )  const

Definition at line 192 of file Type.cpp.

Referenced by isDerivedFrom().

void Type::init ( void   )  [static]

Definition at line 156 of file Type.cpp.

bool Base::Type::isBad ( void   )  const [inline]

Definition at line 187 of file Base/type.h.

Referenced by Gui::View3DInventorViewer::setNavigationType().

bool Type::isDerivedFrom ( const Type  type  )  const

Definition at line 197 of file Type.cpp.

References badType(), and getParent().

Referenced by CmdPointsPolyCut::activated(), CmdMeshPolySplit::activated(), CmdMeshPolyCut::activated(), CmdMeshAddFacet::activated(), CmdMeshPolySelect::activated(), CmdMeshPolySegm::activated(), App::DocumentObjectGroupPy::addObject(), MeshGui::DlgEvaluateMeshImp::addViewProvider(), Gui::SelectionSingleton::countObjectsOfType(), MeshGui::ViewProviderMeshCurvature::curvatureInfoCallback(), Gui::TreeWidget::dragMoveEvent(), Gui::TreeWidget::dropEvent(), Robot::TrajectoryDressUpObject::execute(), Sketcher::SketchObject::execute(), Raytracing::RayFeature::execute(), Part::RuledSurface::execute(), Inspection::Feature::execute(), Drawing::FeatureViewPart::execute(), PartDesign::Revolution::execute(), Part::Revolution::execute(), Drawing::FeatureProjection::execute(), PartDesign::Pocket::execute(), PartDesign::Pad::execute(), Part::Mirroring::execute(), PartDesign::Fillet::execute(), Part::Fillet::execute(), Part::Extrusion::execute(), Part::Chamfer::execute(), Robot::Edge2TracObject::execute(), exporter(), MeshGui::ViewProviderMesh::faceInfoCallback(), MeshGui::ViewProviderMesh::fillHoleCallback(), App::DocumentPy::findObjects(), InspectionGui::ViewProviderInspection::getIcon(), Gui::SelectionSingleton::getObjectsOfType(), App::PropertyPlacementLink::getPlacementObject(), App::PropertyLinkSub::getValue(), App::PropertyLink::getValue(), Gui::ViewProviderDocumentObjectGroup::getViewProviders(), Gui::ViewProviderDocumentObjectGroup::hide(), InspectionGui::ViewProviderInspection::inspectCallback(), InspectionGui::ViewProviderInspection::inspectDistance(), Base::BaseClass::isDerivedFrom(), Gui::SelectionObject::isObjectTypeOf(), Gui::Command::isViewOfType(), MeshGui::ViewProviderMesh::markPartCallback(), 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(), Gui::PropertyEditor::PropertyItem::pythonIdentifier(), Gui::Document::setHide(), Gui::Document::setShow(), Gui::Application::setupContextMenu(), Gui::Dialog::DlgMaterialPropertiesImp::setViewProviders(), PartGui::ViewProviderPartBase::shapeInfoCallback(), Gui::ViewProviderDocumentObjectGroup::show(), Gui::DocumentItem::slotChangeObject(), Gui::Document::slotDeletedObject(), Gui::TaskView::TaskSelectLinkProperty::TaskSelectLinkProperty(), Gui::SelectionFilter::test(), Gui::PropertyEditor::PropertyPlacementItem::toolTip(), Gui::ViewProviderGeometryObject::unsetEdit(), SketcherGui::ViewProviderCustom::updateData(), PartGui::ViewProviderCustom::updateData(), InspectionGui::ViewProviderInspection::updateData(), Gui::PropertyEditor::PropertyTransientFileItem::value(), Gui::PropertyEditor::PropertyPathItem::value(), Gui::PropertyEditor::PropertyFileItem::value(), Gui::PropertyEditor::PropertyColorItem::value(), Gui::PropertyEditor::PropertyStringListItem::value(), Gui::PropertyEditor::PropertyEnumItem::value(), Gui::PropertyEditor::PropertyPlacementItem::value(), Gui::PropertyEditor::PropertyVectorItem::value(), Gui::PropertyEditor::PropertyBoolItem::value(), Gui::PropertyEditor::PropertyFloatConstraintItem::value(), Gui::PropertyEditor::PropertyUnitItem::value(), Gui::PropertyEditor::PropertyFloatItem::value(), Gui::PropertyEditor::PropertyIntegerConstraintItem::value(), Gui::PropertyEditor::PropertyIntegerItem::value(), Gui::PropertyEditor::PropertyFontItem::value(), and Gui::PropertyEditor::PropertyStringItem::value().

bool Base::Type::operator!= ( const Type  type  )  const [inline]

Definition at line 145 of file Base/type.h.

References getKey().

bool Base::Type::operator< ( const Type  type  )  const [inline]

Definition at line 163 of file Base/type.h.

References getKey().

bool Base::Type::operator<= ( const Type  type  )  const [inline]

Definition at line 169 of file Base/type.h.

References getKey().

void Base::Type::operator= ( const Type  type  )  [inline]

Definition at line 151 of file Base/type.h.

References getKey().

bool Base::Type::operator== ( const Type  type  )  const [inline]

Definition at line 157 of file Base/type.h.

References getKey().

bool Base::Type::operator> ( const Type  type  )  const [inline]

Definition at line 181 of file Base/type.h.

References getKey().

bool Base::Type::operator>= ( const Type  type  )  const [inline]

Definition at line 175 of file Base/type.h.

References getKey().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:01:48 2011 for FreeCAD by  doxygen 1.6.1