1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

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.
This commit is contained in:
mpv
2020-06-19 23:12:17 +03:00
committed by abv
parent 59e11a2f75
commit c99ad5d760
202 changed files with 1438 additions and 8261 deletions

View File

@@ -14,6 +14,10 @@ TDataStd_Comment.cxx
TDataStd_Comment.hxx
TDataStd_Current.cxx
TDataStd_Current.hxx
TDataStd_GenericEmpty.cxx
TDataStd_GenericEmpty.hxx
TDataStd_GenericExtString.cxx
TDataStd_GenericExtString.hxx
TDataStd_DataMapIteratorOfDataMapOfStringByte.hxx
TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger.hxx
TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal.hxx

View File

@@ -17,23 +17,9 @@
#include <TDataStd_Comment.hxx>
#include <Standard_Dump.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_ChildIDIterator.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_Tool.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Comment,TDF_Attribute)
#define lid1 45
#define lid2 36
IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_Comment, TDataStd_GenericExtString)
//=======================================================================
//function : GetID
@@ -46,8 +32,6 @@ const Standard_GUID& TDataStd_Comment::GetID ()
return TDataStd_CommentID;
}
//=======================================================================
//function : Set
//purpose :
@@ -65,7 +49,6 @@ Handle(TDataStd_Comment) TDataStd_Comment::Set (const TDF_Label& L,
return A;
}
//=======================================================================
//function : Set
//purpose :
@@ -81,78 +64,51 @@ Handle(TDataStd_Comment) TDataStd_Comment::Set (const TDF_Label& L)
return A;
}
//=======================================================================
//function : TDataStd_Comment
//purpose :
//=======================================================================
TDataStd_Comment::TDataStd_Comment () { }
TDataStd_Comment::TDataStd_Comment () {
myID = GetID();
}
//=======================================================================
//function : Set
//purpose :
//purpose :
//=======================================================================
void TDataStd_Comment::Set (const TCollection_ExtendedString& S)
void TDataStd_Comment::Set (const TCollection_ExtendedString& S)
{
// OCC2932 correction
if(myString == S) return;
Backup();
myString = S;
}
//=======================================================================
//function : Get
//purpose :
//=======================================================================
const TCollection_ExtendedString& TDataStd_Comment::Get () const
{
return myString;
}
//=======================================================================
//function : ID
//purpose :
//function : SetID
//purpose :
//=======================================================================
const Standard_GUID& TDataStd_Comment::ID () const { return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_Comment::NewEmpty () const
void TDataStd_Comment::SetID( const Standard_GUID& theGuid)
{
return new TDataStd_Comment();
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : Restore
//purpose :
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_Comment::Restore(const Handle(TDF_Attribute)& with)
void TDataStd_Comment::SetID()
{
myString = Handle(TDataStd_Comment)::DownCast (with)->Get ();
return;
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataStd_Comment::Paste (const Handle(TDF_Attribute)& into,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
Handle(TDataStd_Comment)::DownCast (into)->Set (myString);
Backup();
myID = GetID();
}
//=======================================================================
@@ -163,24 +119,6 @@ void TDataStd_Comment::Paste (const Handle(TDF_Attribute)& into,
Standard_OStream& TDataStd_Comment::Dump (Standard_OStream& anOS) const
{
TDF_Attribute::Dump(anOS);
anOS << "Comment=|"<<myString<<"|";
anOS << "Comment=|"<<Get()<<"|";
return anOS;
}
Standard_Boolean TDataStd_Comment::
AfterRetrieval(const Standard_Boolean)
{
return Standard_True;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_Comment::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myString)
}

View File

@@ -17,26 +17,14 @@
#ifndef _TDataStd_Comment_HeaderFile
#define _TDataStd_Comment_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDF_Attribute.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Boolean.hxx>
class Standard_GUID;
class TDF_Label;
class TCollection_ExtendedString;
class TDF_Attribute;
class TDF_RelocationTable;
#include <TDataStd_GenericExtString.hxx>
class TDataStd_Comment;
DEFINE_STANDARD_HANDLE(TDataStd_Comment, TDF_Attribute)
DEFINE_STANDARD_HANDLE(TDataStd_Comment, TDataStd_GenericExtString)
//! Comment attribute. may be associated to any label
//! to store user comment.
class TDataStd_Comment : public TDF_Attribute
class TDataStd_Comment : public TDataStd_GenericExtString
{
public:
@@ -58,50 +46,19 @@ public:
Standard_EXPORT static Handle(TDataStd_Comment) Set (const TDF_Label& label, const TCollection_ExtendedString& string);
Standard_EXPORT TDataStd_Comment();
Standard_EXPORT void Set (const TCollection_ExtendedString& S);
//! Returns the comment attribute.
Standard_EXPORT const TCollection_ExtendedString& Get() const;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT void Set (const TCollection_ExtendedString& S) Standard_OVERRIDE;
//! Sets the explicit user defined GUID to the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean AfterRetrieval (const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_Comment,TDF_Attribute)
protected:
private:
TCollection_ExtendedString myString;
DEFINE_DERIVED_ATTRIBUTE(TDataStd_Comment, TDataStd_GenericExtString)
};
#endif // _TDataStd_Comment_HeaderFile

View File

@@ -21,13 +21,12 @@
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
#include <TDataStd.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_DataSet.hxx>
#include <TDF_Label.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_TagSource.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Directory,TDF_Attribute)
IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_Directory,TDataStd_GenericEmpty)
//=======================================================================
//function : Find
@@ -115,7 +114,6 @@ TDataStd_Directory::TDataStd_Directory()
{
}
//=======================================================================
//function : ID
//purpose :
@@ -130,38 +128,10 @@ const Standard_GUID& TDataStd_Directory::ID() const
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_Directory::NewEmpty () const
{
return new TDataStd_Directory();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataStd_Directory::Restore(const Handle(TDF_Attribute)&)
{
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataStd_Directory::Paste (const Handle(TDF_Attribute)&,
const Handle(TDF_RelocationTable)& ) const
{
}
//=======================================================================
//function : References
//purpose :
//=======================================================================
void TDataStd_Directory::References (const Handle(TDF_DataSet)&) const
{
}
//Handle(TDF_Attribute) TDataStd_Directory::NewEmpty () const
//{
// return new TDataStd_Directory();
//}
//=======================================================================
//function : Dump
@@ -173,14 +143,3 @@ Standard_OStream& TDataStd_Directory::Dump (Standard_OStream& anOS) const
anOS << "Directory";
return anOS;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_Directory::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
}

View File

@@ -20,7 +20,7 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TDataStd_GenericEmpty.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_OStream.hxx>
class TDF_Label;
@@ -31,13 +31,13 @@ class TDF_DataSet;
class TDataStd_Directory;
DEFINE_STANDARD_HANDLE(TDataStd_Directory, TDF_Attribute)
DEFINE_STANDARD_HANDLE(TDataStd_Directory, TDataStd_GenericEmpty)
//! Associates a directory in the data framework with
//! a TDataStd_TagSource attribute.
//! You can create a new directory label and add
//! sub-directory or object labels to it,
class TDataStd_Directory : public TDF_Attribute
class TDataStd_Directory : public TDataStd_GenericEmpty
{
public:
@@ -51,7 +51,7 @@ public:
//! and the attribute found is set as D.
Standard_EXPORT static Standard_Boolean Find (const TDF_Label& current, Handle(TDataStd_Directory)& D);
//! Creates an enpty Directory attribute, located at
//! Creates an empty Directory attribute, located at
//! <label>. Raises if <label> has attribute
Standard_EXPORT static Handle(TDataStd_Directory) New (const TDF_Label& label);
@@ -71,23 +71,10 @@ public:
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& DS) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_Directory,TDF_Attribute)
DEFINE_DERIVED_ATTRIBUTE(TDataStd_Directory,TDataStd_GenericEmpty)
protected:

View File

@@ -128,6 +128,7 @@ void TDataStd_Expression::Restore(const Handle(TDF_Attribute)& With)
myExpression = EXPR->GetExpression();
Handle(TDataStd_Variable) V;
myVariables.Clear();
for (TDF_ListIteratorOfAttributeList it (EXPR->GetVariables()); it.More(); it.Next()) {
V = Handle(TDataStd_Variable)::DownCast(it.Value());
myVariables.Append(V);

View File

@@ -22,7 +22,7 @@
#include <TCollection_ExtendedString.hxx>
#include <TDF_AttributeList.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_DerivedAttribute.hxx>
#include <Standard_OStream.hxx>
class Standard_GUID;
class TDF_Label;
@@ -82,22 +82,12 @@ public:
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_Expression,TDF_Attribute)
protected:
private:
TCollection_ExtendedString myExpression;
TDF_AttributeList myVariables;
};

View File

@@ -0,0 +1,28 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <TDataStd_GenericEmpty.hxx>
#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_GenericEmpty,TDF_Attribute)
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_GenericEmpty::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
}

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _TDataStd_GenericEmpty_HeaderFile
#define _TDataStd_GenericEmpty_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TDF_DerivedAttribute.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
class TDF_RelocationTable;
class TDataStd_GenericEmpty;
DEFINE_STANDARD_HANDLE(TDataStd_GenericEmpty, TDF_Attribute)
//! An ancestor attibute for all attributes which have no fields.
//! If an attribute inherits this one it should not have drivers for persistence.
class TDataStd_GenericEmpty : public TDF_Attribute
{
public:
Standard_EXPORT void Restore (const Handle(TDF_Attribute)&) Standard_OVERRIDE {};
Standard_EXPORT void Paste (const Handle(TDF_Attribute)&, const Handle(TDF_RelocationTable)&) const Standard_OVERRIDE {}
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_GenericEmpty,TDF_Attribute)
};
#endif // _TDataStd_GenericEmpty_HeaderFile

View File

@@ -0,0 +1,91 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <TDataStd_GenericExtString.hxx>
#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_GenericExtString,TDF_Attribute)
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void TDataStd_GenericExtString::Set (const TCollection_ExtendedString& S)
{
if(myString == S) return;
Backup();
myString = S;
}
//=======================================================================
//function : Get
//purpose :
//=======================================================================
const TCollection_ExtendedString& TDataStd_GenericExtString::Get () const
{
return myString;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_GenericExtString::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
Backup();
myID = theGuid;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataStd_GenericExtString::ID () const { return myID; }
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataStd_GenericExtString::Restore(const Handle(TDF_Attribute)& with)
{
Handle(TDataStd_GenericExtString) anAtt = Handle(TDataStd_GenericExtString)::DownCast (with);
myString = anAtt->Get();
myID = anAtt->ID();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataStd_GenericExtString::Paste (const Handle(TDF_Attribute)& into,
const Handle(TDF_RelocationTable)&/* RT*/) const
{
Handle(TDataStd_GenericExtString) anAtt = Handle(TDataStd_GenericExtString)::DownCast (into);
anAtt->Set(myString);
anAtt->SetID(myID);
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_GenericExtString::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, Get())
OCCT_DUMP_FIELD_VALUE_GUID (theOStream, myID)
}

View File

@@ -0,0 +1,65 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _TDataStd_GenericExtString_HeaderFile
#define _TDataStd_GenericExtString_HeaderFile
#include <TDF_DerivedAttribute.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_GUID.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_RelocationTable;
class TDataStd_GenericExtString;
DEFINE_STANDARD_HANDLE(TDataStd_GenericExtString, TDF_Attribute)
//! An ancestor attibute for all attributes which have TCollection_ExtendedString field.
//! If an attribute inherits this one it should not have drivers for persistence.
//! Also this attribute provides functionality to have on the same label same attributes with different IDs.
class TDataStd_GenericExtString : public TDF_Attribute
{
public:
//! Sets <S> as name. Raises if <S> is not a valid name.
Standard_EXPORT virtual void Set (const TCollection_ExtendedString& S);
//! Sets the explicit user defined GUID to the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
//! Returns the name contained in this name attribute.
Standard_EXPORT virtual const TCollection_ExtendedString& Get() const;
//! Returns the ID of the attribute.
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_GenericExtString,TDF_Attribute)
protected:
//! A string field of the attribute, participated in persistence.
TCollection_ExtendedString myString;
//! A private GUID of the attribute.
Standard_GUID myID;
};
#endif // _TDataStd_GenericExtString_HeaderFile

View File

@@ -15,21 +15,9 @@
// commercial license or contractual agreement.
#include <TDataStd_Name.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Dump.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <TDF_ListIteratorOfAttributeList.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_Tool.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Name,TDF_Attribute)
IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_Name,TDataStd_GenericExtString)
//=======================================================================
//function : GetID
@@ -52,7 +40,7 @@ static Handle(TDataStd_Name) SetAttr(const TDF_Label& label,
Handle(TDataStd_Name) N;
if (!label.FindAttribute(theGuid, N)) {
N = new TDataStd_Name ();
N->SetID(theGuid);
N->SetID (theGuid);
label.AddAttribute(N);
}
N->Set (theString);
@@ -81,13 +69,15 @@ Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& label,
{
return SetAttr(label, theString, theGuid);
}
//=======================================================================
//function : TDataStd_Name
//purpose : Empty Constructor
//purpose :
//=======================================================================
TDataStd_Name::TDataStd_Name () : myID(GetID())
{}
TDataStd_Name::TDataStd_Name()
{
myID = GetID();
}
//=======================================================================
//function : Set
@@ -101,22 +91,10 @@ void TDataStd_Name::Set (const TCollection_ExtendedString& S)
myString = S;
}
//=======================================================================
//function : Get
//purpose :
//=======================================================================
const TCollection_ExtendedString& TDataStd_Name::Get () const
{
return myString;
}
//=======================================================================
//function : SetID
//purpose :
//=======================================================================
void TDataStd_Name::SetID( const Standard_GUID& theGuid)
{
if(myID == theGuid) return;
@@ -129,6 +107,7 @@ void TDataStd_Name::SetID( const Standard_GUID& theGuid)
//function : SetID
//purpose : sets default ID
//=======================================================================
void TDataStd_Name::SetID()
{
Backup();
@@ -136,49 +115,6 @@ void TDataStd_Name::SetID()
}
// TDF_Attribute methods
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataStd_Name::ID () const { return myID; }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_Name::NewEmpty () const
{
return new TDataStd_Name();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataStd_Name::Restore(const Handle(TDF_Attribute)& with)
{
Handle(TDataStd_Name) anAtt = Handle(TDataStd_Name)::DownCast (with);
myString = anAtt->Get();
myID = anAtt->ID();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
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);
}
//=======================================================================
//function : Dump
//purpose :
@@ -193,17 +129,3 @@ Standard_OStream& TDataStd_Name::Dump (Standard_OStream& anOS) const
anOS << sguid << std::endl;
return anOS;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_Name::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myString)
OCCT_DUMP_FIELD_VALUE_GUID (theOStream, myID)
}

View File

@@ -17,13 +17,8 @@
#ifndef _TDataStd_Name_HeaderFile
#define _TDataStd_Name_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDF_Attribute.hxx>
#include <TDataStd_GenericExtString.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
class Standard_DomainError;
class TDF_Label;
@@ -33,14 +28,13 @@ class TDF_RelocationTable;
class TDataStd_Name;
DEFINE_STANDARD_HANDLE(TDataStd_Name, TDF_Attribute)
DEFINE_STANDARD_HANDLE(TDataStd_Name, TDataStd_GenericExtString)
//! Used to define a name attribute containing a string which specifies the name.
class TDataStd_Name : public TDF_Attribute
class TDataStd_Name : public TDataStd_GenericExtString
{
public:
//! class methods working on the name itself
//! ========================================
@@ -75,10 +69,11 @@ public:
//! The Name attribute is returned.
Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const Standard_GUID& guid,
const TCollection_ExtendedString& string);
Standard_EXPORT TDataStd_Name();
//! Sets <S> as name. Raises if <S> is not a valid name.
Standard_EXPORT void Set (const TCollection_ExtendedString& S);
Standard_EXPORT void Set (const TCollection_ExtendedString& S) Standard_OVERRIDE;
//! Sets the explicit user defined GUID to the attribute.
Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
@@ -86,37 +81,10 @@ public:
//! Sets default GUID for the attribute.
Standard_EXPORT void SetID() Standard_OVERRIDE;
//! Returns the name contained in this name attribute.
Standard_EXPORT const TCollection_ExtendedString& Get() const;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_Name,TDF_Attribute)
protected:
private:
TCollection_ExtendedString myString;
Standard_GUID myID;
DEFINE_DERIVED_ATTRIBUTE(TDataStd_Name, TDataStd_GenericExtString)
};

View File

@@ -22,12 +22,11 @@
#include <Standard_Type.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Label.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_TagSource.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_NoteBook,TDF_Attribute)
IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_NoteBook,TDataStd_GenericEmpty)
//=======================================================================
//function : Find
@@ -127,35 +126,6 @@ const Standard_GUID& TDataStd_NoteBook::ID() const
{ return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_NoteBook::NewEmpty () const
{
return new TDataStd_NoteBook();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataStd_NoteBook::Restore(const Handle(TDF_Attribute)& )
{
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataStd_NoteBook::Paste (const Handle(TDF_Attribute)& ,
const Handle(TDF_RelocationTable)& ) const
{
}
//=======================================================================
//function : Dump
//purpose :
@@ -166,14 +136,3 @@ Standard_OStream& TDataStd_NoteBook::Dump (Standard_OStream& anOS) const
anOS << "NoteBook";
return anOS;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_NoteBook::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
}

View File

@@ -20,7 +20,7 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TDataStd_GenericEmpty.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
@@ -34,10 +34,10 @@ class TDF_RelocationTable;
class TDataStd_NoteBook;
DEFINE_STANDARD_HANDLE(TDataStd_NoteBook, TDF_Attribute)
DEFINE_STANDARD_HANDLE(TDataStd_NoteBook, TDataStd_GenericEmpty)
//! NoteBook Object attribute
class TDataStd_NoteBook : public TDF_Attribute
class TDataStd_NoteBook : public TDataStd_GenericEmpty
{
public:
@@ -72,21 +72,11 @@ public:
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_NoteBook,TDF_Attribute)
DEFINE_DERIVED_ATTRIBUTE(TDataStd_NoteBook, TDataStd_GenericEmpty)
protected:

View File

@@ -22,7 +22,7 @@
#include <Standard_Real.hxx>
#include <TDataStd_RealEnum.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_DerivedAttribute.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_OStream.hxx>
#include <Standard_GUID.hxx>
@@ -109,17 +109,10 @@ public:
protected:
private:
Standard_Real myValue;
//! An obsolete field that will be removed in next versions.
TDataStd_RealEnum myDimension;
Standard_GUID myID;
};

View File

@@ -27,7 +27,7 @@
#include <TDF_ListIteratorOfAttributeList.hxx>
#include <TDF_RelocationTable.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Relation,TDF_Attribute)
IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_Relation,TDF_Attribute)
//=======================================================================
//function : GetID
@@ -63,16 +63,6 @@ TDataStd_Relation::TDataStd_Relation()
{
}
//=======================================================================
//function : Name
//purpose :
//=======================================================================
TCollection_ExtendedString TDataStd_Relation::Name () const
{
return myRelation; // ->String();
}
//=======================================================================
//function : SetRelation
//purpose :
@@ -80,11 +70,7 @@ TCollection_ExtendedString TDataStd_Relation::Name () const
void TDataStd_Relation::SetRelation(const TCollection_ExtendedString& R)
{
// OCC2932 correction
if(myRelation == R) return;
Backup();
myRelation = R;
SetExpression(R);
}
//=======================================================================
@@ -94,17 +80,7 @@ void TDataStd_Relation::SetRelation(const TCollection_ExtendedString& R)
const TCollection_ExtendedString& TDataStd_Relation::GetRelation() const
{
return myRelation;
}
//=======================================================================
//function : GetVariables
//purpose :
//=======================================================================
TDF_AttributeList& TDataStd_Relation::GetVariables()
{
return myVariables;
return GetExpression();
}
//=======================================================================
@@ -117,52 +93,6 @@ const Standard_GUID& TDataStd_Relation::ID() const
return GetID();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataStd_Relation::Restore(const Handle(TDF_Attribute)& With)
{
Handle(TDataStd_Relation) REL = Handle(TDataStd_Relation)::DownCast (With);
myRelation = REL->GetRelation();
Handle(TDataStd_Variable) V;
myVariables.Clear();
for (TDF_ListIteratorOfAttributeList it (REL->GetVariables()); it.More(); it.Next()) {
V = Handle(TDataStd_Variable)::DownCast(it.Value());
myVariables.Append(V);
}
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_Relation::NewEmpty() const
{
return new TDataStd_Relation();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataStd_Relation::Paste(const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& RT) const
{
Handle(TDataStd_Relation) REL = Handle(TDataStd_Relation)::DownCast (Into);
REL->SetRelation(myRelation);
Handle(TDataStd_Variable) V1;
for (TDF_ListIteratorOfAttributeList it (myVariables); it.More(); it.Next()) {
V1 = Handle(TDataStd_Variable)::DownCast(it.Value());
Handle(TDF_Attribute) V2;
RT->HasRelocation (V1,V2);
REL->GetVariables().Append(V2);
}
}
//=======================================================================
//function : Dump
//purpose :
@@ -184,11 +114,11 @@ void TDataStd_Relation::DumpJson (Standard_OStream& theOStream, Standard_Integer
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myRelation)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, GetRelation())
for (TDF_AttributeList::Iterator aVariableIt (myVariables); aVariableIt.More(); aVariableIt.Next())
{
const Handle(TDF_Attribute)& aVariable = aVariableIt.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aVariable.get())
}
}
}

View File

@@ -17,22 +17,10 @@
#ifndef _TDataStd_Relation_HeaderFile
#define _TDataStd_Relation_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDF_AttributeList.hxx>
#include <TDF_Attribute.hxx>
#include <Standard_OStream.hxx>
class Standard_GUID;
class TDF_Label;
class TCollection_ExtendedString;
class TDF_Attribute;
class TDF_RelocationTable;
#include <TDataStd_Expression.hxx>
class TDataStd_Relation;
DEFINE_STANDARD_HANDLE(TDataStd_Relation, TDF_Attribute)
DEFINE_STANDARD_HANDLE(TDataStd_Relation, TDataStd_Expression)
//! Relation attribute.
//! ==================
@@ -42,7 +30,7 @@ DEFINE_STANDARD_HANDLE(TDataStd_Relation, TDF_Attribute)
//!
//! Warning: To be consistent, each Variable referenced by the
//! relation must have its equivalent in the string
class TDataStd_Relation : public TDF_Attribute
class TDataStd_Relation : public TDataStd_Expression
{
public:
@@ -59,23 +47,12 @@ public:
Standard_EXPORT TDataStd_Relation();
//! build and return the relation name
Standard_EXPORT TCollection_ExtendedString Name() const;
Standard_EXPORT void SetRelation (const TCollection_ExtendedString& E);
Standard_EXPORT const TCollection_ExtendedString& GetRelation() const;
Standard_EXPORT TDF_AttributeList& GetVariables();
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
//! Dumps the content of me into the stream
@@ -83,27 +60,7 @@ public:
DEFINE_STANDARD_RTTIEXT(TDataStd_Relation,TDF_Attribute)
protected:
private:
TCollection_ExtendedString myRelation;
TDF_AttributeList myVariables;
DEFINE_DERIVED_ATTRIBUTE(TDataStd_Relation,TDataStd_Expression)
};
#endif // _TDataStd_Relation_HeaderFile

View File

@@ -15,14 +15,10 @@
#include <TDataStd_Tick.hxx>
#include <Standard_Dump.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Label.hxx>
#include <TDF_RelocationTable.hxx>
#include <Standard_GUID.hxx>
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Tick,TDF_Attribute)
IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_Tick,TDataStd_GenericEmpty)
//=======================================================================
//function : GetID
@@ -66,34 +62,6 @@ const Standard_GUID& TDataStd_Tick::ID () const
return GetID();
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataStd_Tick::NewEmpty() const
{
return new TDataStd_Tick();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataStd_Tick::Restore (const Handle(TDF_Attribute)& )
{
// There are no fields in this attribute.
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataStd_Tick::Paste(const Handle(TDF_Attribute)& ,
const Handle(TDF_RelocationTable)& ) const
{
// There are no fields in this attribute.
}
//=======================================================================
//function : Dump
//purpose :
@@ -103,14 +71,3 @@ Standard_OStream& TDataStd_Tick::Dump (Standard_OStream& anOS) const
anOS << "Tick";
return anOS;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void TDataStd_Tick::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
}

View File

@@ -16,10 +16,7 @@
#ifndef _TDataStd_Tick_HeaderFile
#define _TDataStd_Tick_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TDataStd_GenericEmpty.hxx>
#include <Standard_OStream.hxx>
class Standard_GUID;
class TDF_Label;
@@ -28,12 +25,12 @@ class TDF_RelocationTable;
class TDataStd_Tick;
DEFINE_STANDARD_HANDLE(TDataStd_Tick, TDF_Attribute)
DEFINE_STANDARD_HANDLE(TDataStd_Tick, TDataStd_GenericEmpty)
//! Defines a boolean attribute.
//! If it exists at a label - true,
//! Otherwise - false.
class TDataStd_Tick : public TDF_Attribute
class TDataStd_Tick : public TDataStd_GenericEmpty
{
public:
@@ -52,31 +49,10 @@ public:
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(TDataStd_Tick,TDF_Attribute)
protected:
private:
DEFINE_DERIVED_ATTRIBUTE(TDataStd_Tick, TDataStd_GenericEmpty)
};