0028225: MFC sample on OCAF uses old-style definition of a Handle-class
[occt.git] / samples / mfc / standard / 06_Ocaf / src / TOcafFunction_BoxDriver.cxx
index 8747d94..40979bf 100755 (executable)
@@ -12,6 +12,8 @@
 #include "BRepPrimAPI_MakeBox.hxx"
 #include "TNaming_Builder.hxx"
 
+IMPLEMENT_STANDARD_RTTIEXT (TOcafFunction_BoxDriver, TFunction_Driver)
+
 //=======================================================================
 //function : GetID
 //purpose  :
@@ -37,10 +39,10 @@ TOcafFunction_BoxDriver::TOcafFunction_BoxDriver()
 //purpose  : Validation of the object label, its arguments and its results.
 //=======================================================================
 
-void TOcafFunction_BoxDriver::Validate(TFunction_Logbook& log) const
+void TOcafFunction_BoxDriver::Validate(Handle(TFunction_Logbook)& log) const
 {
   // We validate the object label ( Label() ), all the arguments and the results of the object:
-  log.SetValid(Label(), Standard_True);
+  log->SetValid(Label(), Standard_True);
 }
 
 //=======================================================================
@@ -49,10 +51,10 @@ void TOcafFunction_BoxDriver::Validate(TFunction_Logbook& log) const
 //         : be invoked. If the object label or an argument is modified,
 //         : we must recompute the object - to call the method Execute().
 //=======================================================================
-Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const TFunction_Logbook& log) const
+Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const Handle(TFunction_Logbook)& log) const
 {
        // If the object's label is modified:
-  if (log.IsModified(Label())) return Standard_True; 
+  if (log->IsModified(Label())) return Standard_True; 
 
   // Cut (in our simple case) has two arguments: The original shape, and the tool shape.
   // They are on the child labels of the box's label:
@@ -60,12 +62,12 @@ Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const TFunction_Logbook& l
   //     ToolNShape - is attached to the second child label.
   // 
   // Let's check them:
-  if (log.IsModified(Label().FindChild(1))) return Standard_True; // width.
-  if (log.IsModified(Label().FindChild(2))) return Standard_True; // length,
-  if (log.IsModified(Label().FindChild(3))) return Standard_True; // width.
-  if (log.IsModified(Label().FindChild(4))) return Standard_True; // length,
-  if (log.IsModified(Label().FindChild(5))) return Standard_True; // width.
-  if (log.IsModified(Label().FindChild(6))) return Standard_True; // length,
+  if (log->IsModified(Label().FindChild(1))) return Standard_True; // width.
+  if (log->IsModified(Label().FindChild(2))) return Standard_True; // length,
+  if (log->IsModified(Label().FindChild(3))) return Standard_True; // width.
+  if (log->IsModified(Label().FindChild(4))) return Standard_True; // length,
+  if (log->IsModified(Label().FindChild(5))) return Standard_True; // width.
+  if (log->IsModified(Label().FindChild(6))) return Standard_True; // length,
   
  // if there are no any modifications concerned the box,
   // it's not necessary to recompute (to call the method Execute()):
@@ -83,7 +85,7 @@ Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const TFunction_Logbook& l
 //         : if there are no any mistakes occurred we return 0:
 //         : 0 - no mistakes were found.
 //=======================================================================
-Standard_Integer TOcafFunction_BoxDriver::Execute(TFunction_Logbook& /*log*/) const
+Standard_Integer TOcafFunction_BoxDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const
 {
        // Get the values of dimension and position attributes 
        Handle(TDataStd_Real) TSR;
@@ -118,57 +120,3 @@ Standard_Integer TOcafFunction_BoxDriver::Execute(TFunction_Logbook& /*log*/) co
   // If there are no any mistakes we return 0:
   return 0;
 }
-
-TOcafFunction_BoxDriver::~TOcafFunction_BoxDriver() {}
-
-
-Standard_EXPORT Handle_Standard_Type& TOcafFunction_BoxDriver_Type_()
-{
-
-    static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
-  if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
-  static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
-  if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
-  static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
-  if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
-
-  static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
-  static Handle_Standard_Type _aType = new Standard_Type("TOcafFunction_BoxDriver",
-                                                        sizeof(TOcafFunction_BoxDriver),
-                                                        1,
-                                                        (Standard_Address)_Ancestors,
-                                                        (Standard_Address)NULL);
-
-  return _aType;
-}
-
-
-// DownCast method
-//   allow safe downcasting
-//
-const Handle(TOcafFunction_BoxDriver) Handle(TOcafFunction_BoxDriver)::DownCast(const Handle(Standard_Transient)& AnObject) 
-{
-  Handle(TOcafFunction_BoxDriver) _anOtherObject;
-
-  if (!AnObject.IsNull()) {
-     if (AnObject->IsKind(STANDARD_TYPE(TOcafFunction_BoxDriver))) {
-       _anOtherObject = Handle(TOcafFunction_BoxDriver)((Handle(TOcafFunction_BoxDriver)&)AnObject);
-     }
-  }
-
-  return _anOtherObject ;
-}
-const Handle(Standard_Type)& TOcafFunction_BoxDriver::DynamicType() const 
-{ 
-  return STANDARD_TYPE(TOcafFunction_BoxDriver) ; 
-}
-Standard_Boolean TOcafFunction_BoxDriver::IsKind(const Handle(Standard_Type)& AType) const 
-{ 
-  return (STANDARD_TYPE(TOcafFunction_BoxDriver) == AType || TFunction_Driver::IsKind(AType)); 
-}
-
-Handle_TOcafFunction_BoxDriver::~Handle_TOcafFunction_BoxDriver() {}
-
-