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

0031313: Foundation Classes - Dump improvement for classes

- Provide DumpJson for geometrical, ocaf and visualization classes;
- Change depth parameter of DumpJson (constant is not obligate here)
- Introduce a new macro for transient objects to be called as the first row in DumpJson: OCCT_DUMP_TRANSIENT_CLASS_BEGIN. We need not put the class name in the macro, using get_type_name of Standard_Transient for it.
- change implementation of OCCT_DUMP_CLASS_BEGIN and OCCT_DUMP_TRANSIENT_CLASS_BEGIN. It is not an sentry more and it does not create a new hierarchy level. It appends a new row into the output stream: "className": <className>
- OCCT_DUMP_* does not require semicolon
- class header is included first in source files of TDataStd, TDocStd, TCAFDoc
This commit is contained in:
nds
2020-01-28 12:03:38 +03:00
committed by bugmaster
parent 00ea7f2676
commit bc73b00672
532 changed files with 5237 additions and 419 deletions

View File

@@ -20,6 +20,7 @@
#include <CDM_MetaData.hxx>
#include <CDM_Reference.hxx>
#include <Resource_Manager.hxx>
#include <Standard_Dump.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Message.hxx>
@@ -126,3 +127,12 @@ TCollection_AsciiString CDM_Application::Version() const
// Default: empty
return TCollection_AsciiString();
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void CDM_Application::DumpJson (Standard_OStream& theOStream, Standard_Integer /*theDepth*/) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
}

View File

@@ -66,6 +66,9 @@ public:
//! Returns the application version.
Standard_EXPORT virtual TCollection_AsciiString Version() const;
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
friend class CDM_Reference;
friend class CDM_MetaData;

View File

@@ -28,6 +28,7 @@
#include <CDM_ReferenceIterator.hxx>
#include <Resource_Manager.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Dump.hxx>
#include <Standard_Failure.hxx>
#include <Standard_GUID.hxx>
#include <Standard_NoSuchObject.hxx>
@@ -1284,3 +1285,54 @@ void CDM_Document::ChangeStorageFormatVersion(const Standard_Integer theVersion)
{
myStorageFormatVersion = theVersion;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void CDM_Document::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
for (TColStd_SequenceOfExtendedString::Iterator aCommentIt (myComments); aCommentIt.More(); aCommentIt.Next())
{
const TCollection_ExtendedString& aComment = aCommentIt.Value();
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aComment)
}
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myPresentation)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myValidPresentation)
for (CDM_ListOfReferences::Iterator aFromReferenceIt (myFromReferences); aFromReferenceIt.More(); aFromReferenceIt.Next())
{
const Handle(CDM_Reference)& aFromReference = aFromReferenceIt.Value().get();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aFromReference.get())
}
for (CDM_ListOfReferences::Iterator aToReferenceIt (myToReferences); aToReferenceIt.More(); aToReferenceIt.Next())
{
const Handle(CDM_Reference)& aToReference = aToReferenceIt.Value().get();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aToReference.get())
}
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVersion)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myActualReferenceIdentifier)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myStorageVersion)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myMetaData.get())
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myRequestedComment)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myRequestedFolder)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRequestedFolderIsDefined)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myRequestedName)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRequestedNameIsDefined)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRequestedPreviousVersionIsDefined)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myRequestedPreviousVersion)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myFileExtension)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myDescription)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFileExtensionWasFound)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDescriptionWasFound)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myApplication.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myStorageFormatVersion)
}

View File

@@ -349,6 +349,9 @@ Standard_OStream& operator << (Standard_OStream& anOStream);
//! Sets <theVersion> of the format to be used to store the document
Standard_EXPORT void ChangeStorageFormatVersion(const Standard_Integer theVersion);
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
friend class CDM_Reference;
friend class CDM_ReferenceIterator;
friend class CDM_Application;

View File

@@ -20,6 +20,7 @@
#include <CDM_MetaData.hxx>
#include <CDM_MetaDataLookUpTable.hxx>
#include <CDM_Reference.hxx>
#include <Standard_Dump.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
@@ -144,3 +145,24 @@ void CDM_MetaData::SetIsReadOnly() {
void CDM_MetaData::UnsetIsReadOnly() {
myIsReadOnly=Standard_False;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void CDM_MetaData::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsRetrieved)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDocument)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myFolder)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myVersion)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasVersion)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myFileName)
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myPath)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDocumentVersion)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsReadOnly)
}

View File

@@ -84,6 +84,9 @@ Standard_OStream& operator << (Standard_OStream& anOStream);
Standard_EXPORT void SetIsReadOnly();
Standard_EXPORT void UnsetIsReadOnly();
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
friend class CDM_Reference;

View File

@@ -19,6 +19,7 @@
#include <CDM_Document.hxx>
#include <CDM_MetaData.hxx>
#include <CDM_Reference.hxx>
#include <Standard_Dump.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(CDM_Reference,Standard_Transient)
@@ -120,3 +121,23 @@ Standard_Boolean CDM_Reference::IsInSession() const {
Standard_Boolean CDM_Reference::IsStored() const {
return !myMetaData.IsNull();
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void CDM_Reference::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myToDocument.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFromDocument)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myReferenceIdentifier)
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myApplication.get())
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myMetaData.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDocumentVersion)
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseStorageConfiguration)
}

View File

@@ -48,6 +48,9 @@ public:
Standard_EXPORT Standard_Integer DocumentVersion() const;
Standard_EXPORT Standard_Boolean IsReadOnly() const;
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
friend class CDM_Document;