MantisBT - Open CASCADE
View Issue Details
0026397Open CASCADE[OCCT] OCCT:Foundation Classespublic2015-07-03 10:372020-09-11 16:13
[OCCT] 7.6.0* 
Not required
0026397: Change method DownCast() of Handle to return a pointer rather than a Handle
Method DownCast() of opencascade::handle<> can be changed to return a pointer instead of constructing a new handle. The benefits would be:

- No overhead for incrementing / decrementing reference counter if result of DownCast() is used to access the object directly

- Possible more efficient code when new Handle() is initialized by result of DownCast()

- Safer code -- compiler may complain if result of DownCast() is assigned to reference to a handle

- Possibility to avoid double type checking in expressions like this:

if (myCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))
  Handle(Geom_BSplineCurve) aBSplCurve = Handle(Geom_BSplineCurve)::DownCast (myCurve);
  ... // work with bspline

this can be replaced by more compact and faster variant:

if (const Geom_BSplineCurve* aBSplCurve = Handle(Geom_BSplineCurve)::DownCast (myCurve))
  ... // work with bspline

One drawback of returning a pointer is that it will break compatibility with existing code which now can use method IsNull() to the result of DownCast() to check if the value is of a goo type. Such checks however should be better replaced by equivalent check of IsNull() of original object followed by IsKind().
No tags attached.
Issue History
2015-07-03 10:37abvNew Issue
2015-07-03 10:37abvAssigned To => abv
2015-12-14 22:39abvTarget Version7.0.0 => 7.1.0
2016-11-03 17:13abvTarget Version7.1.0 => 7.2.0
2017-07-27 09:43abvTarget Version7.2.0 => 7.4.0
2017-08-14 11:14apvTest case number => Not required
2017-10-09 13:39abvDescription Updatedbug_revision_view_page.php?rev_id=17858#r17858
2019-07-10 22:29abvTarget Version7.4.0 => 7.5.0
2020-09-11 16:13utverdovTarget Version7.5.0 => 7.6.0*

There are no notes attached to this issue.