1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
mpv c99ad5d760 0030773: Application Framework - To allow to inherit existing attributes to reuse persistence mechanisms
Added possibility to inherit existing attributes if the same persistent fields are used. All methods that allow controlling the data model changes or getting some callbacks may be overridden in successor. They may have same GUIDs as a base class or new ones.

Special macros IMPLEMENT_DERIVED_ATTRIBUTE and IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE must be used instead of standard Handle macro definition IMPLEMENT_STANDARD_RTTIEXT to register new derived attributes.

Using this improvement several existing attributes from TDataStd, TDataXtd and XCAFDoc packages become inherited from other base attribute-classes. XML and Bin drivers of these attributes are removed. New base attribute classes are added: TDataStd_GenericEmpty and TDataStd_GenericExtString.

This improvement does not change both present formats Bin and XML documents. The obsolete Standard scheme is not changed at all.
2020-09-12 20:42:18 +03:00

71 lines
1.6 KiB
Plaintext

#INTERFACE CAF
# Basic attributes
#
# Testing attributes: TDataStd_Tick TDataStd_Directory TDataStd_NoteBook TDataXtd_Axis TDataXtd_Placement TDataXtd_Plane TDataXtd_Point TDataXtd_Shape
#
# Testing command: SetEmptyAttribute
# XmlOcaf format open/save with these attributes
NewDocument DX XmlOcaf
UndoLimit DX 2
Label DX 0:2
set IsGood 1
NewCommand DX
SetEmptyAttribute DX 0:2 TDataXtd_Axis
SetEmptyAttribute DX 0:2 TDataXtd_Placement
SetEmptyAttribute DX 0:2 TDataXtd_Plane
SetEmptyAttribute DX 0:2 TDataXtd_Point
SetEmptyAttribute DX 0:2 TDataXtd_Shape
SetEmptyAttribute DX 0:2 TDataStd_Tick
SetEmptyAttribute DX 0:2 TDataStd_Directory
SetEmptyAttribute DX 0:2 TDataStd_NoteBook
CommitCommand DX
set aLen1 [llength [Attributes DX 0:2]]
if { ${aLen1} != 8 } {
set IsGood 0
puts "Not all attributes were added aLen1=${aLen1}"
}
Undo DX
set aLen2 [llength [Attributes DX 0:2]]
if { ${aLen2} != 0 } {
set IsGood 0
puts "Not all attributes were removed on Undo aLen2=${aLen2}"
}
Redo DX
set aLen3 [llength [Attributes DX 0:2]]
if { ${aLen3} != 8 } {
set IsGood 0
puts "Not all attributes were restored by Redo aLen3=${aLen3}"
}
set aFile ${imagedir}/caf001-F5.xml
file delete ${aFile}
SaveAs DX ${aFile}
if { ![file exists ${aFile}] } {
puts "There is not ${aFile} file; SaveAs command: Error"
return
}
Close DX
Open ${aFile} DDX
set aLen4 [llength [Attributes DDX 0:2]]
if { ${aLen4} != 8 } {
set IsGood 0
puts "Not all attributes were restored on Open aLen4=${aLen4}"
}
if { ${IsGood} == 0} {
puts "Set empty attributes: Error"
} else {
puts "Set empty attributes: OK"
}