Archived issue #0024023
Revamp the OCCT Handle
Description
Replace the actual implementation of shared pointer used by OCCT (Handle) by a more modern solutions.
Additional information
Public activity
26 archived notes
Participants are labeled by their role within this record.
To add technical details, here are some practical concerns for this revamping.
The main challenge is to do this keeping existing interface so as to avoid a need to update all existing OCCT-dependent code...
1. Interaction with RTTI
Handle classes are used together with OCCT-specific implementation of run-time type identification (RTTI). For that, specific methods IsKind(), DynamicType(), are added to each class manipulated by Handle, and static function Standard_Type_* is created to instantiate relevant type object.
The latter static function represents particular problem: it has to be instantiated in C++ code. This is (major) reason of existence of extra files with extension ixx in drv subfolder. It is very desirable to get rid of this necessity as this would allow to eliminate these unnecessary files.
A possible way for this is to use C++ RTTI (typeid, typeinfo, dynamic_cast) instead of OCCT-specific one.
2. Inheritance of Handle classes
Handle classes in OCCT inherit each other, reflecting inheritance of the handled classes. This allow Handles to be passed by reference in function arguments, which is not possible e.g. with boost smart pointers. This is quite useful feature, and it is highly desirable to keep it.
3. No weak handles
Handles do not provide weak pointers, would be worth adding.
The main challenge is to do this keeping existing interface so as to avoid a need to update all existing OCCT-dependent code...
1. Interaction with RTTI
Handle classes are used together with OCCT-specific implementation of run-time type identification (RTTI). For that, specific methods IsKind(), DynamicType(), are added to each class manipulated by Handle, and static function Standard_Type_* is created to instantiate relevant type object.
The latter static function represents particular problem: it has to be instantiated in C++ code. This is (major) reason of existence of extra files with extension ixx in drv subfolder. It is very desirable to get rid of this necessity as this would allow to eliminate these unnecessary files.
A possible way for this is to use C++ RTTI (typeid, typeinfo, dynamic_cast) instead of OCCT-specific one.
2. Inheritance of Handle classes
Handle classes in OCCT inherit each other, reflecting inheritance of the handled classes. This allow Handles to be passed by reference in function arguments, which is not possible e.g. with boost smart pointers. This is quite useful feature, and it is highly desirable to keep it.
3. No weak handles
Handles do not provide weak pointers, would be worth adding.
Here is result of analysis of possibility to replace OCCT RTTI by standard C++ one, made by mpv:
-------
During the research of removal of "Standard_Type" class from OCCT performance in order to remove "RTTI" definitions is C++ code the next conclusions were achieved:
1. Modifications of "Standard" package must be serious, but most of them are simplification of existing code:
- remove Standard_Type and Standard_AncestorIterator classes
- # define STANDARD_TYPE(aType) typeid(aType)
- "typedef type_info Handle_Standard_Type;" in new Standard_Type.hxx for "imported Type;" in Standard.cdl
- remove "aType##_Type_()" method definitions from all atomic classes, like "Standard_Boolean_Type_()", so, some ".cxx" files also should be removed from "Standard" packages
- minor modification in WOK generated files: remove "class Standard_Type;" definition from all produced files
- changes in "HashCode" methods which use size of Standard_Type class
2. Modifications needed outside of "Standard" packages are minimal, like usage of Standard_AncestorIterator only in one method:
- Message_Algorithm::SendStatusMessages;
3. But serious limitation faced during this development is "IsKind" methods, used widely in OCCT sources. The problem is that the only method that can be used here is "dynamic_cast", but it is impossible to apply it on "type_info" object given as an argument. Visible solution here is usage of templates or macros instead of current API of "IsKind" method. But this requires serious changes in OCC sources and depended products and application.
-------
During the research of removal of "Standard_Type" class from OCCT performance in order to remove "RTTI" definitions is C++ code the next conclusions were achieved:
1. Modifications of "Standard" package must be serious, but most of them are simplification of existing code:
- remove Standard_Type and Standard_AncestorIterator classes
- # define STANDARD_TYPE(aType) typeid(aType)
- "typedef type_info Handle_Standard_Type;" in new Standard_Type.hxx for "imported Type;" in Standard.cdl
- remove "aType##_Type_()" method definitions from all atomic classes, like "Standard_Boolean_Type_()", so, some ".cxx" files also should be removed from "Standard" packages
- minor modification in WOK generated files: remove "class Standard_Type;" definition from all produced files
- changes in "HashCode" methods which use size of Standard_Type class
2. Modifications needed outside of "Standard" packages are minimal, like usage of Standard_AncestorIterator only in one method:
- Message_Algorithm::SendStatusMessages;
3. But serious limitation faced during this development is "IsKind" methods, used widely in OCCT sources. The problem is that the only method that can be used here is "dynamic_cast", but it is impossible to apply it on "type_info" object given as an argument. Visible solution here is usage of templates or macros instead of current API of "IsKind" method. But this requires serious changes in OCC sources and depended products and application.
One more point that could be addressed is incompatibility of Handle() macro with same-named class defined in CGAL library, described in
http://www.opencascade.org/org/forum/thread_23768/?forum=3
http://www.opencascade.org/org/forum/thread_23768/?forum=3
Idea by szv: we can provide transparent down casting for Handles, e.g.:
Handle(Geom_Curve) aC = ...;
Handle(Geom_BSplineCurve) aBspl = aC; // transparent down cast
Handle(Geom_Curve) aC = ...;
Handle(Geom_BSplineCurve) aBspl = aC; // transparent down cast
One more feature desired from handles is to be able to interact correctly with namespaces. Current implementation has a problem in that: since Handle(Class) is expanded to Handle_Class, it does not work if Class is defined not in the current namespace and has to be prefixed by namespace name. This can be avoided either by changing the Handle definition to Class_Handle, or by switching to use of templates.
We will have to use macros to add standard definitions for OCCT RTTI in classes inheriting Transient anyway. Currently this is not a big problem since most of instances of such macros are generated from CDL. When we get rid of CDL, these macros become sources. Then it will be easy to get inconsistent definition of such macro vs. actual class definition (w.r.t. class name, base class name). Thus we need some tool to check such consistency -- either a checking script, or a C++ compile time assert (or both).
Currently OCC handles offer the following two valuable advantages:
1. The least possible memory footprint. An extra cost is just a sizeof(int) for reference counter in the Standard_Transient.
(We don't count sizeof(void*) for vtbl in Standard_Transient assuming that these are its own costs).
This makes the handle an efficient alternative to shared_ptr when dealing with large number of objects where each byte counts.
In comparison, extra footprint of std::shared_ptr in MSVS2010 is sizeof(void*) + 2 * sizeof (long) + sizeof (void*) + sizeof (void*)
2 Ability to traverse hiearchy of types (using Standard_AncestorIterator).
Consider the following use case (from CAD Exchanger). There is a map (std::unordered_map) of {Handle_Standard_Type, V}, for instance a map of processors for entities.
To find a value V for type T the map owner first finds if there is a direct record {T, V}. If not it searches for {Parent_of_T, V} and so on until it finds a record or
finishes at {STANDARD_TYPE(Standard_Transient), V}. For example, this is used to process all Geom_Curve's in one way, and Geom_TrimmedCurve in some other way.
Standard RTTI (std::type_info) does not provide the ability to retrieve a direct ancestor. It only allows to compare if one type_info is an ancestor
(not necessarily immediate) of the other. Thus implementation of the above logic would hardly be possible.
So please consider the above points during refactoring.
Thank you.
1. The least possible memory footprint. An extra cost is just a sizeof(int) for reference counter in the Standard_Transient.
(We don't count sizeof(void*) for vtbl in Standard_Transient assuming that these are its own costs).
This makes the handle an efficient alternative to shared_ptr when dealing with large number of objects where each byte counts.
In comparison, extra footprint of std::shared_ptr in MSVS2010 is sizeof(void*) + 2 * sizeof (long) + sizeof (void*) + sizeof (void*)
2 Ability to traverse hiearchy of types (using Standard_AncestorIterator).
Consider the following use case (from CAD Exchanger). There is a map (std::unordered_map) of {Handle_Standard_Type, V}, for instance a map of processors for entities.
To find a value V for type T the map owner first finds if there is a direct record {T, V}. If not it searches for {Parent_of_T, V} and so on until it finds a record or
finishes at {STANDARD_TYPE(Standard_Transient), V}. For example, this is used to process all Geom_Curve's in one way, and Geom_TrimmedCurve in some other way.
Standard RTTI (std::type_info) does not provide the ability to retrieve a direct ancestor. It only allows to compare if one type_info is an ancestor
(not necessarily immediate) of the other. Thus implementation of the above logic would hardly be possible.
So please consider the above points during refactoring.
Thank you.
Regarding the above "transparent down casting for Handles, e.g.:
Handle(Geom_Curve) aC = ...;
Handle(Geom_BSplineCurve) aBspl = aC; // transparent down cast "
Please do NOT enable that !
This contradicts with strict type cast which C++ applies to the pointers (including shared_ptr). You should receive a compilation time error and address the issue in the compile, not in run time.
Handle is essentially a pointer and hence should inherit the same logic.
You should be able to write
Handle_Geom_Curve aC = aBspl;
but not the other way around.
Just like you would be able to write:
Geom_Curve* aCP = aBsplP; //where aBsplP is Geom_BSplineCurve
or
std::shared_ptr<Geom_Curve> aCSP = aBsplSP; //where aBsplSP is shared_ptr<Geom_BSplineCurve>
and not the other way around.
Detecting errors at compile time is the cheapest, so all the efforts should be applied to retain that.
Handle(Geom_Curve) aC = ...;
Handle(Geom_BSplineCurve) aBspl = aC; // transparent down cast "
Please do NOT enable that !
This contradicts with strict type cast which C++ applies to the pointers (including shared_ptr). You should receive a compilation time error and address the issue in the compile, not in run time.
Handle is essentially a pointer and hence should inherit the same logic.
You should be able to write
Handle_Geom_Curve aC = aBspl;
but not the other way around.
Just like you would be able to write:
Geom_Curve* aCP = aBsplP; //where aBsplP is Geom_BSplineCurve
or
std::shared_ptr<Geom_Curve> aCSP = aBsplSP; //where aBsplSP is shared_ptr<Geom_BSplineCurve>
and not the other way around.
Detecting errors at compile time is the cheapest, so all the efforts should be applied to retain that.
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Fri Jun 12 09:08:32 2015 +0300
Next step...
Author: abv
Date: Tue Jun 9 06:27:30 2015 +0300
First attempt to make non-inheriting handle
Author: abv
Date: Tue Apr 8 16:26:21 2014 +0400
0024023: Revamp the OCCT Handle
*** NOTE: THIS CHANGE IS INCOMPLETE ***
Macro defining Handle class is replaced by template class implementing the same concept (defined in Standard_Handle.hxx and Standard_Transient.hxx).
Header file Standard_DefineHandle.hxx becomes deprecated: the only useful macro DEFINE_STANDARD_RTTI is defined now in Standard_Type.hxx. Standard_DefineHandle.hxx is kept for compatibility, it defines macros previously used for definition of Handles and RTTI as empty.
Definition of macro Handle() and STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_Handle.hxx (new file) and Standard_Type.hxx, respectively.
Conflicts:
src/Standard/Standard_Macro.hxx
[revision removed]
Detailed log of new commits:
Author: abv
Date: Fri Jun 12 09:08:32 2015 +0300
Next step...
Author: abv
Date: Tue Jun 9 06:27:30 2015 +0300
First attempt to make non-inheriting handle
Author: abv
Date: Tue Apr 8 16:26:21 2014 +0400
0024023: Revamp the OCCT Handle
*** NOTE: THIS CHANGE IS INCOMPLETE ***
Macro defining Handle class is replaced by template class implementing the same concept (defined in Standard_Handle.hxx and Standard_Transient.hxx).
Header file Standard_DefineHandle.hxx becomes deprecated: the only useful macro DEFINE_STANDARD_RTTI is defined now in Standard_Type.hxx. Standard_DefineHandle.hxx is kept for compatibility, it defines macros previously used for definition of Handles and RTTI as empty.
Definition of macro Handle() and STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_Handle.hxx (new file) and Standard_Type.hxx, respectively.
Conflicts:
src/Standard/Standard_Macro.hxx
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Wed Jun 17 06:52:06 2015 +0300
Corrections
Author: abv
Date: Tue Jun 16 22:01:37 2015 +0300
Automatic upgrade by occt_upgrade . -handle
Author: abv
Date: Tue Jun 16 21:39:52 2015 +0300
Corrections in Handle
[revision removed]
Detailed log of new commits:
Author: abv
Date: Wed Jun 17 06:52:06 2015 +0300
Corrections
Author: abv
Date: Tue Jun 16 22:01:37 2015 +0300
Automatic upgrade by occt_upgrade . -handle
Author: abv
Date: Tue Jun 16 21:39:52 2015 +0300
Corrections in Handle
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Mon Jun 22 07:02:42 2015 +0300
Corrections in TKMath
Author: abv
Date: Sat Jun 20 20:30:22 2015 +0300
TKernel made compilable
[revision removed]
Detailed log of new commits:
Author: abv
Date: Mon Jun 22 07:02:42 2015 +0300
Corrections in TKMath
Author: abv
Date: Sat Jun 20 20:30:22 2015 +0300
TKernel made compilable
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Mon Jun 22 19:26:57 2015 +0300
Added missing header
Author: abv
Date: Mon Jun 22 18:31:16 2015 +0300
Conversion of handle to const & to another handle restricted to compatible types only; constructor from other handle and method reset() added; some ambiguities resolved
Author: abv
Date: Mon Jun 22 18:29:59 2015 +0300
Clean-up of poor code in Modeling Data exhibited due to templated handle
Author: abv
Date: Mon Jun 22 11:51:55 2015 +0300
HashCode() added for Handle
[revision removed]
Detailed log of new commits:
Author: abv
Date: Mon Jun 22 19:26:57 2015 +0300
Added missing header
Author: abv
Date: Mon Jun 22 18:31:16 2015 +0300
Conversion of handle to const & to another handle restricted to compatible types only; constructor from other handle and method reset() added; some ambiguities resolved
Author: abv
Date: Mon Jun 22 18:29:59 2015 +0300
Clean-up of poor code in Modeling Data exhibited due to templated handle
Author: abv
Date: Mon Jun 22 11:51:55 2015 +0300
HashCode() added for Handle
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Wed Jun 24 19:50:01 2015 +0300
Next pack of code corrections...
Author: Commenter 5
Date: Thu Apr 24 10:57:26 2014 +0400
0024870: Provide OCCT RTTI test cases
Test commands for checking performance and functionality of OCCT handles and RTTI added.
New test case added for that: test perf fclasses handle
Author: abv
Date: Tue Jun 23 20:19:45 2015 +0300
Forgotten changes in headers
Author: abv
Date: Tue Jun 23 19:30:05 2015 +0300
Casting constructor of handle is made conditional (only for compatible types); operator casting to const reference to handle to base type is disabled for MSVC below below v12
Author: abv
Date: Tue Jun 23 19:28:12 2015 +0300
Updates of rest of MOA and part of OCAF
Author: abv
Date: Tue Jun 23 15:17:49 2015 +0300
Corrections in Handle and Standard_Persistent
Author: abv
Date: Tue Jun 23 14:47:23 2015 +0300
Code adaptation for new Handle
Adaptor3d_CurveOnSurface: added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface
BOPAlgo, BOOPDS_DS, GeomInt, IntPatch, IntTools, BRepMAT2d, MAT2d, ShapeCustom: handle argument passed by reference made const
BRepGProps, Law: removed typedefs that used Handle macro to define class name
BRepMesh, ShapeFix: Includes of headers "Handle_...hxx" are removed
IntPatch: direct cast of reference to handle replaced by DownCast()
MAT, CDM: use This() method to initialize handle to class instance from within its const methods
ShapeAnalysis: switch to use of remaining Append() method for sequences
Missing headers added; wrong use of macro Handle() corrected.
Code corrected to avoid ambiguous situations due to changed implementation of Handle.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Wed Jun 24 19:50:01 2015 +0300
Next pack of code corrections...
Author: Commenter 5
Date: Thu Apr 24 10:57:26 2014 +0400
0024870: Provide OCCT RTTI test cases
Test commands for checking performance and functionality of OCCT handles and RTTI added.
New test case added for that: test perf fclasses handle
Author: abv
Date: Tue Jun 23 20:19:45 2015 +0300
Forgotten changes in headers
Author: abv
Date: Tue Jun 23 19:30:05 2015 +0300
Casting constructor of handle is made conditional (only for compatible types); operator casting to const reference to handle to base type is disabled for MSVC below below v12
Author: abv
Date: Tue Jun 23 19:28:12 2015 +0300
Updates of rest of MOA and part of OCAF
Author: abv
Date: Tue Jun 23 15:17:49 2015 +0300
Corrections in Handle and Standard_Persistent
Author: abv
Date: Tue Jun 23 14:47:23 2015 +0300
Code adaptation for new Handle
Adaptor3d_CurveOnSurface: added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface
BOPAlgo, BOOPDS_DS, GeomInt, IntPatch, IntTools, BRepMAT2d, MAT2d, ShapeCustom: handle argument passed by reference made const
BRepGProps, Law: removed typedefs that used Handle macro to define class name
BRepMesh, ShapeFix: Includes of headers "Handle_...hxx" are removed
IntPatch: direct cast of reference to handle replaced by DownCast()
MAT, CDM: use This() method to initialize handle to class instance from within its const methods
ShapeAnalysis: switch to use of remaining Append() method for sequences
Missing headers added; wrong use of macro Handle() corrected.
Code corrected to avoid ambiguous situations due to changed implementation of Handle.
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Thu Jun 25 00:47:17 2015 +0300
0024023: Revamp the OCCT Handle - Nullify
Assignment of handle to NULL replaced by call to method Nullify()
Author: abv
Date: Thu Jun 25 01:06:37 2015 +0300
0024023: Revamp the OCCT Handle - unsorted
Author: abv
Date: Thu Jun 25 00:45:56 2015 +0300
0024023: Revamp the OCCT Handle - cast
Code corrected to eliminate passing object to function as non-const reference to handle of the base type.
DownCast is used instead of C-style cast to handle to derived type.
Author: abv
Date: Thu Jun 25 00:37:41 2015 +0300
0024023: Revamp the OCCT Handle - this
Construction of handle from const pointer to class corrected to be explicit
Author: abv
Date: Wed Jun 24 23:40:44 2015 +0300
0024023: Revamp the OCCT Handle - ambiguity
Code corrected to avoid ambiguous situations due to changed implementation of Handle.
In Adaptor3d_CurveOnSurface added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface, replacing by single call.
In NCollection_DefineHSequence.hxx, method Append() from another HSequence is removed; Append() from Sequence is used instead.
Author: abv
Date: Thu Jun 25 00:39:28 2015 +0300
0024023: Revamp the OCCT Handle - GC
Implementation of operator of type casting to resulting object simplified in classes of GC and GCE2d packages
Author: abv
Date: Thu Jun 25 00:31:05 2015 +0300
0024023: Revamp the OCCT Handle - general
Missing headers added; includes of headers "Handle_...hxx" removed.
Misuses of macro Handle() and its use in typedefs corrected.
Alias classes Profile and Option are removed from IFSelect; ones defined in MoniTool are used directly.
Author: abv
Date: Tue Jun 16 22:01:37 2015 +0300
Automatic upgrade by occt_upgrade . -handle
Author: abv
Date: Wed Jun 24 22:44:25 2015 +0300
0024023: Revamp the OCCT Handle
Macro defining Handle class is replaced by template class implementing the same concept (defined in Standard_Handle.hxx and Standard_Transient.hxx), opencascade::handle<>.
Header file Standard_DefineHandle.hxx becomes deprecated: the only useful macro DEFINE_STANDARD_RTTI is defined now in Standard_Type.hxx. Standard_DefineHandle.hxx is kept for compatibility, it defines macros previously used for definition of Handles and RTTI as empty. Macro DEFINE_STANDARD_HANDLE(C1,C2) defining typedef "Handle_C1" to corresponding handle class is also kept for compatibility.
Definitions of macro Handle() and STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_Handle.hxx (new file) and Standard_Type.hxx, respectively.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Thu Jun 25 00:47:17 2015 +0300
0024023: Revamp the OCCT Handle - Nullify
Assignment of handle to NULL replaced by call to method Nullify()
Author: abv
Date: Thu Jun 25 01:06:37 2015 +0300
0024023: Revamp the OCCT Handle - unsorted
Author: abv
Date: Thu Jun 25 00:45:56 2015 +0300
0024023: Revamp the OCCT Handle - cast
Code corrected to eliminate passing object to function as non-const reference to handle of the base type.
DownCast is used instead of C-style cast to handle to derived type.
Author: abv
Date: Thu Jun 25 00:37:41 2015 +0300
0024023: Revamp the OCCT Handle - this
Construction of handle from const pointer to class corrected to be explicit
Author: abv
Date: Wed Jun 24 23:40:44 2015 +0300
0024023: Revamp the OCCT Handle - ambiguity
Code corrected to avoid ambiguous situations due to changed implementation of Handle.
In Adaptor3d_CurveOnSurface added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface, replacing by single call.
In NCollection_DefineHSequence.hxx, method Append() from another HSequence is removed; Append() from Sequence is used instead.
Author: abv
Date: Thu Jun 25 00:39:28 2015 +0300
0024023: Revamp the OCCT Handle - GC
Implementation of operator of type casting to resulting object simplified in classes of GC and GCE2d packages
Author: abv
Date: Thu Jun 25 00:31:05 2015 +0300
0024023: Revamp the OCCT Handle - general
Missing headers added; includes of headers "Handle_...hxx" removed.
Misuses of macro Handle() and its use in typedefs corrected.
Alias classes Profile and Option are removed from IFSelect; ones defined in MoniTool are used directly.
Author: abv
Date: Tue Jun 16 22:01:37 2015 +0300
Automatic upgrade by occt_upgrade . -handle
Author: abv
Date: Wed Jun 24 22:44:25 2015 +0300
0024023: Revamp the OCCT Handle
Macro defining Handle class is replaced by template class implementing the same concept (defined in Standard_Handle.hxx and Standard_Transient.hxx), opencascade::handle<>.
Header file Standard_DefineHandle.hxx becomes deprecated: the only useful macro DEFINE_STANDARD_RTTI is defined now in Standard_Type.hxx. Standard_DefineHandle.hxx is kept for compatibility, it defines macros previously used for definition of Handles and RTTI as empty. Macro DEFINE_STANDARD_HANDLE(C1,C2) defining typedef "Handle_C1" to corresponding handle class is also kept for compatibility.
Definitions of macro Handle() and STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_Handle.hxx (new file) and Standard_Type.hxx, respectively.
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Thu Jun 25 18:06:00 2015 +0300
Added possibility to define maps manipulated by handle, via macro DEFINE_HMAP defined in NCollection_DefineHMap.hxx
This is applied in visualization to use normal handles instead of NCollection_Handle<>
Author: abv
Date: Thu Jun 25 17:14:41 2015 +0300
0024023: Revamp the OCCT Handle - general 3
Separate header files defining Handle classes removed (except Image_PixMap_Handle.hxx)
Author: abv
Date: Thu Jun 25 14:58:31 2015 +0300
0024023: Revamp the OCCT Handle - ambiguity 2
Ambiguities resolved
Second argument made non-default in method IGESData_IGESWriter::Send() having entity argument to force flag to be always passed explicitly
Author: abv
Date: Thu Jun 25 14:44:11 2015 +0300
0024023: Revamp the OCCT Handle - general 2
Missing headers added
Author: abv
Date: Thu Jun 25 14:39:10 2015 +0300
Added DownCast(ptr)
[revision removed]
Detailed log of new commits:
Author: abv
Date: Thu Jun 25 18:06:00 2015 +0300
Added possibility to define maps manipulated by handle, via macro DEFINE_HMAP defined in NCollection_DefineHMap.hxx
This is applied in visualization to use normal handles instead of NCollection_Handle<>
Author: abv
Date: Thu Jun 25 17:14:41 2015 +0300
0024023: Revamp the OCCT Handle - general 3
Separate header files defining Handle classes removed (except Image_PixMap_Handle.hxx)
Author: abv
Date: Thu Jun 25 14:58:31 2015 +0300
0024023: Revamp the OCCT Handle - ambiguity 2
Ambiguities resolved
Second argument made non-default in method IGESData_IGESWriter::Send() having entity argument to force flag to be always passed explicitly
Author: abv
Date: Thu Jun 25 14:44:11 2015 +0300
0024023: Revamp the OCCT Handle - general 2
Missing headers added
Author: abv
Date: Thu Jun 25 14:39:10 2015 +0300
Added DownCast(ptr)
Branch [archived branch] has been updated by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Fri Jun 26 06:32:08 2015 +0300
HashCode() for Standard_Transient*
Author: abv
Date: Fri Jun 26 06:31:41 2015 +0300
Further adaptations
[revision removed]
Detailed log of new commits:
Author: abv
Date: Fri Jun 26 06:32:08 2015 +0300
HashCode() for Standard_Transient*
Author: abv
Date: Fri Jun 26 06:31:41 2015 +0300
Further adaptations
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Fri Jun 26 18:20:13 2015 +0300
0024023: Revamp the OCCT Handle -- ambiguity
Code corrected to avoid ambiguous situations due to changed implementation of Handle (overloaded methods accepting handles of different types).
In Adaptor3d_CurveOnSurface added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface, replacing by single call.
In NCollection_DefineHSequence.hxx, method Append() with handle to another HSequence as argument is removed; Append() from Sequence is used instead.
Second argument made non-default in method IGESData_IGESWriter::Send() with entity argument, to force flag to be always passed explicitly.
In DrawTrSurf and IGESData_IGESWriter, template variants of methods Set() and Send(), respectively, are added to avoid ambiguity when these methods are called with handles to derived types (using SFINAE).
Author: abv
Date: Fri Jun 26 12:23:30 2015 +0300
0024023: Revamp the OCCT Handle -- plugin
Definition of PLUGINFACTORY function changed to return Standard_Transient* instead of Handle(Standard_Transient), which cannot be returned by C-style function.
Default implementation of PLUGINFACTORY() instantiated by macro PLUGIN() now keeps static instance of the factory object, initialized once (at the first call).
Author: abv
Date: Thu Jun 25 00:39:28 2015 +0300
0024023: Revamp the OCCT Handle -- GC
Implementation of operator of type casting to resulting object simplified in classes of GC and GCE2d packages
Author: abv
Date: Fri Jun 26 18:17:15 2015 +0300
0024023: Revamp the OCCT Handle -- downcast
C-style cast of Handle to that of derived type (now illegal) is replaced by call to DownCast()
Author: abv
Date: Fri Jun 26 18:17:07 2015 +0300
0024023: Revamp the OCCT Handle -- general
Missing headers added; includes of headers "Handle_...hxx" removed.
Misuses of macro Handle() and its use in typedefs corrected.
Alias classes Profile and Option are removed from IFSelect; ones defined in MoniTool are used directly.
Removed header files defining only Handle classes (except Image_PixMap_Handle.hxx)
Classes SelectMgr_BaseFrustum and now inherit Standard_Transient and can be manipulated by Handle (not NCollection_Handle)
Author: abv
Date: Tue Jun 16 22:01:37 2015 +0300
Automatic upgrade by occt_upgrade . -handle
Author: abv
Date: Wed Jun 24 22:44:25 2015 +0300
0024023: Revamp the OCCT Handle -- handle
Macro defining Handle class is replaced by template class implementing the same concept (defined in Standard_Handle.hxx and Standard_Transient.hxx), opencascade::handle<>.
Header file Standard_DefineHandle.hxx becomes deprecated: the only useful macro DEFINE_STANDARD_RTTI is defined now in Standard_Type.hxx. Standard_DefineHandle.hxx is kept for compatibility, it defines macros previously used for definition of Handles and RTTI as empty. Macro DEFINE_STANDARD_HANDLE(C1,C2) is also kept for compatibility; now it expands to typedef "Handle_C1" to corresponding handle class.
Definitions of macro Handle() and STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_Handle.hxx (new file) and Standard_Type.hxx, respectively.
New template class NCollection_Shared added, allowing to define sub-class manipulated by handle, for any non-transient class.
[revision removed]
Detailed log of new commits:
Author: abv
Date: Fri Jun 26 18:20:13 2015 +0300
0024023: Revamp the OCCT Handle -- ambiguity
Code corrected to avoid ambiguous situations due to changed implementation of Handle (overloaded methods accepting handles of different types).
In Adaptor3d_CurveOnSurface added method Load() with two parameters, allowing to avoid ambiguity of cast of handles when calling separate methods Load() for curve and surface, replacing by single call.
In NCollection_DefineHSequence.hxx, method Append() with handle to another HSequence as argument is removed; Append() from Sequence is used instead.
Second argument made non-default in method IGESData_IGESWriter::Send() with entity argument, to force flag to be always passed explicitly.
In DrawTrSurf and IGESData_IGESWriter, template variants of methods Set() and Send(), respectively, are added to avoid ambiguity when these methods are called with handles to derived types (using SFINAE).
Author: abv
Date: Fri Jun 26 12:23:30 2015 +0300
0024023: Revamp the OCCT Handle -- plugin
Definition of PLUGINFACTORY function changed to return Standard_Transient* instead of Handle(Standard_Transient), which cannot be returned by C-style function.
Default implementation of PLUGINFACTORY() instantiated by macro PLUGIN() now keeps static instance of the factory object, initialized once (at the first call).
Author: abv
Date: Thu Jun 25 00:39:28 2015 +0300
0024023: Revamp the OCCT Handle -- GC
Implementation of operator of type casting to resulting object simplified in classes of GC and GCE2d packages
Author: abv
Date: Fri Jun 26 18:17:15 2015 +0300
0024023: Revamp the OCCT Handle -- downcast
C-style cast of Handle to that of derived type (now illegal) is replaced by call to DownCast()
Author: abv
Date: Fri Jun 26 18:17:07 2015 +0300
0024023: Revamp the OCCT Handle -- general
Missing headers added; includes of headers "Handle_...hxx" removed.
Misuses of macro Handle() and its use in typedefs corrected.
Alias classes Profile and Option are removed from IFSelect; ones defined in MoniTool are used directly.
Removed header files defining only Handle classes (except Image_PixMap_Handle.hxx)
Classes SelectMgr_BaseFrustum and now inherit Standard_Transient and can be manipulated by Handle (not NCollection_Handle)
Author: abv
Date: Tue Jun 16 22:01:37 2015 +0300
Automatic upgrade by occt_upgrade . -handle
Author: abv
Date: Wed Jun 24 22:44:25 2015 +0300
0024023: Revamp the OCCT Handle -- handle
Macro defining Handle class is replaced by template class implementing the same concept (defined in Standard_Handle.hxx and Standard_Transient.hxx), opencascade::handle<>.
Header file Standard_DefineHandle.hxx becomes deprecated: the only useful macro DEFINE_STANDARD_RTTI is defined now in Standard_Type.hxx. Standard_DefineHandle.hxx is kept for compatibility, it defines macros previously used for definition of Handles and RTTI as empty. Macro DEFINE_STANDARD_HANDLE(C1,C2) is also kept for compatibility; now it expands to typedef "Handle_C1" to corresponding handle class.
Definitions of macro Handle() and STANDARD_TYPE() moved from Standard_Macro.hxx to Standard_Handle.hxx (new file) and Standard_Type.hxx, respectively.
New template class NCollection_Shared added, allowing to define sub-class manipulated by handle, for any non-transient class.
Branch CR24023_6 contains first working version of the new templated handles, see details in commit messages above. This version is minimalistic in terms of efforts needed to port dependent code, yet these efforts are quite considerable. Porting notes are to come...
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Related records
- #0024805 · parent of · closedEliminate unused static functions and methods: ShallowDump(), ShallowCopy(), STANDARD_TYPE(...)
- #0024806 · parent of · closedExtend macro DEFINE_STANDARD_RTTI by additional argument specifying base class
- #0024814 · parent of · closedAvoid using explicit names of Handle classes
- #0026373 · parent of · newMerge NCollection_Handle with opencascade::handle
- #0024947 · parent of · closedRedesign OCCT legacy type system
- #0029961 · parent of · closedFoundation Classes - NCollection_Shared constructor passes arguments by copy
- #0024870 · related to · closedProvide OCCT RTTI test cases
- #0026377 · related to · closedPassing Handle objects as arguments to functions as non-const reference to base type is dangerous
- #0026457 · related to · closedFailed build with OCCT_DEBUG enabled
- #0024895 · related to · closed'PLUGINFACTORY' has C-linkage specified, but returns user-defined type 'Handle_Standard_Transient' which is incompatible with C
- #0026497 · related to · closedRestore explicit hierarchy of handles
- #0026549 · related to · closedProvide move constructors and operators for basic classes
- #0027104 · related to · closedDownCast() cannot return null for mismatched handle
- #0027111 · related to · closedAdd generalized copy constructor in handle class for old compilers
- #0027563 · related to · closedFoundation Classes, opencascade::handle - make operator*() consistent with operator->()
- #0025620 · related to · closedCAST analysis: Avoid public or missing copy assignment operator in abstract classes
- #0024002 · child of · closedOverall code and build procedure refactoring