View Issue Details

IDProjectCategoryView StatusLast Update
0026397Open CASCADEOCCT:Foundation Classespublic2023-08-01 15:08
ReporterabvAssigned Toabv 
PrioritynormalSeverityminor 
Status newResolutionopen 
Target VersionUnscheduled 
Summary0026397: Change method DownCast() of Handle to return a pointer rather than a Handle
DescriptionMethod 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().
TagsNo tags attached.
Test case numberNot required

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2015-07-03 10:37 abv New Issue
2015-07-03 10:37 abv Assigned To => abv
2015-12-14 22:39 abv Target Version 7.0.0 => 7.1.0
2016-11-03 17:13 abv Target Version 7.1.0 => 7.2.0
2017-07-27 09:43 abv Target Version 7.2.0 => 7.4.0
2017-08-14 11:14 apv Test case number => Not required
2017-10-09 13:39 abv Description Updated
2019-07-10 22:29 abv Target Version 7.4.0 => 7.5.0
2020-09-11 16:13 utverdov Target Version 7.5.0 => 7.6.0
2021-09-09 23:08 kgv Target Version 7.6.0 => 7.7.0
2022-10-24 10:40 szy Target Version 7.7.0 => 7.8.0
2023-08-01 15:08 dpasukhi Target Version 7.8.0 => Unscheduled