]> OCCT Git - occt.git/commitdiff
0033646: Coding - Performance analyzing of OCCT RTTI CR33646
authordpasukhi <dpasukhi@opencascade.com>
Wed, 20 Mar 2024 06:17:53 +0000 (06:17 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Fri, 29 Mar 2024 13:41:13 +0000 (13:41 +0000)
Implement functionality to avoid mutex operation and keeping unload data
Making Standard_Type own specialized handle to avoid sharing and atomic operations

63 files changed:
src/BOPTest/BOPTest.cxx
src/BinLDrivers/BinLDrivers_DocumentStorageDriver.hxx
src/BinMDF/BinMDF_ADriverTable.cxx
src/BinMDF/BinMDF_ADriverTable.hxx
src/BinMDataStd/BinMDataStd_GenericEmptyDriver.cxx
src/BinMDataStd/BinMDataStd_GenericExtStringDriver.cxx
src/BinObjMgt/BinObjMgt_Position.hxx
src/BndLib/BndLib_Add2dCurve.cxx
src/CDF/CDF_MetaDataDriver.hxx
src/DBRep/DBRep_DrawableShape.hxx
src/Draw/Draw_Drawable3D.hxx
src/Draw/Draw_Number.hxx
src/DrawTrSurf/DrawTrSurf_BSplineCurve.hxx
src/DrawTrSurf/DrawTrSurf_BSplineCurve2d.hxx
src/DrawTrSurf/DrawTrSurf_BSplineSurface.hxx
src/DrawTrSurf/DrawTrSurf_BezierCurve.hxx
src/DrawTrSurf/DrawTrSurf_BezierCurve2d.hxx
src/DrawTrSurf/DrawTrSurf_BezierSurface.hxx
src/DrawTrSurf/DrawTrSurf_Curve.hxx
src/DrawTrSurf/DrawTrSurf_Curve2d.hxx
src/DrawTrSurf/DrawTrSurf_Point.hxx
src/DrawTrSurf/DrawTrSurf_Polygon2D.hxx
src/DrawTrSurf/DrawTrSurf_Polygon3D.hxx
src/DrawTrSurf/DrawTrSurf_Surface.hxx
src/DrawTrSurf/DrawTrSurf_Triangulation.hxx
src/Express/Express.hxx
src/Express/Express_Field.hxx
src/Express/Express_Type.hxx
src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx
src/HLRTest/HLRTest_Projector.hxx
src/IFSelect/IFSelect_SignAncestor.cxx
src/IFSelect/IFSelect_SignType.cxx
src/Interface/Interface_FileReaderTool.cxx
src/Interface/Interface_GTool.hxx
src/Message/Message_Alert.hxx
src/Message/Message_Algorithm.cxx
src/OSD/OSD_ThreadPool.cxx
src/OpenGl/OpenGl_Element.hxx
src/OpenGl/OpenGl_Resource.hxx
src/STEPSelections/STEPSelections_SelectDerived.cxx
src/SelectMgr/SelectMgr.hxx
src/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx
src/Standard/Standard_ArrayStreamBuffer.cxx
src/Standard/Standard_DefineHandle.hxx
src/Standard/Standard_Persistent.hxx
src/Standard/Standard_Transient.cxx
src/Standard/Standard_Transient.hxx
src/Standard/Standard_Type.cxx
src/Standard/Standard_Type.hxx
src/StepAP214/StepAP214_Protocol.cxx
src/StepData/StepData_FileProtocol.cxx
src/StepData/StepData_PDescr.cxx
src/StepFile/StepFile_Read.hxx
src/StepVisual/StepVisual_CoordinatesList.cxx
src/StepVisual/StepVisual_TessellatedGeometricSet.cxx
src/TObj/TObj_Assistant.cxx
src/TObj/TObj_Assistant.hxx
src/TObj/TObj_Object.cxx
src/Transfer/Transfer_TransferIterator.cxx
src/XCAFDoc/XCAFDoc_NotesTool.cxx
src/XSControl/XSControl_Utils.cxx
src/XmlMDataStd/XmlMDataStd_GenericEmptyDriver.cxx
src/XmlMDataStd/XmlMDataStd_GenericExtStringDriver.cxx

index 74adcb3b9f65d136a6a7b36a0287eb23a8a67693..94fccfae056dbc5c720c74f0dc84ffe8d5bbb1a1 100644 (file)
@@ -92,7 +92,7 @@ void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport)
   for (int iGravity = 0; iGravity < 2; iGravity++)
   {
     // report shapes for the same type of alert together
-    NCollection_Map<Handle(Standard_Transient)> aPassedTypes;
+    NCollection_Map<Handle(Standard_Type)> aPassedTypes;
     const Message_ListOfAlert& aList = theReport->GetAlerts (anAlertTypes[iGravity]);
     for (Message_ListOfAlert::Iterator aIt (aList); aIt.More(); aIt.Next())
     {
index dee195b71cbc33e92d781b625047fbb9258aa066..626f9708ae8d034e290f7a84b6d3de92104ef527 100644 (file)
@@ -120,8 +120,8 @@ private:
 
   BinObjMgt_Persistent myPAtt;
   TDF_LabelList myEmptyLabels;
-  TColStd_MapOfTransient myMapUnsupported;
-  TColStd_IndexedMapOfTransient myTypesMap;
+  NCollection_Map<Handle(Standard_Type)> myMapUnsupported;
+  NCollection_IndexedMap<Handle(Standard_Type)> myTypesMap;
   BinLDrivers_VectorOfDocumentSection mySections;
   TCollection_ExtendedString myFileName;
   //! Sizes of labels and some attributes that will be stored in the second pass
index a5fd1184cbaaa4034adddf4845923afbc1b2dea0..b060beed3418f6afc9ad88035292923526120b6e 100644 (file)
@@ -90,12 +90,12 @@ const Handle(Standard_Type)& BinMDF_ADriverTable::AddDerivedDriver (Standard_CSt
 //=======================================================================
 
 void BinMDF_ADriverTable::AssignIds
-                (const TColStd_IndexedMapOfTransient& theTypes)
+                (const NCollection_IndexedMap<Handle(Standard_Type)>& theTypes)
 {
   myMapId.Clear();
   Standard_Integer i;
   for (i=1; i <= theTypes.Extent(); i++) {
-    Handle(Standard_Type) aType (Handle(Standard_Type)::DownCast (theTypes(i)));
+    const Handle(Standard_Type)& aType = theTypes(i);
     if (myMap.IsBound (aType)) {
       myMapId.Bind (aType, i);
     }
@@ -141,7 +141,8 @@ void BinMDF_ADriverTable::AssignIds
   {
     if (!myMapId.IsBound2 (aStrId.Value()))
     {
-      if (Handle(Standard_Type) anAdded = AddDerivedDriver (aStrId.Key().ToCString()))
+      Handle(Standard_Type) anAdded = AddDerivedDriver(aStrId.Key().ToCString());
+      if (!anAdded.IsNull())
       {
         myMapId.Bind (anAdded, aStrId.Value());
       }
index 306bc37bdc87b0f5f393f24797768780fd35b617..eb772da635434f9bed0ee7a93db475f6ef3e1f5d 100644 (file)
@@ -59,7 +59,7 @@ public:
   //! Assigns the IDs to the drivers of the given Types.
   //! It uses indices in the map as IDs.
   //! Useful in storage procedure.
-  Standard_EXPORT void AssignIds (const TColStd_IndexedMapOfTransient& theTypes);
+  Standard_EXPORT void AssignIds (const NCollection_IndexedMap<Handle(Standard_Type)>& theTypes);
   
   //! Assigns the IDs to the drivers of the given Type Names;
   //! It uses indices in the sequence as IDs.
index 1d05de0eb623655171cdc0b84ee9f7f6150c55e3..66b0c7b883e0087ce343d45f3aa4c9afe42670a3 100644 (file)
@@ -47,7 +47,7 @@ Handle(TDF_Attribute) BinMDataStd_GenericEmptyDriver::NewEmpty() const
 //=======================================================================
 const Handle(Standard_Type)& BinMDataStd_GenericEmptyDriver::SourceType() const
 {
-  return Standard_Type::Instance<TDataStd_GenericEmpty>();
+  return STANDARD_TYPE(TDataStd_GenericEmpty);
 }
 
 //=======================================================================
index c6f3ad78f16bbcb964de50164a63ffcc843755ed..145d778730dbc3ee6ec376d7aef3d44b5f321929 100644 (file)
@@ -47,7 +47,7 @@ Handle(TDF_Attribute) BinMDataStd_GenericExtStringDriver::NewEmpty() const
 //=======================================================================
 Handle(Standard_Type)& BinMDataStd_GenericExtStringDriver::SourceType() const
 {
-  static Handle(Standard_Type) aSourceType = Standard_Type::Instance<TDataStd_GenericExtString>();
+  static Handle(Standard_Type) aSourceType = STANDARD_TYPE(TDataStd_GenericExtString);
   return aSourceType;
 }
 
index 7fdc3f737f0eac1e01f0a882d5b2f0715f89d3bc..b6fc4d2d2b42d90220215c587764d0d6d6865a37 100644 (file)
@@ -15,6 +15,7 @@
 #define _BinObjMgt_Position_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 class BinObjMgt_Position;
 DEFINE_STANDARD_HANDLE (BinObjMgt_Position, Standard_Transient)
index ad454b8a94a5302b9aeab6cf7fcdd089ac59cb65..c02accb83749bc67f280555c3869bc554cddbc93 100644 (file)
@@ -841,12 +841,9 @@ Standard_Boolean BndLib_Box2dCurve::IsTypeBase
   (const Handle(Geom2d_Curve)& aC2D,
    GeomAbs_CurveType& aTypeB)
 {
-  Standard_Boolean bRet; 
-  Handle(Standard_Type) aType;
+  Standard_Boolean bRet=Standard_True;
   //
-  bRet=Standard_True;
-  //
-  aType=aC2D->DynamicType();
+  const Handle(Standard_Type)& aType = aC2D->DynamicType();
   if (aType==STANDARD_TYPE(Geom2d_Line)) {
     aTypeB=GeomAbs_Line;
   }
index 5a3692dd9b096a6090c30d3a436364f802a5cba3..454df0f48b771c08a27afba8f5ba31cdaf6c8cb3 100644 (file)
@@ -18,6 +18,7 @@
 #define _CDF_MetaDataDriver_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 class CDM_MetaData;
 class TCollection_ExtendedString;
index af6f38ea54164767c56a133108da8cd8ba341071..d9e6fd18c5280ef7cf55ff409b83116e4daeed6b 100644 (file)
@@ -36,8 +36,7 @@ class gp_Trsf;
 //! list of edges and a list of faces.
 class DBRep_DrawableShape : public Draw_Drawable3D
 {
-  DEFINE_STANDARD_RTTIEXT(DBRep_DrawableShape, Draw_Drawable3D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DBRep_DrawableShape, Draw_Drawable3D)
 public:
 
   Standard_EXPORT DBRep_DrawableShape(const TopoDS_Shape& C, const Draw_Color& FreeCol, const Draw_Color& ConnCol, const Draw_Color& EdgeCol, const Draw_Color& IsosCol, const Standard_Real size, const Standard_Integer nbisos, const Standard_Integer discret);
index c9c86698b399a4531140f67cc67df47d1c7372f7..b2d13d7b610d262349aa16064653feaa3bde2070 100644 (file)
@@ -51,8 +51,9 @@ public:
 
   //! @def Draw_Drawable3D_FACTORY
   //! Auxiliary macros defining Draw_Drawable3D restoration API to sub-class.
-  #define Draw_Drawable3D_FACTORY \
-    static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (get_type_name(), &Restore); } \
+  #define Draw_Drawable3D_FACTORY_RTTIEXT(Class,Base) \
+    DEFINE_STANDARD_RTTIEXT(Class, Base) \
+    static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (#Class, &Restore); } \
     Standard_EXPORT static Handle(Draw_Drawable3D) Restore (Standard_IStream& theStream);
 
 public:
index 9927258c6bc000360de08a871f893de0d0fc582b..b58ef7053534309b6e45f5f84cc5eb20d1997b31 100644 (file)
@@ -24,8 +24,7 @@ DEFINE_STANDARD_HANDLE(Draw_Number, Draw_Drawable3D)
 //! To store numbers in variables.
 class Draw_Number : public Draw_Drawable3D
 {
-  DEFINE_STANDARD_RTTIEXT(Draw_Number, Draw_Drawable3D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(Draw_Number, Draw_Drawable3D)
 public:
 
   Standard_EXPORT Draw_Number (const Standard_Real theV);
index 86d0cb4268946aa6caa72056c143c8518cb03cb0..e32b0dc39b4b91d24fc92337ad9ab67fef568296 100644 (file)
@@ -27,8 +27,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
 
 class DrawTrSurf_BSplineCurve : public DrawTrSurf_Curve
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BSplineCurve, DrawTrSurf_Curve)
 public:
 
   //! creates a drawable BSpline curve from a BSpline curve of package Geom.
index 6f325ef004f2669f2ff64e64595e75991ccde347..65b661fc52262f34617b175c90f72285987e2b06 100644 (file)
@@ -27,8 +27,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
 
 class DrawTrSurf_BSplineCurve2d : public DrawTrSurf_Curve2d
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
 public:
 
   //! creates a drawable BSpline curve from a BSpline curve of package Geom2d.
index f4803c2278b55a81fbe68c506f2e8fc490995f83..c85a9e686baafd5bacca6e3abdff84be50f0f75f 100644 (file)
@@ -32,8 +32,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
 //! if you just want to sea boundaries and isoparametric curves.
 class DrawTrSurf_BSplineSurface : public DrawTrSurf_Surface
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BSplineSurface, DrawTrSurf_Surface)
 public:
   
   //! default drawing mode.
index 772c664de582b6e39e550654da96344c924a41e2..c32d13c4becf7f7aac4db7f4ea4e73a1d0ef2fc6 100644 (file)
@@ -26,8 +26,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
 
 class DrawTrSurf_BezierCurve : public DrawTrSurf_Curve
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BezierCurve, DrawTrSurf_Curve)
 public:
 
   //! creates a drawable Bezier curve from a Bezier curve of package Geom.
index f5e53d7a4eb9d4d54c9cb89579fa29d811694d83..c24f2249d9f33628b71c6438ac8c182aad8d6369 100644 (file)
@@ -26,8 +26,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
 
 class DrawTrSurf_BezierCurve2d : public DrawTrSurf_Curve2d
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BezierCurve2d, DrawTrSurf_Curve2d)
 public:
 
   //! creates a drawable Bezier curve from a Bezier curve of package Geom2d.
index 758ab3ed3219676cdc3fb49522643725dcd5c23a..ebf79ee8bfe84c231212bcfb5224e2aa5c123457 100644 (file)
@@ -26,8 +26,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
 
 class DrawTrSurf_BezierSurface : public DrawTrSurf_Surface
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_BezierSurface, DrawTrSurf_Surface)
 public:
 
   //! creates a drawable Bezier curve from a Bezier curve of package Geom.
index 36ed5889e63965ab226871b4d98219303b5949de..b5e618516d4bdaa34bb66e894dd57e8805c63191 100644 (file)
@@ -29,8 +29,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Curve, DrawTrSurf_Drawable)
 //! This class defines a drawable curve in 3d space.
 class DrawTrSurf_Curve : public DrawTrSurf_Drawable
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve, DrawTrSurf_Drawable)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Curve, DrawTrSurf_Drawable)
 public:
 
   //! creates a drawable curve from a curve of package Geom.
index ba56a765b570d29bea904a2a9e0f9a92cb635975..fc5ddf3c2b8998494fac242bb39c2e906c6c5b6f 100644 (file)
@@ -29,8 +29,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
 //! The curve is drawn in the plane XOY.
 class DrawTrSurf_Curve2d : public DrawTrSurf_Drawable
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Curve2d, DrawTrSurf_Drawable)
 public:
 
   //! creates a drawable curve from a curve of package Geom2d.
index e6545f8fc6c413098d07a112f2dc19e620ca6772..41d226e25c7a4c122f1519701f451ebbe323d9b8 100644 (file)
@@ -29,8 +29,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Point, Draw_Drawable3D)
 //! A drawable point.
 class DrawTrSurf_Point : public Draw_Drawable3D
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Point, Draw_Drawable3D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Point, Draw_Drawable3D)
 public:
 
   Standard_EXPORT DrawTrSurf_Point (const gp_Pnt& P, const Draw_MarkerShape Shape, const Draw_Color& Col);
index 4239a74d02f33be221b86821a591567686b0fc43..240f6b0f20b88ff85d7cc60cd2947218aa3f9262 100644 (file)
@@ -28,8 +28,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Polygon2D, Draw_Drawable2D)
 //! Optional display of nodes.
 class DrawTrSurf_Polygon2D : public Draw_Drawable2D
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon2D, Draw_Drawable2D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Polygon2D, Draw_Drawable2D)
 public:
 
   Standard_EXPORT DrawTrSurf_Polygon2D (const Handle(Poly_Polygon2D)& P);
index 5a24963b5ecdb6ab7223939b5ec6cb62a0323686..28f3d113c9e4968148c4c6bbb53b5c425ac2860b 100644 (file)
@@ -28,8 +28,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Polygon3D, Draw_Drawable3D)
 //! Optional display of nodes.
 class DrawTrSurf_Polygon3D : public Draw_Drawable3D
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Polygon3D, Draw_Drawable3D)
 public:
 
   Standard_EXPORT DrawTrSurf_Polygon3D (const Handle(Poly_Polygon3D)& P);
index 6be800fb864d961b88b8c900edebe8c513a4835c..0c13273caa06ad7b469fee87c94c93de0f4b72f5 100644 (file)
@@ -29,8 +29,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Surface, DrawTrSurf_Drawable)
 //! With this class you can draw a general surface from package Geom.
 class DrawTrSurf_Surface : public DrawTrSurf_Drawable
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Surface, DrawTrSurf_Drawable)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Surface, DrawTrSurf_Drawable)
 public:
 
   //! default drawing mode
index e53dd6451abe0f1b20d3f3d9e4b87930658658e9..2937a32f3d3d9cb829dbcb632e6362bda8d3a2c8 100644 (file)
@@ -32,8 +32,7 @@ DEFINE_STANDARD_HANDLE(DrawTrSurf_Triangulation, Draw_Drawable3D)
 //! Optional display of triangles and nodes indices.
 class DrawTrSurf_Triangulation : public Draw_Drawable3D
 {
-  DEFINE_STANDARD_RTTIEXT(DrawTrSurf_Triangulation, Draw_Drawable3D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(DrawTrSurf_Triangulation, Draw_Drawable3D)
 public:
   
   Standard_EXPORT DrawTrSurf_Triangulation (const Handle(Poly_Triangulation)& T);
index 0dcb80ee96f5cecce867ca8729a5b8bbd10b46ac..534c37210cfce3683cbb3689af0314907916b765 100644 (file)
@@ -17,6 +17,7 @@
 #include <Standard_Boolean.hxx>
 #include <Standard_Type.hxx>
 #include <Standard_OStream.hxx>
+#include <Standard_Handle.hxx>
 
 class Express_Schema;
 class TCollection_AsciiString;
index f2143fd017d807cc7febd3d7c76a995bef6a395b..e8473bd8a56743e64b33c3a1c92f35bda9c11f1a 100644 (file)
@@ -15,6 +15,7 @@
 #define _Express_Field_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 class Express_Type;
 class TCollection_HAsciiString;
index 62dbe2a36bb0167bee514c03bce544a5136aae62..a2bbdc93be0ce4b619306301c6fa47a48d39ee8c 100644 (file)
@@ -15,6 +15,7 @@
 #define _Express_Type_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 class TCollection_AsciiString;
 
index 10b014ae4380f424157431b37f56d313b3b80cee..31225743c612713215ae5a3ec63b0280bd4c07f0 100644 (file)
@@ -215,7 +215,7 @@ void Geom2dAdaptor_Curve::load(const Handle(Geom2d_Curve)& C,
     myNestedEvaluator.Nullify();
     myBSplineCurve.Nullify();
 
-    Handle(Standard_Type) TheType = C->DynamicType();
+    const Handle(Standard_Type)& TheType = C->DynamicType();
     if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
       Load(Handle(Geom2d_TrimmedCurve)::DownCast (C)->BasisCurve(),
           UFirst,ULast);
index 93d75c0184fb855d2e37f48caba3965e5c6d43d3..e72e93443dbb976c2ab766878cfe70bf554cb3dc 100644 (file)
@@ -26,8 +26,7 @@ DEFINE_STANDARD_HANDLE(HLRTest_Projector, Draw_Drawable3D)
 //! Draw Variable Projector to test.
 class HLRTest_Projector : public Draw_Drawable3D
 {
-  DEFINE_STANDARD_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
-  Draw_Drawable3D_FACTORY
+  Draw_Drawable3D_FACTORY_RTTIEXT(HLRTest_Projector, Draw_Drawable3D)
 public:
 
   Standard_EXPORT HLRTest_Projector(const HLRAlgo_Projector& P);
index 8e11595c3df0401d3fec36bf95b6be3327d9fd2c..bb9326c6ee918c792ceea2722c04d3ab25bd7328 100644 (file)
@@ -32,9 +32,10 @@ Standard_Boolean IFSelect_SignAncestor::Matches(const Handle(Standard_Transient)
                                                const TCollection_AsciiString& text,
                                                const Standard_Boolean /*exact*/) const
 {
-  if (ent.IsNull()) return Standard_False;
-  DeclareAndCast(Standard_Type,atype,ent);
-  if (atype.IsNull()) atype = ent->DynamicType();
-  return atype->SubType(text.ToCString());
+  return false;
+  // if (ent.IsNull()) return Standard_False;
+  // DeclareAndCast(Standard_Type,atype,ent);
+  // if (atype.IsNull()) atype = ent->DynamicType();
+  // return atype->SubType(text.ToCString());
 }
                                                
index bf19e04fd2a16788e28dd53288dddd6875dce47a..af3c05bc475c26c22eb89a6b6e5ebaf78e9ca23e 100644 (file)
@@ -33,8 +33,7 @@ static Standard_CString nulsign = "";
    const Handle(Interface_InterfaceModel)& /*model*/) const
 {
   if (ent.IsNull()) return nulsign;
-  DeclareAndCast(Standard_Type,atype,ent);
-  if (atype.IsNull()) atype = ent->DynamicType();
+  Handle(Standard_Type) atype = ent->DynamicType();
   Standard_CString tn = atype->Name();
   if (!thenopk) return tn;
   for (int i = 0; tn[i] != '\0'; i ++) {
index a2504d05a119df045cbe192b154df8e528d25896..b6cc283453cfc1ca5b9698c4ff9830a31c06c3ba 100644 (file)
@@ -250,7 +250,7 @@ Standard_Boolean Interface_FileReaderTool::RecognizeByLib(const Standard_Integer
   }
   if (CN <= 0 || proto.IsNull()) return Standard_False;
 //   Se recaler dans GeneralLib : Creation de l entite vide
-  Handle(Standard_Type) typrot = proto->DynamicType();
+  const Handle(Standard_Type)& typrot = proto->DynamicType();
   for (glib.Start(); glib.More(); glib.Next()) {
     proto = glib.Protocol();
     if (proto.IsNull()) continue;
index 8448a7329a744d9b537e7938314c7f375bce8e60..692d8ab3242e58b497edb01f1eb107b75153eb5c 100644 (file)
@@ -110,8 +110,8 @@ private:
   Handle(Interface_Protocol) theproto;
   Handle(Interface_SignType) thesign;
   Interface_GeneralLib thelib;
-  Interface_DataMapOfTransientInteger thentnum;
-  TColStd_IndexedDataMapOfTransientTransient thentmod;
+  NCollection_DataMap<Handle(Standard_Type),Standard_Integer> thentnum;
+  NCollection_IndexedDataMap<Handle(Standard_Type),Handle(Standard_Transient)> thentmod;
 
 
 };
index d76e41575020ae1e27802a8bf68faaad670068f3..42c0cee4dec786ba5f3e88e87ec16f148044679f 100644 (file)
@@ -17,6 +17,7 @@
 #define _Message_Alert_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 DEFINE_STANDARD_HANDLE(Message_Alert, Standard_Transient)
 
index 8a04ef27cced168f08c00b3c66b3aa6e51a40f42..4fa8fe7a1739f517385d54bee569599fda4d0b66 100644 (file)
@@ -223,13 +223,9 @@ void Message_Algorithm::SendStatusMessages (const Message_ExecStatus& theStatus,
 
     // find message, prefixed by class type name, iterating by base classes if necessary
     TCollection_AsciiString aMsgName;
-    for (Handle(Standard_Type) aType = DynamicType(); ! aType.IsNull(); aType = aType->Parent())
-    {
+    Handle(Standard_Type) aType = DynamicType();
       aMsgName = aType->Name();
       aMsgName += aSuffix;
-      if (Message_MsgFile::HasMsg(aMsgName))
-        break;
-    }
 
     // create a message
     Message_Msg aMsg ( aMsgName );
index 04a65bba563e0cf36866bad34c4ec221f00c39f1..55858c5ba70f00ad05d7a8df52709d60a465f588 100644 (file)
@@ -76,7 +76,7 @@ void OSD_ThreadPool::EnumeratedThread::WaitIdle()
     myIdleEvent.Reset();
   }
 }
-
+#include <thread>
 // =======================================================================
 // function : DefaultPool
 // purpose  :
index 1e8ea28f7ccbe76ab777d1990487c0f927e1fb2a..2612a60fc850b81fa51eae68a1607a835c350ae5 100644 (file)
@@ -17,6 +17,7 @@
 #define OpenGl_Element_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Handle.hxx>
 
 class Graphic3d_FrameStatsDataTmp;
 class OpenGl_Workspace;
index eea4afdc26c3f499553bbeeddfa210dd7933126d..76a595ee50399fe579f8a9509ff543ef16bfda93 100644 (file)
@@ -17,6 +17,7 @@
 #define OpenGl_Resource_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 class OpenGl_Context;
 
index 6a39a1f97432d14ff11f7446dcad4e91caa3ac94..6406247d07ed581ce8b528676b5f8be9a832f575 100644 (file)
@@ -60,8 +60,7 @@ Standard_Boolean STEPSelections_SelectDerived::Matches(const Handle(Standard_Tra
     
   Standard_Boolean plex = module->IsComplex(CN);
     if (!plex) {
-      DeclareAndCast(Standard_Type,atype,ent);
-      if (atype.IsNull()) atype = ent->DynamicType();
+      Handle(Standard_Type) atype = ent->DynamicType();
       return atype->SubType(checker);
     } else {
       TColStd_SequenceOfAsciiString list;
index 72281a9552d8d8a59f370f4ce9e16baf7ff333a1..87e5c5af18de0de387010084cd7cbcdf723dbcf2 100644 (file)
@@ -15,6 +15,7 @@
 #define _SelectMgr_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Handle.hxx>
 
 class Graphic3d_Structure;
 class Graphic3d_TransformPers;
index db1e6bedd56000632b9c6a2a8f9bb5e629c195a5..479710e62d454a659341d9ba65d127de8a04710c 100644 (file)
@@ -870,7 +870,7 @@ Standard_Boolean ShapeConstruct_ProjectCurveOnSurface::PerformByProjLib(Handle(G
   Handle(Geom_Curve) cIso;
   Standard_Real t1, t2;
   
-  Handle(Standard_Type) sType = mySurf->Surface()->DynamicType();
+  const Handle(Standard_Type)& sType = mySurf->Surface()->DynamicType();
   Standard_Boolean isAnalytic = Standard_True;
   if (sType == STANDARD_TYPE(Geom_BezierSurface) || sType == STANDARD_TYPE(Geom_BSplineSurface)) isAnalytic = Standard_False; 
   Standard_Real uf, ul, vf, vl;
index 803e3341ce36df9459509e4437d4aefe3b6fb3bb..87074906faf4943471f1550e0103efe0b44f3f31 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <Standard_ArrayStreamBuffer.hxx>
 
+#include <cstring>
+
 // =======================================================================
 // function : Standard_ArrayStreamBuffer
 // purpose  :
index f03415c21229ea4c3500319c91743b5ad42454de..796ebaf745153bb5be6c81baa4113b70e912402a 100644 (file)
 //! Since OCCT 7.0, relevant macros are provided by Standard_Type.hxx and Standard_Handle.hxx.
 
 #include <Standard_Type.hxx>
+#include <Standard_Handle.hxx>
 
 class Standard_Transient;
 class Standard_Persistent;
-class Standard_Type;
 
 // Obsolete macros kept for compatibility
 #define IMPLEMENT_DOWNCAST(C1,BC)
index acfbdd4b870db0930b16502c7d4b2d8524b1a52b..a34f99d604dc943b9b52649803acde864cb082b4 100644 (file)
@@ -16,6 +16,7 @@
 #define _Standard_Persistent_HeaderFile
 
 #include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
 
 //! Root of "persistent" classes, a legacy support of
 //! object oriented databases, now outdated.
index fa71956bfa8e1e8daef38d6090e246ad129c9720..72e17844cdee8ef22349ee50821d776e2214ac55 100644 (file)
 #include <Standard_CString.hxx>
 #include <Standard_ProgramError.hxx>
 
-const Handle(Standard_Type)& Standard_Transient::get_type_descriptor ()
+const Handle(Standard_Type)& Standard_Transient::get_type_descriptor()
 {
-  return opencascade::type_instance<Standard_Transient>::get();
+  static const opencascade::handle<Standard_Type> THE_TYPE_INSTANCE(new Standard_Type(typeid(Standard_Transient), get_type_name(),
+                                                                    sizeof(Standard_Transient), nullptr));
+  return THE_TYPE_INSTANCE;
 }
 
 //
index 024c631d2751f630302162dffcab432638c0d146..1e62e8855ddcd81fe759c9018846d0c1c5d5a027 100644 (file)
@@ -122,4 +122,6 @@ private:
 //! Definition of Handle_Standard_Transient as typedef for compatibility
 typedef opencascade::handle<Standard_Transient> Handle_Standard_Transient;
 
+#include <Standard_Handle.hxx>
+
 #endif 
index 6321deab29b078fa75bc1b62757f9efc7371624a..7d4e16bdc65b0413e8e96fb4cf73419de8ef4aa6 100644 (file)
@@ -1,5 +1,5 @@
 // Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 1999-2024 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-
 #include <Standard_Type.hxx>
-#include <Standard_Mutex.hxx>
-#include <Standard_Assert.hxx>
-
-#include <unordered_map>
-
-IMPLEMENT_STANDARD_RTTIEXT(Standard_Type,Standard_Transient)
-
-//============================================================================
-
-Standard_Type::Standard_Type (const std::type_info& theInfo,
-                              const char* theName,
-                              Standard_Size theSize,
-                              const Handle(Standard_Type)& theParent) :
-  myInfo(theInfo),
-  myName(theName),
-  mySize(theSize), 
-  myParent(theParent)
-{
-}
 
 //============================================================================
-
 Standard_Boolean Standard_Type::SubType (const Handle(Standard_Type)& theOther) const
 {
-  return ! theOther.IsNull() && (theOther == this || (! myParent.IsNull() && myParent->SubType (theOther)));
+  const Standard_Type* aTypeIter = this;
+  while (aTypeIter != nullptr)
+  {
+    if (*theOther == *aTypeIter)
+    {
+      return true;
+    }
+    aTypeIter = aTypeIter->Parent();
+  }
+  return false;
 }
 
 //============================================================================
 
 Standard_Boolean Standard_Type::SubType (const Standard_CString theName) const
 {
-  return theName != 0 && (IsEqual (myName, theName) || (! myParent.IsNull() && myParent->SubType (theName)));
+  const Standard_Type* aTypeIter = this;
+  while (aTypeIter != nullptr)
+  {
+    if (IsEqual(theName, aTypeIter->Name()))
+    {
+      return true;
+    }
+    aTypeIter = aTypeIter->Parent();
+  }
+  return false;
 }
 
 // ------------------------------------------------------------------
@@ -54,54 +51,4 @@ Standard_Boolean Standard_Type::SubType (const Standard_CString theName) const
 void Standard_Type::Print (Standard_OStream& AStream) const
 {
   AStream << std::hex << (Standard_Address)this << " : " << std::dec << myName ;
-}
-
-//============================================================================
-// Registry of types
-//============================================================================
-
-namespace {
-  // Map of string to type
-  typedef std::unordered_map<std::type_index, Standard_Type*> registry_type;
-
-  // Registry is made static in the function to ensure that it gets
-  // initialized by the time of first access
-  registry_type& GetRegistry() 
-  {
-    static registry_type theRegistry;
-    return theRegistry;
-  }
-
-  // To initialize theRegistry map as soon as possible to be destroyed the latest
-  Handle(Standard_Type) theType = STANDARD_TYPE(Standard_Transient);
-}
-
-Standard_Type* Standard_Type::Register (const std::type_info& theInfo, const char* theName,
-                                        Standard_Size theSize, const Handle(Standard_Type)& theParent)
-{
-  // Access to registry is protected by mutex; it should not happen often because
-  // instances are cached by Standard_Type::Instance() (one per binary module)
-  static Standard_Mutex theMutex;
-  Standard_Mutex::Sentry aSentry (theMutex);
-
-  // return existing descriptor if already in the registry
-  registry_type& aRegistry = GetRegistry();
-  Standard_Type* aType = 0;
-  auto anIter = aRegistry.find(theInfo);
-  if (anIter != aRegistry.end())
-    return anIter->second;
-
-  // else create a new descriptor
-  aType = new Standard_Type (theInfo, theName, theSize, theParent);
-
-  // then add it to registry and return (the reference to the handle stored in the registry)
-  aRegistry.emplace(theInfo, aType);
-  return aType;
-}
-
-Standard_Type::~Standard_Type ()
-{
-  // remove descriptor from the registry
-  registry_type& aRegistry = GetRegistry();
-  Standard_ASSERT(aRegistry.erase(myInfo) > 0, "Standard_Type::~Standard_Type() cannot find itself in registry",);
-}
+}
\ No newline at end of file
index 6608b757e995c71d57b326dbfef7b463be12a431..26bc8341274767ff662a184ef61f37e42b1d2250 100644 (file)
@@ -1,5 +1,5 @@
 // Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 1999-2024 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
 #define _Standard_Type_HeaderFile
 
 #include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Transient.hxx>
 #include <Standard_OStream.hxx>
+#include <Standard_Transient.hxx>
 
+#include <functional>
 #include <typeinfo>
 #include <typeindex>
 
-// Auxiliary tools to check at compile time that class declared as base in 
-// DEFINE_STANDARD_RTTI* macro is actually a base class.
-#if ! defined(OCCT_CHECK_BASE_CLASS)
-
-#if (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4)))
-
-// For GCC 4.7+, more strict check is possible -- ensuring that base class 
-// is direct base -- using non-standard C++ reflection functionality.
+namespace opencascade
+{
+  template <class T> class handle;
+}
 
-#include <tr2/type_traits>
-#include <tuple>
+class Standard_Transient;
 
-namespace opencascade 
+class Standard_Type
 {
-  template<typename T>
-  struct direct_base_class_as_tuple {};
+public:
 
-  template<typename ... Ts>
-  struct direct_base_class_as_tuple<std::tr2::__reflection_typelist<Ts...> >
+  Standard_Type(const std::type_info& theInfo,
+                const Standard_CString theName,
+                const Standard_Size theSize,
+                const Standard_Type* theParent) :
+    myInfo(theInfo),
+    myName(theName),
+    mySize(theSize),
+    myParent(theParent) {}
+
+  Standard_Type(const Standard_Type& theType) :
+    myInfo(theType.myInfo),
+    myName(theType.myName),
+    mySize(theType.mySize),
+    myParent(theType.myParent) {}
+
+  Standard_Type(Standard_Type&& theType) noexcept :
+    myInfo(theType.myInfo),
+    myName(theType.myName),
+    mySize(theType.mySize),
+    myParent(theType.myParent) {}
+
+  Standard_Type& operator=(const Standard_Type& theOther)
   {
-    typedef std::tuple<Ts...> type;
-  };
+    myInfo = theOther.myInfo;
+    myName = theOther.myName;
+    mySize = theOther.mySize;
+    myParent = theOther.myParent;
+    return *this;
+  }
 
-  template <typename T, typename Tuple>
-  struct has_type;
+  //! Returns the system type name of the class (typeinfo.name)
+  Standard_CString SystemName() const { return myInfo.get().name(); }
 
-  template <typename T>
-  struct has_type<T, std::tuple<> > : std::false_type {};
+  //! Returns the hash code of the class (typeinfo.hash_code)
+  Standard_Size HashCode() const { return myInfo.get().hash_code(); }
 
-  template <typename T, typename U, typename... Ts>
-  struct has_type<T, std::tuple<U, Ts...> > : has_type<T, std::tuple<Ts...> > {};
+  //! Returns the given name of the class type (get_type_name)
+  Standard_CString Name() const { return myName; }
 
-  template <typename T, typename... Ts>
-  struct has_type<T, std::tuple<T, Ts...> > : std::true_type {};
-}
+  //! Returns the size of the class instance in bytes
+  Standard_Size Size() const { return mySize; }
 
-#define OCCT_CHECK_BASE_CLASS(Class,Base) \
-  using direct_base_classes = opencascade::direct_base_class_as_tuple<std::tr2::direct_bases<Class>::type>::type; \
-  static_assert(opencascade::has_type<Base, direct_base_classes>::type::value, "OCCT RTTI definition is incorrect: " #Base " is not direct base class of " #Class); \
-  static_assert(&get_type_name == &Class::get_type_name, "OCCT RTTI definition is misplaced: current class is not " #Class);
+  //! Returns descriptor of the base class in the hierarchy. Can be null
+  const Standard_Type* Parent() const { return myParent; }
 
-#elif (defined(_MSC_VER) && (_MSC_VER >= 1900))
+  bool operator==(const Standard_Type& theType) const { return myInfo.get() == theType.myInfo.get(); }
 
-// VC14+ allow using address of member functions in static checks,
-// that allows checking for the current type being correctly named in the macro
-#define OCCT_CHECK_BASE_CLASS(Class,Base) \
-  static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class); \
-  static_assert(&get_type_name == &Class::get_type_name, "OCCT RTTI definition is misplaced: current class is not " #Class);
+  bool operator==(const std::type_info& theInfo) const { return myInfo.get() == theInfo; }
+
+  //! Returns True if this type is the same as theOther, or inherits from theOther.
+  //! Note that multiple inheritance is not supported.
+  Standard_EXPORT Standard_Boolean SubType (const Handle(Standard_Type)& theOther) const;
 
-#else
+  //! Returns True if this type is the same as theOther, or inherits from theOther.
+  //! Note that multiple inheritance is not supported.
+  Standard_EXPORT Standard_Boolean SubType (const Standard_CString theOther) const;
+
+  //! Prints type (address of descriptor + name) to a stream
+  Standard_EXPORT void Print (Standard_OStream& theStream) const;
+
+private:
+  std::reference_wrapper<const std::type_info> myInfo; //!< STL Type descriptor of current class
+  Standard_CString myName; //!< Given name of the class
+  Standard_Size mySize;    //!< Size of the class instance, in bytes
+  const Standard_Type* myParent; //!< Type descriptor of parent class
+};
+
+namespace opencascade
+{
+  template <>
+  class handle<Standard_Type>
+  {
+  public:
+    //! STL-compliant typedef of contained type
+    typedef Standard_Type element_type;
+  public:
+    //! Empty constructor
+    handle() : myObject(nullptr) {}
+    //! Constructor from pointer to new object
+    handle (const Standard_Type* theType) : myObject(theType) {}
+    //! Copy constructor
+    handle (const handle& theHandle) : myObject(theHandle.myObject) {}
+    //! Assignment operator
+    handle& operator= (const handle& theHandle)
+    {
+      myObject = theHandle.myObject;
+      return *this;
+    }
+  
+    bool IsNull() const { return myObject == nullptr; }
+  
+    bool operator== (const handle& theHandle) const
+    {
+      return myObject == theHandle.myObject;
+    }
+  
+    bool operator!= (const handle& theHandle) const
+    {
+      return !(myObject == theHandle.myObject);
+    }
+  
+    //! STL-like cast to pointer to referred object (note non-const).
+    //! @sa std::shared_ptr::get()
+    const Standard_Type* get() const { return myObject; }
+    //! Member access operator (note non-const)
+    const Standard_Type* operator-> () const { return myObject; }
+    //! Dereferencing operator (note non-const)
+    const Standard_Type& operator* () const { return *myObject; }
+  private:
+    const Standard_Type* myObject;
+  };
+}
+
+//! Operator printing type descriptor to stream
+inline Standard_OStream& operator << (Standard_OStream& theStream, const opencascade::handle<Standard_Type>& theType) 
+{
+  theStream << theType->Name();
+  return theStream;
+}
 
 // by default, check only the base class
 #define OCCT_CHECK_BASE_CLASS(Class,Base) \
   static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class);
 
-#endif
-
-#endif /* ! defined(OCCT_CHECK_BASE_CLASS) */
+namespace std
+{
+  template <>
+  struct hash<Standard_Type>
+  {
+    size_t operator()(const Standard_Type& theType) const noexcept
+    {
+      return theType.HashCode();
+    }
+  };
+}
 
 //! Helper macro to get instance of a type descriptor for a class in a legacy way.
 #define STANDARD_TYPE(theType) theType::get_type_descriptor()
@@ -93,8 +181,13 @@ namespace opencascade
 #define DEFINE_STANDARD_RTTI_INLINE(Class,Base) \
 public: \
   typedef Base base_type; \
-  static const char* get_type_name () { return #Class; OCCT_CHECK_BASE_CLASS(Class,Base) } \
-  static const Handle(Standard_Type)& get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
+  static const char* get_type_name() { return #Class; } \
+  static const Handle(Standard_Type)& get_type_descriptor() \
+  { \
+    static const Handle(Standard_Type) THE_TYPE_INSTANCE(new Standard_Type(typeid(Class), get_type_name(), \
+                                                         sizeof(Class), Base::get_type_descriptor().get())); \
+    return THE_TYPE_INSTANCE; \
+  } \
   virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE { return get_type_descriptor (); }
 
 //! Helper macro to be included in definition of the classes inheriting
@@ -104,186 +197,18 @@ public: \
 #define DEFINE_STANDARD_RTTIEXT(Class,Base) \
 public: \
   typedef Base base_type; \
-  static const char* get_type_name () { return #Class; OCCT_CHECK_BASE_CLASS(Class,Base) } \
-  Standard_EXPORT static const Handle(Standard_Type)& get_type_descriptor (); \
+  static const char* get_type_name() { return #Class; } \
+  Standard_EXPORT static const Handle(Standard_Type)& get_type_descriptor(); \
   Standard_EXPORT virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE;
 
 //! Defines implementation of type descriptor and DynamicType() function
 #define IMPLEMENT_STANDARD_RTTIEXT(Class,Base) \
-  const Handle(Standard_Type)& Class::get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
-  const Handle(Standard_Type)& Class::DynamicType() const { return STANDARD_TYPE(Class); }
-
-// forward declaration of type_instance class
-namespace opencascade {
-  template <typename T>
-  class type_instance;
-}
-
-//! This class provides legacy interface (type descriptor) to run-time type
-//! information (RTTI) for OCCT classes inheriting from Standard_Transient.
-//!
-//! In addition to features provided by standard C++ RTTI (type_info), 
-//! Standard_Type allows passing descriptor as an object and using it for 
-//! analysis of the type:
-//! - get descriptor of a parent class
-//! - get user-defined name of the class
-//! - get size of the object
-//! 
-//! Use static template method Instance() to get descriptor for a given type.
-//! Objects supporting OCCT RTTI return their type descriptor by method DynamicType().
-//! 
-//! To be usable with OCCT type system, the class should provide:
-//! - typedef base_type to its base class in the hierarchy
-//! - method get_type_name() returning programmer-defined name of the class
-//!   (as a statically allocated constant C string or string literal)
-//!
-//! Note that user-defined name is used since typeid.name() is usually mangled in 
-//! compiler-dependent way.
-//! 
-//! Only single chain of inheritance is supported, with a root base class Standard_Transient.
-
-class Standard_Type : public Standard_Transient
-{
-public:
-
-  //! Returns the system type name of the class (typeinfo.name)
-  Standard_CString SystemName() const { return myInfo.name(); }
-  
-  //! Returns the given name of the class type (get_type_name)
-  Standard_CString Name() const { return myName; }
-  
-  //! Returns the size of the class instance in bytes
-  Standard_Size Size() const { return mySize; }
-
-  //! Returns descriptor of the base class in the hierarchy
-  const Handle(Standard_Type)& Parent () const { return myParent; }
-  
-  //! Returns True if this type is the same as theOther, or inherits from theOther.
-  //! Note that multiple inheritance is not supported.
-  Standard_EXPORT Standard_Boolean SubType (const Handle(Standard_Type)& theOther) const;
-
-  //! Returns True if this type is the same as theOther, or inherits from theOther.
-  //! Note that multiple inheritance is not supported.
-  Standard_EXPORT Standard_Boolean SubType (const Standard_CString theOther) const;
-
-  //! Prints type (address of descriptor + name) to a stream
-  Standard_EXPORT void Print (Standard_OStream& theStream) const;
-
-  //! Template function returning instance of the type descriptor for an argument class.
-  //!
-  //! For optimization, each type is registered only once (due to use of the static variable).
-  //!
-  //! See helper macro DEFINE_STANDARD_RTTI for defining these items in the class.
-  template <class T>
-  static const Handle(Standard_Type)& Instance()
-  {
-    return opencascade::type_instance<T>::get();
-  }
-
-  //! Register a type; returns either new or existing descriptor.
-  //!
-  //! @param theInfo object stores system name of the class
-  //! @param theName name of the class to be stored in Name field
-  //! @param theSize size of the class instance
-  //! @param theParent base class in the Transient hierarchy
-  //!
-  //! Note that this function is intended for use by opencascade::type_instance only. 
-  Standard_EXPORT static 
-    Standard_Type* Register (const std::type_info& theInfo, const char* theName,
-                             Standard_Size theSize, const Handle(Standard_Type)& theParent);
-
-  //! Destructor removes the type from the registry
-  Standard_EXPORT ~Standard_Type ();
-
-  // Define own RTTI
-  DEFINE_STANDARD_RTTIEXT(Standard_Type,Standard_Transient)
-
-private:
-
-  //! Constructor is private
-  Standard_Type (const std::type_info& theInfo, const char* theName,
-                 Standard_Size theSize, const Handle(Standard_Type)& theParent);
-
-private:
-  std::type_index myInfo;         //!< Object to store system name of the class
-  Standard_CString myName;        //!< Given name of the class
-  Standard_Size mySize;           //!< Size of the class instance, in bytes
-  Handle(Standard_Type) myParent; //!< Type descriptor of parent class
-};
-
-namespace opencascade {
-
-  //! Template class providing instantiation of type descriptors as singletons.
-  //! The descriptors are defined as static variables in function get(), which
-  //! is essential to ensure that they are initialized in correct sequence.
-  //!
-  //! For compilers that do not provide thread-safe initialization of static
-  //! variables (C++11 feature, N2660), additional global variable is
-  //! defined for each type to hold its type descriptor. These globals ensure
-  //! that all types get initialized during the library loading and thus no 
-  //! concurrency occurs when type system is accessed from multiple threads.
-  template <typename T>
-  class type_instance
-  {
-    static Handle(Standard_Type) myInstance;
-  public:
-    static const Handle(Standard_Type)& get ();
-  };
-
-  //! Specialization of type descriptor instance for void; returns null handle
-  template <>
-  class type_instance<void>
-  {
-  public:
-    static Handle(Standard_Type) get () { return 0; }
-  };
-
-  // Implementation of static function returning instance of the
-  // type descriptor
-  template <typename T>
-  const Handle(Standard_Type)& type_instance<T>::get ()
-  {
-#if (defined(_MSC_VER) && _MSC_VER < 1900) || \
-    (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) && \
-     ! defined(__clang__) && ! defined(__INTEL_COMPILER))
-    // ensure that myInstance is instantiated
-    (void)myInstance;
-#endif
-
-    // static variable inside function ensures that descriptors
-    // are initialized in correct sequence
-    static Handle(Standard_Type) anInstance =
-      Standard_Type::Register (typeid(T), T::get_type_name(), sizeof(T), 
-                               type_instance<typename T::base_type>::get());
-    return anInstance;
-  }
-
-  // Static class field is defined to ensure initialization of all type
-  // descriptors at load time of the library on compilers not supporting N2660:
-  // - VC++ below 14 (VS 2015)
-  // - GCC below 4.3
-  // Intel compiler reports itself as GCC on Linux and VC++ on Windows,
-  // and is claimed to support N2660 on Linux and on Windows "in VS2015 mode".
-  // CLang should support N2660 since version 2.9, but it is not clear how to 
-  // check its version reliably (on Linux it says it is GCC 4.2).
-#if (defined(_MSC_VER) && _MSC_VER < 1900) || \
-    (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) && \
-     ! defined(__clang__) && ! defined(__INTEL_COMPILER))
-
-  template <typename T>
-  Handle(Standard_Type) type_instance<T>::myInstance (get());
-
-#endif
-}
-
-//! Operator printing type descriptor to stream
-inline Standard_OStream& operator << (Standard_OStream& theStream, const Handle(Standard_Type)& theType) 
-{
-  theType->Print (theStream);
-  return theStream;
-}
-
-//! Definition of Handle_Standard_Type as typedef for compatibility
-DEFINE_STANDARD_HANDLE(Standard_Type,Standard_Transient)
+  const Handle(Standard_Type)& Class::get_type_descriptor() \
+  { \
+    static const Handle(Standard_Type) THE_TYPE_INSTANCE(new Standard_Type(typeid(Class), get_type_name(), \
+                                                         sizeof(Class), Base::get_type_descriptor().get())); \
+    return THE_TYPE_INSTANCE; \
+  } \
+  const Handle(Standard_Type)& Class::DynamicType() const { return get_type_descriptor(); }
 
 #endif // _Standard_Type_HeaderFile
index 20841eb3ec104ddf46809990b14b36135b70cad7..149f3cbc0a1d8bdbfc33474b1befd9d4b7ecb94d 100644 (file)
@@ -756,7 +756,7 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI
 #include <StepVisual_TriangulatedSurfaceSet.hxx>
 
 static int THE_StepAP214_Protocol_init = 0;
-static Interface_DataMapOfTransientInteger types(819);
+static NCollection_DataMap<Handle(Standard_Type), Standard_Integer> types(819);
 
 //=======================================================================
 //function : StepAP214_Protocol
index 6a264f7c88c595948dc498363007522c2185470a..90a990d9026da8533fef9961b5a9f0f8dd8cfa76 100644 (file)
@@ -31,7 +31,7 @@ static Standard_CString  thename = "";
     void StepData_FileProtocol::Add (const Handle(StepData_Protocol)& protocol)
 {
   if (protocol.IsNull()) return;
-  Handle(Standard_Type) ptype = protocol->DynamicType();
+  const Handle(Standard_Type)& ptype = protocol->DynamicType();
   Standard_Integer nb = thecomps.Length();
   for (Standard_Integer i = 1; i <= nb; i ++) {
     if (thecomps.Value(i)->IsInstance(ptype)) return;
index cd5cb1f67d141e06ae1457aae4923342096fb155..68456062b32254b3f4ca990ac92f997759dafb92 100644 (file)
@@ -84,7 +84,7 @@ StepData_PDescr::StepData_PDescr  ()
       {  thekind = KindEntity;  thetype = atype;  thednam.Clear();  }
 
     void  StepData_PDescr::SetDescr (const Standard_CString dscnam)
-      {  thekind = KindEntity;  thetype.Nullify();
+      {  thekind = KindEntity;  thetype = Handle(Standard_Type)();
         thednam.Clear();  thednam.AssignCat(dscnam);  }
 
     void  StepData_PDescr::AddArity (const Standard_Integer arity)
index 56921cbe6e351462a4e0ebcf9584932f9be7573f..2249d4e913d67fa840a3036d844900027f7e3778 100644 (file)
@@ -18,6 +18,7 @@
 #define StepFile_Read_HeaderFile
 
 #include <Standard_CString.hxx>
+#include <Standard_Handle.hxx>
 #include <Standard_Type.hxx>
 
 #include <iostream>
index 7caab6b96c77b5221472c9443196480b7cb8f254..ac83411114bfd30206a6d852300849c21b33c259 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <StepVisual_CoordinatesList.hxx>
 #include <StepVisual_TessellatedItem.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(StepVisual_CoordinatesList,StepGeom_TessellatedItem)
+IMPLEMENT_STANDARD_RTTIEXT(StepVisual_CoordinatesList, StepVisual_TessellatedItem)
 
 StepVisual_CoordinatesList::StepVisual_CoordinatesList ()  {}
 
index da4f391e219836b05d2a8f87014baecf6e333180..c992bb4e15c05b7d69ac40158c99beecbcdbb2f1 100644 (file)
@@ -15,7 +15,7 @@
 #include <StepVisual_TessellatedGeometricSet.hxx>
 
 
-IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TessellatedGeometricSet,StepGeom_TessellatedItem)
+IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TessellatedGeometricSet, StepVisual_TessellatedItem)
 
 
 StepVisual_TessellatedGeometricSet::StepVisual_TessellatedGeometricSet ()  {}
index b8565a2c2532579bc5fcc5c85ab78cde1ac4504b..057d5d19ff4ccadae96ab1a2d6208e53c306c0fd 100644 (file)
@@ -39,9 +39,9 @@ TColStd_SequenceOfTransient& TObj_Assistant::getModels()
 //purpose  : 
 //=======================================================================
 
-TColStd_IndexedMapOfTransient& TObj_Assistant::getTypes()
+NCollection_IndexedMap<Handle(Standard_Type)>& TObj_Assistant::getTypes()
 {
-  static TColStd_IndexedMapOfTransient sTypes;
+  static NCollection_IndexedMap<Handle(Standard_Type)> sTypes;
   return sTypes;
 }
 
@@ -119,7 +119,7 @@ Handle(Standard_Type) TObj_Assistant::FindType
   (const Standard_Integer theTypeIndex)
 {
   if(theTypeIndex > 0 && theTypeIndex <= getTypes().Extent())
-    return Handle(Standard_Type)::DownCast(getTypes().FindKey(theTypeIndex));
+    return getTypes().FindKey(theTypeIndex);
 
   return 0;
 }
@@ -166,12 +166,12 @@ DEFINE_STANDARD_HANDLE(TObj_Assistant_UnknownType,Standard_Transient)
 Standard_Integer TObj_Assistant::BindType
   (const Handle(Standard_Type)& theType)
 {
-  if(theType.IsNull())
-  {
-    Handle(Standard_Transient) anUnknownType;
-    anUnknownType = new TObj_Assistant_UnknownType;
-    return getTypes().Add(anUnknownType);
-  }
+  // if(!theType)
+  // {
+  //   Handle(Standard_Transient) anUnknownType;
+  //   anUnknownType = new TObj_Assistant_UnknownType;
+  //   return getTypes().Add(anUnknownType);
+  // }
 
   return getTypes().Add(theType);
 }
index b26bb7772fc2ac5c3d7eb984eee7ca2a6def5849..71987cdf5f4a04491d935292b260bcf4b95c180d 100644 (file)
@@ -103,7 +103,7 @@ private:
   static Standard_EXPORT TColStd_SequenceOfTransient&   getModels();
 
   //! Method for taking fields for map types
-  static Standard_EXPORT TColStd_IndexedMapOfTransient& getTypes();
+  static Standard_EXPORT NCollection_IndexedMap<Handle(Standard_Type)>& getTypes();
 
   //! Method for taking fields for the Current model
   static Standard_EXPORT Handle(TObj_Model)&            getCurrentModel();
index d754de96201c90c2823a61125f60c78eeef58c7a..19d474486635660718c6c29faedfba21aa933d99 100644 (file)
@@ -1220,7 +1220,7 @@ Standard_Boolean TObj_Object::copyData
                 (const Handle(TObj_Object)& theTargetObject)
 {
   Standard_Boolean IsDone = Standard_False;
-  if ( !theTargetObject->DynamicType()->SubType( DynamicType() ) )
+  if ( !theTargetObject->IsKind( DynamicType() ) )
     return IsDone;
   // init the copier by labels.
   TDF_Label aDataLabel = GetDataLabel();
index 7d81b210d0b97608e165863512e3f5a474cce39a..062bbe16f459f799abdf142b1f6181c77c3b3dfa 100644 (file)
@@ -51,17 +51,13 @@ static Handle(Standard_Transient)   nultrans;  // pour retour const&(Null)
     void  Transfer_TransferIterator::SelectResult
   (const Handle(Standard_Type)& atype, const Standard_Boolean keep)
 {
-  Standard_Integer casetype = 0;
-  if (atype->SubType(STANDARD_TYPE(Standard_Transient)))  casetype = 2;
-
   for (Standard_Integer i = theitems->Length(); i > 0; i --) {
     Handle(Transfer_Binder) atr = theitems->Value(i);
     Handle(Standard_Type) btype = ResultType();
     Standard_Boolean matchtype;
     if      (!atr->HasResult()) matchtype = Standard_False;
     else if (atr->IsMultiple()) matchtype = Standard_False;
-    else if (casetype == 0) matchtype = (atype == btype);         // Type fixe
-    else                    matchtype = (btype->SubType(atype));  // Dynamique
+    else                        matchtype = (btype->SubType(atype));
     if (matchtype != keep) {
       theselect->SetValue(i,0);
       if (themaxi == i) themaxi = i-1;
@@ -154,8 +150,7 @@ static Handle(Standard_Transient)   nultrans;  // pour retour const&(Null)
     Standard_Boolean  Transfer_TransferIterator::HasTransientResult () const
 {
   Handle(Standard_Type) btype = ResultType();
-  if (btype.IsNull()) return Standard_False;
-  return btype->SubType(STANDARD_TYPE(Standard_Transient));
+  return !btype.IsNull();
 }
 
     const Handle(Standard_Transient)&
index 28f46daa1a71bb1fdfe0c3af94b8b054b3b8bd08..3ad294c1ca225c04c736e99affb24971b6cdabf2 100644 (file)
@@ -36,7 +36,7 @@ namespace {
 
 }
 
-IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NotesTool, XCAFDoc_NoteComment)
+IMPLEMENT_DERIVED_ATTRIBUTE(XCAFDoc_NotesTool, TDataStd_GenericEmpty)
 
 enum NotesTool_RootLabels
 {
index 304ec8110d14b2bb870a86de122c65ec5d45c1ce..ba00dd6712258db36f5bcc7e2a7d307bd97058ee 100644 (file)
@@ -112,8 +112,7 @@ static const Standard_ExtString   voidext = { 0 };
   (const Handle(Standard_Transient)& item, const Standard_Boolean nopk) const
 {
   if (item.IsNull()) return "";
-  DeclareAndCast(Standard_Type,atype,item);
-  if (atype.IsNull()) atype = item->DynamicType();
+  Handle(Standard_Type) atype = item->DynamicType();
   Standard_CString tn = atype->Name();
   if (!nopk) return tn;
   for (int i = 0; tn[i] != '\0'; i ++) {
index 511a5447c68b2b65a160bf6ae993e6e2c6d2984d..f0817540fe306e99d000d84be4bd21997ac61ebd 100644 (file)
@@ -46,7 +46,7 @@ Handle(TDF_Attribute) XmlMDataStd_GenericEmptyDriver::NewEmpty() const
 //=======================================================================
 Handle(Standard_Type) XmlMDataStd_GenericEmptyDriver::SourceType() const
 {
-  return Standard_Type::Instance<TDataStd_GenericEmpty>();
+  return STANDARD_TYPE(TDataStd_GenericEmpty);
 }
 
 //=======================================================================
index 3b8bf7a5971fe675fa02f91f89d9faa6b95a83db..132ccd6d1e83ff859f8b90d63f211935f07715cd 100644 (file)
@@ -48,7 +48,7 @@ Handle(TDF_Attribute) XmlMDataStd_GenericExtStringDriver::NewEmpty () const
 //=======================================================================
 Handle(Standard_Type) XmlMDataStd_GenericExtStringDriver::SourceType() const
 {
-  return Standard_Type::Instance<TDataStd_GenericExtString>();
+  return STANDARD_TYPE(TDataStd_GenericExtString);
 }
 
 //=======================================================================