//function : TDataStd_AsciiString
//purpose :
//=======================================================================
-TDataStd_AsciiString::TDataStd_AsciiString():
- myID (GetID())
+TDataStd_AsciiString::TDataStd_AsciiString()
{
myString.Clear();
}
return myID;
}
+//=======================================================================
+//function : SetAttr
+//purpose : Implements Set functionality
+//=======================================================================
+static Handle(TDataStd_AsciiString) SetAttr(
+ const TDF_Label& label,
+ const TCollection_AsciiString& theString,
+ const Standard_GUID& theGuid)
+{
+ Handle(TDataStd_AsciiString) A;
+ if (!label.FindAttribute(theGuid, A)) {
+ A = new TDataStd_AsciiString ();
+ A->SetID(theGuid);
+ label.AddAttribute(A);
+ }
+ A->Set (theString);
+ return A;
+}
+
//=======================================================================
//function : Set
//purpose :
const TDF_Label& theLabel,
const TCollection_AsciiString& theAsciiString)
{
- Handle(TDataStd_AsciiString) A;
- if (!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), A))
- {
- A = new TDataStd_AsciiString;
- A->SetID(GetID());
- theLabel.AddAttribute(A);
- }
- A->Set(theAsciiString);
- return A;
+ return SetAttr(theLabel, theAsciiString, GetID());
}
//=======================================================================
//purpose : Set user defined attribute
//=======================================================================
-Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (const TDF_Label& L, const Standard_GUID& theGuid,
- const TCollection_AsciiString& theAsciiString)
+Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
+ const TDF_Label& theLabel,
+ const Standard_GUID& theGuid,
+ const TCollection_AsciiString& theAsciiString)
{
- Handle(TDataStd_AsciiString) A;
- if (!L.FindAttribute(theGuid, A)) {
- A = new TDataStd_AsciiString ();
- A->SetID(theGuid);
- L.AddAttribute(A);
- }
- A->Set (theAsciiString);
- return A;
+ return SetAttr(theLabel, theAsciiString, theGuid);
}
//=======================================================================
//function : Set
Handle(TDF_Attribute) TDataStd_AsciiString::NewEmpty () const
{
- Handle(TDataStd_AsciiString) Att = new TDataStd_AsciiString();
- Att->SetID(myID);
- return Att;
+ return new TDataStd_AsciiString();
}
//=======================================================================
return TDataStd_IntegerID;
}
+//=======================================================================
+//function : SetAttr
+//purpose : Implements Set functionality
+//=======================================================================
+static Handle(TDataStd_Integer) SetAttr(const TDF_Label& label,
+ const Standard_Integer V,
+ const Standard_GUID& theGuid)
+{
+ Handle(TDataStd_Integer) A;
+ if (!label.FindAttribute(theGuid, A)) {
+ A = new TDataStd_Integer ();
+ A->SetID(theGuid);
+ label.AddAttribute(A);
+ }
+ A->Set (V);
+ return A;
+}
//=======================================================================
//function : Set
const Standard_Integer V)
{
- Handle(TDataStd_Integer) A;
- if (!L.FindAttribute (TDataStd_Integer::GetID(), A)) {
- A = new TDataStd_Integer ();
- A->SetID(GetID());
- L.AddAttribute(A);
- }
- A->Set (V);
- return A;
+ return SetAttr(L, V, GetID());
}
//=======================================================================
//purpose : Set user defined attribute
//=======================================================================
-Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L, const Standard_GUID& theGuid,
- const Standard_Integer V)
+Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L,
+ const Standard_GUID& theGuid,
+ const Standard_Integer V)
{
- Handle(TDataStd_Integer) A;
- if (!L.FindAttribute(theGuid, A)) {
- A = new TDataStd_Integer ();
- A->SetID(theGuid);
- L.AddAttribute(A);
- }
- A->Set (V);
- return A;
+ return SetAttr(L, V, theGuid);
}
//=======================================================================
//function : TDataStd_Integer
//=======================================================================
TDataStd_Integer::TDataStd_Integer ()
- : myValue (-1), myID (GetID())
+ : myValue (-1)
{ }
//=======================================================================
Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const
-{
- Handle(TDataStd_Integer) Att = new TDataStd_Integer();
- Att->SetID(myID);
- return Att;
+{
+ return new TDataStd_Integer();
}
//=======================================================================
return TDataStd_NameID;
}
+//=======================================================================
+//function : SetAttr
+//purpose : Implements Set functionality
+//=======================================================================
+static Handle(TDataStd_Name) SetAttr(const TDF_Label& label,
+ const TCollection_ExtendedString& theString,
+ const Standard_GUID& theGuid)
+{
+ Handle(TDataStd_Name) N;
+ if (!label.FindAttribute(theGuid, N)) {
+ N = new TDataStd_Name ();
+ N->SetID(theGuid);
+ label.AddAttribute(N);
+ }
+ N->Set (theString);
+ return N;
+}
+
//=======================================================================
//function : Set
//purpose :
(const TDF_Label& label,
const TCollection_ExtendedString& theString)
{
- Handle(TDataStd_Name) N;
- if (!label.FindAttribute(TDataStd_Name::GetID(), N)) {
- N = new TDataStd_Name ();
- N->SetID(GetID());
- label.AddAttribute(N);
- }
- N->Set(theString);
- return N;
+ return SetAttr(label, theString, GetID());
}
//=======================================================================
//purpose : Set user defined attribute
//=======================================================================
-Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& L, const Standard_GUID& theGuid,
+Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& label,
+ const Standard_GUID& theGuid,
const TCollection_ExtendedString& theString)
{
- Handle(TDataStd_Name) N;
- if (!L.FindAttribute(theGuid, N)) {
- N = new TDataStd_Name ();
- N->SetID(theGuid);
- L.AddAttribute(N);
- }
- N->Set (theString);
- return N;
+ return SetAttr(label, theString, theGuid);
}
//=======================================================================
//function : TDataStd_Name
//purpose : Empty Constructor
//=======================================================================
-TDataStd_Name::TDataStd_Name (): myID (GetID())
-{ }
+TDataStd_Name::TDataStd_Name ()
+{}
//=======================================================================
//function : Set
//=======================================================================
Handle(TDF_Attribute) TDataStd_Name::NewEmpty () const
-{
- Handle(TDataStd_Name) Att = new TDataStd_Name();
- Att->SetID(myID);
- return Att;
+{
+ return new TDataStd_Name();
}
//=======================================================================
void TDataStd_Name::Paste (const Handle(TDF_Attribute)& into,
const Handle(TDF_RelocationTable)&/* RT*/) const
{
- Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (into);
- anAtt->Set (myString);
- anAtt->SetID(myID);
+ Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (into);
+ anAtt->Set (myString);
+ anAtt->SetID(myID);
}
//=======================================================================
return TDataStd_RealID;
}
+//=======================================================================
+//function : SetAttr
+//purpose : Implements Set functionality
+//=======================================================================
+static Handle(TDataStd_Real) SetAttr(const TDF_Label& label,
+ const Standard_Real V,
+ const Standard_GUID& theGuid)
+{
+ Handle(TDataStd_Real) A;
+ if (!label.FindAttribute(theGuid, A)) {
+ A = new TDataStd_Real ();
+ A->SetID(theGuid);
+ label.AddAttribute(A);
+ }
+ A->Set (V);
+ return A;
+}
//=======================================================================
//function : Set
Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
const Standard_Real V)
{
- Handle(TDataStd_Real) A;
- if (!L.FindAttribute(TDataStd_Real::GetID(), A)) {
- A = new TDataStd_Real ();
- A->SetID(GetID());
- L.AddAttribute(A);
- }
- A->Set (V);
- return A;
+ return SetAttr(L, V, GetID());
}
//=======================================================================
//purpose : User defined attribute
//=======================================================================
-Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L, const Standard_GUID& theGuid,
+Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
+ const Standard_GUID& theGuid,
const Standard_Real V)
{
- Handle(TDataStd_Real) A;
- if (!L.FindAttribute(theGuid, A)) {
- A = new TDataStd_Real ();
- A->SetID(theGuid);
- L.AddAttribute(A);
- }
- A->Set (V);
- return A;
+ return SetAttr(L, V, theGuid);
}
//=======================================================================
TDataStd_Real::TDataStd_Real ()
: myValue (RealFirst()),
- myDimension (TDataStd_SCALAR),
- myID (GetID())
+ myDimension (TDataStd_SCALAR)
{}
//=======================================================================
Handle(TDF_Attribute) TDataStd_Real::NewEmpty () const
-{
- Handle(TDataStd_Real) Att = new TDataStd_Real();
- Att->SetID(myID);
- return Att;
+{
+ return new TDataStd_Real();
}
//=======================================================================
--- /dev/null
+#INTERFACE CAF
+# Basic attributes
+#
+# Testing attribute: User defined (additional GUID) TDataStd_Integer
+#
+# Testing command: SetInteger
+# Testing command: GetInteger
+#
+
+puts "caf001-A6"
+
+# Add an attribute to a data framework
+set aSetAttr1 100
+set aSetAttr2 200
+set aGuid1 "12e94541-6dbc-11d4-b9c8-0060b0ee281b"
+
+set aLabel 0:2
+SetInteger D ${aLabel} ${aSetAttr1}
+SetInteger D ${aLabel} ${aSetAttr2} ${aGuid1}
+
+# Close/Open the transaction
+NewCommand D
+
+# Save the document
+set aFile ${imagedir}/caf001-A7.cbf
+file delete ${aFile}
+SaveAs D ${aFile}
+if { ![file exists ${aFile}] } {
+ puts "There is not ${aFile} file; SaveAs command: Error"
+ return
+}
+#catch {exec chmod 777 ${aFile}}
+
+# Restore the document
+Close D
+Open ${aFile} DD
+
+# Get a value of the attribute #1
+set IsDone [catch {set aGetAttr3 [GetInteger DD ${aLabel}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr1}!=${aGetAttr3} } {
+ puts ${aResult}
+ puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
+ puts "Get a value of the first TDataStd_Integer attribute from restoring document: Error"
+ return
+}
+
+# Get a value of the attribute #2
+set IsDone [catch {set aGetAttr4 [GetInteger DD ${aLabel} ${aGuid1}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr2}!=${aGetAttr4} } {
+ puts ${aResult}
+ puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
+ puts "Get a value of the second TDataStd_Integer attribute from restoring document: Error"
+ return
+}
+
+puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK"
--- /dev/null
+#INTERFACE CAF
+# Basic attributes
+#
+# Testing attribute: User defined (additional GUID) TDataStd_Real
+#
+# Testing command: SetReal
+# Testing command: GetReal
+#
+
+puts "caf001-B6"
+
+# Add an attribute to a data framework
+set aSetAttr1 100.11
+set aSetAttr2 200.11
+set aGuid2 "12e94552-6dbc-11d4-b9c8-0060b0ee281b"
+set aLabel 0:2
+SetReal D ${aLabel} ${aSetAttr1}
+SetReal D ${aLabel} ${aSetAttr2} ${aGuid2}
+
+# Close/Open the transaction
+NewCommand D
+
+# Save the document
+set aFile ${imagedir}/caf001-B7.cbf
+file delete ${aFile}
+SaveAs D ${aFile}
+if { ![file exists ${aFile}] } {
+ puts "There is not ${aFile} file; SaveAs command: Error"
+ return
+}
+#catch {exec chmod 777 ${aFile}}
+
+# Restore the document
+Close D
+Open ${aFile} DD
+
+# Get a value of the attribute #1
+set IsDone [catch {set aGetAttr3 [GetReal DD ${aLabel}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr1}!=${aGetAttr3} } {
+ puts ${aResult}
+ puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
+ puts "Get a value of the first TDataStd_Real attribute from restoring document: Error"
+ return
+}
+
+# Get a value of the attribute #2
+set IsDone [catch {set aGetAttr4 [GetReal DD ${aLabel} ${aGuid2}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr2}!=${aGetAttr4} } {
+ puts ${aResult}
+ puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
+ puts "Get a value of the second TDataStd_Real attribute from restoring document: Error"
+ return
+}
+
+puts "Get a value of user defined TDataStd_Integer attributes from restoring document: OK"
--- /dev/null
+#INTERFACE CAF
+# Basic attributes
+#
+# Testing attribute: User defined (additional GUID) TDataStd_Name
+#
+# Testing command: SetName
+# Testing command: GetName
+#
+
+puts "caf001-E6"
+
+# Add an attribute to a data framework
+set aSetAttr1 "New Attribute_1"
+set aSetAttr2 "New Attribute_2"
+set aGuid2 "12e94562-6dbc-11d4-b9c8-0060b0ee281b"
+set aLabel 0:2
+SetName D ${aLabel} ${aSetAttr1}
+SetName D ${aLabel} ${aSetAttr2} ${aGuid2}
+
+# Close/Open the transaction
+NewCommand D
+
+# Save the document
+set aFile ${imagedir}/caf001-E7.cbf
+file delete ${aFile}
+SaveAs D ${aFile}
+if { ![file exists ${aFile}] } {
+ puts "There is not ${aFile} file; SaveAs command: Error"
+ return
+}
+#catch {exec chmod 777 ${aFile}}
+
+# Restore the document
+Close D
+Open ${aFile} DD
+
+# Get a value of the attribute #1
+set IsDone [catch {set aGetAttr3 [GetName DD ${aLabel}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr1}!=${aGetAttr3} } {
+ puts ${aResult}
+ puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
+ puts "Get a value of the first TDataStd_Name attribute from restoring document: Error"
+ return
+}
+
+# Get a value of the attribute #2
+set IsDone [catch {set aGetAttr4 [GetName DD ${aLabel} ${aGuid2}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr2}!=${aGetAttr4} } {
+ puts ${aResult}
+ puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
+ puts "Get a value of the second TDataStd_Name attribute from restoring document: Error"
+ return
+}
+
+puts "Get a value of user defined TDataStd_Name attributes from restoring document: OK"
--- /dev/null
+#INTERFACE CAF
+# Basic attributes
+#
+# Testing attribute: User defined (additional GUID) TDataStd_AsciiString
+#
+# Testing command: SetAsciiString
+# Testing command: GetAsciiString
+#
+
+puts "caf001-N6"
+
+# Add an attribute to a data framework
+set aSetAttr1 "New Attribute_1"
+set aSetAttr2 "New Attribute_2"
+set aGuid2 "12e94572-6dbc-11d4-b9c8-0060b0ee281b"
+set aLabel 0:2
+SetAsciiString D ${aLabel} ${aSetAttr1}
+SetAsciiString D ${aLabel} ${aSetAttr2} ${aGuid2}
+
+# Close/Open the transaction
+NewCommand D
+
+# Save the document
+set aFile ${imagedir}/caf001-N7.cbf
+file delete ${aFile}
+SaveAs D ${aFile}
+if { ![file exists ${aFile}] } {
+ puts "There is not ${aFile} file; SaveAs command: Error"
+ return
+}
+#catch {exec chmod 777 ${aFile}}
+
+# Restore the document
+Close D
+Open ${aFile} DD
+
+# Get a value of the attribute #1
+set IsDone [catch {set aGetAttr3 [GetAsciiString DD ${aLabel}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr1}!=${aGetAttr3} } {
+ puts ${aResult}
+ puts "aSetAttr1=${aSetAttr1} aGetAttr3=${aGetAttr3}"
+ puts "Get a value of the first TDataStd_AsciiString attribute from restoring document: Error"
+ return
+}
+
+# Get a value of the attribute #2
+set IsDone [catch {set aGetAttr4 [GetAsciiString DD ${aLabel} ${aGuid2}]} aResult]
+if { ${IsDone} != 0 ||
+ ${aSetAttr2}!=${aGetAttr4} } {
+ puts ${aResult}
+ puts "aSetAttr2=${aSetAttr2} aGetAttr4=${aGetAttr4}"
+ puts "Get a value of the second TDataStd_AsciiString attribute from restoring document: Error"
+ return
+}
+
+puts "Get a value of user defined TDataStd_AsciiString attributes from restoring document: OK"