mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0026961: Recover possibility to read files in old persistence format
Possibility to read shapes and OCAF documents from old persistence format (Std and StdL schema) is restored. Test cases used old persistent files on input are restored with suffix "_std" Removing toolkit from OS package
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
FILES
|
||||
StdLPersistent.cxx
|
||||
StdLPersistent.hxx
|
||||
StdLPersistent_PCollection_HExtendedString.cxx
|
||||
StdLPersistent_PCollection_HExtendedString.hxx
|
||||
StdLPersistent_PColStd_HArray1.hxx
|
||||
StdLPersistent_PColStd_HArray1Base.cxx
|
||||
StdLPersistent_PColStd_HArray1Base.hxx
|
||||
StdLPersistent_PDataStd_Integer.cxx
|
||||
StdLPersistent_PDataStd_Integer.hxx
|
||||
StdLPersistent_PDataStd_Name.cxx
|
||||
StdLPersistent_PDataStd_Name.hxx
|
||||
StdLPersistent_PDF_Data.cxx
|
||||
StdLPersistent_PDF_Data.hxx
|
||||
StdLPersistent_PDocStd_Document.cxx
|
||||
StdLPersistent_PDocStd_Document.hxx
|
||||
StdLPersistent_Collection.cxx
|
||||
StdLPersistent_Collection.hxx
|
||||
StdLPersistent_Data.cxx
|
||||
StdLPersistent_Data.hxx
|
||||
StdLPersistent_Dependency.cxx
|
||||
StdLPersistent_Dependency.hxx
|
||||
StdLPersistent_Document.cxx
|
||||
StdLPersistent_Document.hxx
|
||||
StdLPersistent_Function.hxx
|
||||
StdLPersistent_HArray1OfPersistent.hxx
|
||||
StdLPersistent_HArray1.cxx
|
||||
StdLPersistent_HArray1.hxx
|
||||
StdLPersistent_HArray2.cxx
|
||||
StdLPersistent_HArray2.hxx
|
||||
StdLPersistent_HString.cxx
|
||||
StdLPersistent_HString.hxx
|
||||
StdLPersistent_NamedData.cxx
|
||||
StdLPersistent_NamedData.hxx
|
||||
StdLPersistent_Real.hxx
|
||||
StdLPersistent_TreeNode.cxx
|
||||
StdLPersistent_TreeNode.hxx
|
||||
StdLPersistent_Value.cxx
|
||||
StdLPersistent_Value.hxx
|
||||
StdLPersistent_Variable.hxx
|
||||
StdLPersistent_Void.hxx
|
||||
StdLPersistent_XLink.hxx
|
||||
|
@@ -14,12 +14,22 @@
|
||||
#include <StdLPersistent.hxx>
|
||||
#include <StdObjMgt_MapOfInstantiators.hxx>
|
||||
|
||||
#include <StdLPersistent_PDocStd_Document.hxx>
|
||||
#include <StdLPersistent_PDF_Data.hxx>
|
||||
#include <StdLPersistent_PColStd_HArray1.hxx>
|
||||
#include <StdLPersistent_PCollection_HExtendedString.hxx>
|
||||
#include <StdLPersistent_PDataStd_Name.hxx>
|
||||
#include <StdLPersistent_PDataStd_Integer.hxx>
|
||||
#include <StdLPersistent_Document.hxx>
|
||||
#include <StdLPersistent_Data.hxx>
|
||||
#include <StdLPersistent_HString.hxx>
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
#include <StdLPersistent_HArray2.hxx>
|
||||
#include <StdLPersistent_Void.hxx>
|
||||
#include <StdLPersistent_Real.hxx>
|
||||
#include <StdLPersistent_Value.hxx>
|
||||
#include <StdLPersistent_Collection.hxx>
|
||||
#include <StdLPersistent_Dependency.hxx>
|
||||
#include <StdLPersistent_Variable.hxx>
|
||||
#include <StdLPersistent_XLink.hxx>
|
||||
#include <StdLPersistent_Function.hxx>
|
||||
#include <StdLPersistent_TreeNode.hxx>
|
||||
#include <StdLPersistent_NamedData.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BindTypes
|
||||
@@ -27,17 +37,65 @@
|
||||
//=======================================================================
|
||||
void StdLPersistent::BindTypes (StdObjMgt_MapOfInstantiators& theMap)
|
||||
{
|
||||
theMap.Bind <StdLPersistent_PDocStd_Document> ("PDocStd_Document");
|
||||
theMap.Bind <StdLPersistent_PDF_Data> ("PDF_Data");
|
||||
theMap.Bind <StdLPersistent_PDataStd_Name> ("PDataStd_Name");
|
||||
theMap.Bind <StdLPersistent_PDataStd_Integer> ("PDataStd_Integer");
|
||||
// Non-attribute data
|
||||
theMap.Bind <StdLPersistent_Document> ("PDocStd_Document");
|
||||
theMap.Bind <StdLPersistent_Data> ("PDF_Data");
|
||||
|
||||
theMap.Bind <StdLPersistent_PColStd_HArray1OfInteger>
|
||||
("PColStd_HArray1OfInteger");
|
||||
theMap.Bind <StdLPersistent_HString::Ascii> ("PCollection_HAsciiString");
|
||||
theMap.Bind <StdLPersistent_HString::Extended> ("PCollection_HExtendedString");
|
||||
|
||||
theMap.Bind <StdLPersistent_PDF_HAttributeArray1>
|
||||
("PDF_HAttributeArray1");
|
||||
theMap.Bind <StdLPersistent_HArray1::Integer> ("PColStd_HArray1OfInteger");
|
||||
theMap.Bind <StdLPersistent_HArray1::Real> ("PColStd_HArray1OfReal");
|
||||
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PColStd_HArray1OfExtendedString");
|
||||
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDF_HAttributeArray1");
|
||||
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDataStd_HArray1OfHAsciiString");
|
||||
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDataStd_HArray1OfHArray1OfInteger");
|
||||
theMap.Bind <StdLPersistent_HArray1::Persistent> ("PDataStd_HArray1OfHArray1OfReal");
|
||||
theMap.Bind <StdLPersistent_HArray1::Byte> ("PDataStd_HArray1OfByte");
|
||||
|
||||
theMap.Bind <StdLPersistent_PCollection_HExtendedString>
|
||||
("PCollection_HExtendedString");
|
||||
theMap.Bind <StdLPersistent_HArray2::Integer> ("PColStd_HArray2OfInteger");
|
||||
|
||||
// Attributes
|
||||
theMap.Bind <StdLPersistent_Void::Directory> ("PDataStd_Directory");
|
||||
theMap.Bind <StdLPersistent_Void::Tick> ("PDataStd_Tick");
|
||||
theMap.Bind <StdLPersistent_Void::NoteBook> ("PDataStd_NoteBook");
|
||||
|
||||
theMap.Bind <StdLPersistent_Value::Integer> ("PDataStd_Integer");
|
||||
theMap.Bind <StdLPersistent_Value::TagSource> ("PDF_TagSource");
|
||||
theMap.Bind <StdLPersistent_Value::Reference> ("PDF_Reference");
|
||||
theMap.Bind <StdLPersistent_Value::UAttribute> ("PDataStd_UAttribute");
|
||||
|
||||
theMap.Bind <StdLPersistent_Value::Name> ("PDataStd_Name");
|
||||
theMap.Bind <StdLPersistent_Value::Comment> ("PDataStd_Comment");
|
||||
theMap.Bind <StdLPersistent_Value::AsciiString> ("PDataStd_AsciiString");
|
||||
|
||||
theMap.Bind <StdLPersistent_Collection::IntegerArray> ("PDataStd_IntegerArray");
|
||||
theMap.Bind <StdLPersistent_Collection::RealArray> ("PDataStd_RealArray");
|
||||
theMap.Bind <StdLPersistent_Collection::ByteArray> ("PDataStd_ByteArray");
|
||||
theMap.Bind <StdLPersistent_Collection::ExtStringArray> ("PDataStd_ExtStringArray");
|
||||
theMap.Bind <StdLPersistent_Collection::BooleanArray> ("PDataStd_BooleanArray");
|
||||
theMap.Bind <StdLPersistent_Collection::ReferenceArray> ("PDataStd_ReferenceArray");
|
||||
|
||||
theMap.Bind <StdLPersistent_Collection::IntegerArray_1> ("PDataStd_IntegerArray_1");
|
||||
theMap.Bind <StdLPersistent_Collection::RealArray_1> ("PDataStd_RealArray_1");
|
||||
theMap.Bind <StdLPersistent_Collection::ByteArray_1> ("PDataStd_ByteArray_1");
|
||||
theMap.Bind <StdLPersistent_Collection::ExtStringArray_1> ("PDataStd_ExtStringArray_1");
|
||||
|
||||
theMap.Bind <StdLPersistent_Collection::IntegerList> ("PDataStd_IntegerList");
|
||||
theMap.Bind <StdLPersistent_Collection::RealList> ("PDataStd_RealList");
|
||||
theMap.Bind <StdLPersistent_Collection::BooleanList> ("PDataStd_BooleanList");
|
||||
theMap.Bind <StdLPersistent_Collection::ExtStringList> ("PDataStd_ExtStringList");
|
||||
theMap.Bind <StdLPersistent_Collection::ReferenceList> ("PDataStd_ReferenceList");
|
||||
|
||||
theMap.Bind <StdLPersistent_Collection::IntPackedMap> ("PDataStd_IntPackedMap");
|
||||
theMap.Bind <StdLPersistent_Collection::IntPackedMap_1> ("PDataStd_IntPackedMap_1");
|
||||
|
||||
theMap.Bind <StdLPersistent_Real> ("PDataStd_Real");
|
||||
theMap.Bind <StdLPersistent_Dependency::Expression> ("PDataStd_Expression");
|
||||
theMap.Bind <StdLPersistent_Dependency::Relation> ("PDataStd_Relation");
|
||||
theMap.Bind <StdLPersistent_Variable> ("PDataStd_Variable");
|
||||
theMap.Bind <StdLPersistent_XLink> ("PDocStd_XLink");
|
||||
theMap.Bind <StdLPersistent_Function> ("PFunction_Function");
|
||||
theMap.Bind <StdLPersistent_TreeNode> ("PDataStd_TreeNode");
|
||||
theMap.Bind <StdLPersistent_NamedData> ("PDataStd_NamedData");
|
||||
}
|
||||
|
260
src/StdLPersistent/StdLPersistent_Collection.cxx
Normal file
260
src/StdLPersistent/StdLPersistent_Collection.cxx
Normal file
@@ -0,0 +1,260 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_Collection.hxx>
|
||||
|
||||
#include <TColStd_HPackedMapOfInteger.hxx>
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
|
||||
struct StdLPersistent_Collection::noConversion
|
||||
{
|
||||
noConversion (const Handle(TDF_Data)&) {}
|
||||
|
||||
template <class Type>
|
||||
Type operator() (Type theValue) const { return theValue; }
|
||||
};
|
||||
|
||||
struct StdLPersistent_Collection::byteConverter
|
||||
{
|
||||
byteConverter (const Handle(TDF_Data)&) {}
|
||||
|
||||
Standard_Byte operator() (Standard_Integer theValue) const
|
||||
{ return static_cast<Standard_Byte> (theValue); }
|
||||
};
|
||||
|
||||
struct StdLPersistent_Collection::stringConverter
|
||||
{
|
||||
stringConverter (const Handle(TDF_Data)&) {}
|
||||
|
||||
const TCollection_ExtendedString& operator()
|
||||
(const Handle(StdObjMgt_Persistent)& theValue) const
|
||||
{
|
||||
Handle(TCollection_HExtendedString) aString = theValue->ExtString();
|
||||
if (aString)
|
||||
return aString->String();
|
||||
else
|
||||
{
|
||||
static TCollection_ExtendedString anEmptyString;
|
||||
return anEmptyString;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct StdLPersistent_Collection::referenceConverter
|
||||
{
|
||||
referenceConverter (const Handle(TDF_Data)& theDF) : myDF (theDF) {}
|
||||
|
||||
TDF_Label operator() (const Handle(StdObjMgt_Persistent)& theValue) const
|
||||
{ return theValue->Label (myDF); }
|
||||
|
||||
private:
|
||||
Handle(TDF_Data) myDF;
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
template <class Persistent>
|
||||
void StdLPersistent_Collection::booleanArrayBase<Persistent>::Read
|
||||
(StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
StdLPersistent_Collection::booleanArrayBase<Persistent>::SingleRef::Read (theReadData);
|
||||
theReadData >> myLower >> myUpper;
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::booleanArrayBase<Persistent>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
Handle(TColStd_HArray1OfByte) aByteArray =
|
||||
new TColStd_HArray1OfByte (theArray->Lower(), theArray->Upper());
|
||||
|
||||
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
|
||||
aByteArray->SetValue (i, theConverter (theArray->Value(i)));
|
||||
|
||||
this->myTransient->Init (myLower, myUpper);
|
||||
this->myTransient->SetInternalArray (aByteArray);
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::directArrayBase<Persistent>::import
|
||||
(const ArrayHandle& theArray, Converter) const
|
||||
{
|
||||
this->myTransient->ChangeArray (theArray);
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::arrayBase<Persistent>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
this->myTransient->Init (theArray->Lower(), theArray->Upper());
|
||||
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
|
||||
this->myTransient->SetValue (i, theConverter (theArray->Value(i)));
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::listBase<Persistent>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
|
||||
this->myTransient->Append (theConverter (theArray->Value(i)));
|
||||
}
|
||||
|
||||
template <class Persistent>
|
||||
template <class ArrayHandle, class Converter>
|
||||
void StdLPersistent_Collection::mapBase<Persistent>::import
|
||||
(const ArrayHandle& theArray, Converter theConverter) const
|
||||
{
|
||||
Handle(TColStd_HPackedMapOfInteger) anHMap = new TColStd_HPackedMapOfInteger;
|
||||
for (Standard_Integer i = theArray->Lower(); i <= theArray->Upper(); i++)
|
||||
anHMap->ChangeMap().Add (theConverter (theArray->Value(i)));
|
||||
this->myTransient->ChangeMap (anHMap);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template <template<class> class BaseT,
|
||||
class HArrayClass,
|
||||
class AttribClass,
|
||||
class Converter>
|
||||
void StdLPersistent_Collection::
|
||||
instance<BaseT, HArrayClass, AttribClass, Converter>::ImportAttribute()
|
||||
{
|
||||
Handle(HArrayClass) anHArray;
|
||||
if (this->myData.Cast (anHArray))
|
||||
{
|
||||
typename HArrayClass::ArrayHandle anArray = anHArray->Array();
|
||||
if (anArray)
|
||||
this->import (anArray, Converter (this->myTransient->Label().Data()));
|
||||
this->myData.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
template <class Instance>
|
||||
void StdLPersistent_Collection::instance_1<Instance>::Read
|
||||
(StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
Instance::Read (theReadData);
|
||||
theReadData >> myDelta;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template <class Instance>
|
||||
void StdLPersistent_Collection::instance_1<Instance>::ImportAttribute()
|
||||
{
|
||||
Instance::ImportAttribute();
|
||||
this->myTransient->SetDelta (myDelta);
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::booleanArrayBase,
|
||||
StdLPersistent_Collection::integer,
|
||||
TDataStd_BooleanArray,
|
||||
StdLPersistent_Collection::byteConverter>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::directArrayBase,
|
||||
StdLPersistent_Collection::integer,
|
||||
TDataStd_IntegerArray,
|
||||
StdLPersistent_Collection::noConversion>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::directArrayBase,
|
||||
StdLPersistent_Collection::real,
|
||||
TDataStd_RealArray,
|
||||
StdLPersistent_Collection::noConversion>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::arrayBase,
|
||||
StdLPersistent_Collection::integer,
|
||||
TDataStd_ByteArray,
|
||||
StdLPersistent_Collection::byteConverter>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::arrayBase,
|
||||
StdLPersistent_Collection::persistent,
|
||||
TDataStd_ExtStringArray,
|
||||
StdLPersistent_Collection::stringConverter>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::arrayBase,
|
||||
StdLPersistent_Collection::persistent,
|
||||
TDataStd_ReferenceArray,
|
||||
StdLPersistent_Collection::referenceConverter>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::listBase,
|
||||
StdLPersistent_Collection::integer,
|
||||
TDataStd_IntegerList,
|
||||
StdLPersistent_Collection::noConversion>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::listBase,
|
||||
StdLPersistent_Collection::real,
|
||||
TDataStd_RealList,
|
||||
StdLPersistent_Collection::noConversion>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::listBase,
|
||||
StdLPersistent_Collection::integer,
|
||||
TDataStd_BooleanList,
|
||||
StdLPersistent_Collection::noConversion>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::listBase,
|
||||
StdLPersistent_Collection::persistent,
|
||||
TDataStd_ExtStringList,
|
||||
StdLPersistent_Collection::stringConverter>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::listBase,
|
||||
StdLPersistent_Collection::persistent,
|
||||
TDataStd_ReferenceList,
|
||||
StdLPersistent_Collection::referenceConverter>;
|
||||
|
||||
template class StdLPersistent_Collection::instance
|
||||
<StdLPersistent_Collection::mapBase,
|
||||
StdLPersistent_Collection::integer,
|
||||
TDataStd_IntPackedMap,
|
||||
StdLPersistent_Collection::noConversion>;
|
||||
|
||||
template class StdLPersistent_Collection::instance_1
|
||||
<StdLPersistent_Collection::IntegerArray>;
|
||||
|
||||
template class StdLPersistent_Collection::instance_1
|
||||
<StdLPersistent_Collection::RealArray>;
|
||||
|
||||
template class StdLPersistent_Collection::instance_1
|
||||
<StdLPersistent_Collection::ByteArray>;
|
||||
|
||||
template class StdLPersistent_Collection::instance_1
|
||||
<StdLPersistent_Collection::ExtStringArray>;
|
||||
|
||||
template class StdLPersistent_Collection::instance_1
|
||||
<StdLPersistent_Collection::IntPackedMap>;
|
197
src/StdLPersistent/StdLPersistent_Collection.hxx
Normal file
197
src/StdLPersistent/StdLPersistent_Collection.hxx
Normal file
@@ -0,0 +1,197 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_Collection_HeaderFile
|
||||
#define _StdLPersistent_Collection_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
|
||||
#include <TDataStd_IntegerArray.hxx>
|
||||
#include <TDataStd_RealArray.hxx>
|
||||
#include <TDataStd_ByteArray.hxx>
|
||||
#include <TDataStd_ExtStringArray.hxx>
|
||||
#include <TDataStd_BooleanArray.hxx>
|
||||
#include <TDataStd_ReferenceArray.hxx>
|
||||
#include <TDataStd_IntegerList.hxx>
|
||||
#include <TDataStd_RealList.hxx>
|
||||
#include <TDataStd_ExtStringList.hxx>
|
||||
#include <TDataStd_BooleanList.hxx>
|
||||
#include <TDataStd_ReferenceList.hxx>
|
||||
#include <TDataStd_IntPackedMap.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Collection : private StdObjMgt_ContentTypes
|
||||
{
|
||||
// Converters
|
||||
struct noConversion;
|
||||
struct byteConverter;
|
||||
struct stringConverter;
|
||||
struct referenceConverter;
|
||||
|
||||
// Base templates
|
||||
template <class Base>
|
||||
class booleanArrayBase : public Base
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
protected:
|
||||
template <class ArrayHandle, class Converter>
|
||||
inline void import (const ArrayHandle& theArray, Converter theConverter)
|
||||
const;
|
||||
|
||||
protected:
|
||||
Value<Standard_Integer> myLower;
|
||||
Value<Standard_Integer> myUpper;
|
||||
};
|
||||
|
||||
template <class Base>
|
||||
class directArrayBase : public Base
|
||||
{
|
||||
protected:
|
||||
template <class ArrayHandle, class Converter>
|
||||
inline void import (const ArrayHandle& theArray, Converter theConverter)
|
||||
const;
|
||||
};
|
||||
|
||||
template <class Base>
|
||||
class arrayBase : public Base
|
||||
{
|
||||
protected:
|
||||
template <class ArrayHandle, class Converter>
|
||||
inline void import (const ArrayHandle& theArray, Converter theConverter)
|
||||
const;
|
||||
};
|
||||
|
||||
template <class Base>
|
||||
class listBase : public Base
|
||||
{
|
||||
protected:
|
||||
template <class ArrayHandle, class Converter>
|
||||
inline void import (const ArrayHandle& theArray, Converter theConverter)
|
||||
const;
|
||||
};
|
||||
|
||||
template <class Base>
|
||||
class mapBase : public Base
|
||||
{
|
||||
protected:
|
||||
template <class ArrayHandle, class Converter>
|
||||
inline void import (const ArrayHandle& theArray, Converter theConverter)
|
||||
const;
|
||||
};
|
||||
|
||||
// Instance templates
|
||||
template <template<class> class BaseT,
|
||||
class HArrayClass,
|
||||
class AttribClass,
|
||||
class Converter>
|
||||
class instance
|
||||
: public BaseT <typename StdObjMgt_Attribute<AttribClass>::SingleRef>
|
||||
{
|
||||
public:
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual void ImportAttribute();
|
||||
};
|
||||
|
||||
template <class Instance>
|
||||
class instance_1 : public Instance
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual void ImportAttribute();
|
||||
|
||||
private:
|
||||
Value<Standard_Boolean> myDelta;
|
||||
};
|
||||
|
||||
|
||||
// Collection type specialization
|
||||
template<class HArrayClass, class AttribClass, class Converter = noConversion>
|
||||
struct booleanArrayT
|
||||
: instance<booleanArrayBase, HArrayClass, AttribClass, Converter> {};
|
||||
|
||||
template<class HArrayClass, class AttribClass, class Converter = noConversion>
|
||||
struct directArrayT
|
||||
: instance<directArrayBase, HArrayClass, AttribClass, Converter> {};
|
||||
|
||||
template<class HArrayClass, class AttribClass, class Converter = noConversion>
|
||||
struct arrayT
|
||||
: instance<arrayBase, HArrayClass, AttribClass, Converter> {};
|
||||
|
||||
template<class HArrayClass, class AttribClass, class Converter = noConversion>
|
||||
struct listT
|
||||
: instance<listBase, HArrayClass, AttribClass, Converter> {};
|
||||
|
||||
template<class HArrayClass, class AttribClass, class Converter = noConversion>
|
||||
struct mapT
|
||||
: instance<mapBase, HArrayClass, AttribClass, Converter> {};
|
||||
|
||||
|
||||
// Internal array types
|
||||
typedef StdLPersistent_HArray1::Integer integer;
|
||||
typedef StdLPersistent_HArray1::Real real;
|
||||
typedef StdLPersistent_HArray1::Persistent persistent;
|
||||
|
||||
public:
|
||||
// Final specialization
|
||||
typedef booleanArrayT <integer, TDataStd_BooleanArray, byteConverter>
|
||||
BooleanArray;
|
||||
|
||||
typedef directArrayT <integer, TDataStd_IntegerArray>
|
||||
IntegerArray;
|
||||
|
||||
typedef directArrayT <real, TDataStd_RealArray>
|
||||
RealArray;
|
||||
|
||||
typedef arrayT <integer, TDataStd_ByteArray, byteConverter>
|
||||
ByteArray;
|
||||
|
||||
typedef arrayT <persistent, TDataStd_ExtStringArray, stringConverter>
|
||||
ExtStringArray;
|
||||
|
||||
typedef arrayT <persistent, TDataStd_ReferenceArray, referenceConverter>
|
||||
ReferenceArray;
|
||||
|
||||
typedef listT <integer, TDataStd_IntegerList>
|
||||
IntegerList;
|
||||
|
||||
typedef listT <real, TDataStd_RealList>
|
||||
RealList;
|
||||
|
||||
typedef listT <integer, TDataStd_BooleanList>
|
||||
BooleanList;
|
||||
|
||||
typedef listT <persistent, TDataStd_ExtStringList, stringConverter>
|
||||
ExtStringList;
|
||||
|
||||
typedef listT <persistent, TDataStd_ReferenceList, referenceConverter>
|
||||
ReferenceList;
|
||||
|
||||
typedef mapT <integer, TDataStd_IntPackedMap>
|
||||
IntPackedMap;
|
||||
|
||||
typedef instance_1<IntegerArray> IntegerArray_1;
|
||||
typedef instance_1<RealArray> RealArray_1;
|
||||
typedef instance_1<ByteArray> ByteArray_1;
|
||||
typedef instance_1<ExtStringArray> ExtStringArray_1;
|
||||
typedef instance_1<IntPackedMap> IntPackedMap_1;
|
||||
};
|
||||
|
||||
#endif
|
@@ -11,53 +11,50 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdLPersistent_PDF_Data.hxx>
|
||||
|
||||
#include <StdLPersistent_Data.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
|
||||
|
||||
//! Create a transient label tree from persistent data
|
||||
class StdLPersistent_PDF_Data::Parser
|
||||
class StdLPersistent_Data::Parser
|
||||
{
|
||||
public:
|
||||
//! Start parsing a persistent data.
|
||||
Parser (const StdLPersistent_PDF_Data& theSource)
|
||||
: myLabelsIter (theSource.myLabels->Array())
|
||||
, myAttribIter (theSource.myAttributes->Array()) {}
|
||||
Parser (const TColStd_HArray1OfInteger& theLabels,
|
||||
const StdLPersistent_HArray1OfPersistent& theAttributes)
|
||||
: myLabelsIter (theLabels)
|
||||
, myAttribIter (theAttributes) {}
|
||||
|
||||
//! Fill a transient label with data.
|
||||
void FillLabel (TDF_Label theLabel)
|
||||
{
|
||||
Standard_Integer i;
|
||||
|
||||
// Read count of attributes
|
||||
// Read attributes count
|
||||
myLabelsIter.Next();
|
||||
Standard_Integer anAttribCount = myLabelsIter.Value();
|
||||
|
||||
// Add attributes to the label
|
||||
for (i = 0 ; i < anAttribCount; i++)
|
||||
for (i = 0; i < anAttribCount; i++)
|
||||
{
|
||||
// read persistent attribute
|
||||
const Handle(StdObjMgt_Persistent)& aPAttrib = myAttribIter.Value();
|
||||
Handle(StdObjMgt_Persistent)& aPAttrib = myAttribIter.ChangeValue();
|
||||
myAttribIter.Next();
|
||||
|
||||
// create transient attribute and add it to the label
|
||||
if (!aPAttrib.IsNull())
|
||||
{
|
||||
Handle(TDF_Attribute) aTAttrib = aPAttrib->ImportAttribute();
|
||||
if (!aTAttrib.IsNull())
|
||||
theLabel.AddAttribute (aTAttrib);
|
||||
}
|
||||
if (aPAttrib)
|
||||
theLabel.AddAttribute (aPAttrib->CreateAttribute());
|
||||
}
|
||||
|
||||
// Read count of child labels
|
||||
// Read child labels count
|
||||
myLabelsIter.Next();
|
||||
Standard_Integer aSubLabelsCount = myLabelsIter.Value();
|
||||
|
||||
// Create child labels
|
||||
for (i = 0 ; i < aSubLabelsCount; i++)
|
||||
for (i = 0; i < aSubLabelsCount; i++)
|
||||
{
|
||||
// read tag of child label
|
||||
myLabelsIter.Next();
|
||||
@@ -70,15 +67,15 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
NCollection_Array1<Standard_Integer >::Iterator myLabelsIter;
|
||||
NCollection_Array1<Handle(StdObjMgt_Persistent)>::Iterator myAttribIter;
|
||||
TColStd_HArray1OfInteger ::Iterator myLabelsIter;
|
||||
StdLPersistent_HArray1OfPersistent::Iterator myAttribIter;
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDF_Data::Read (StdObjMgt_ReadData& theReadData)
|
||||
void StdLPersistent_Data::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myVersion >> myLabels >> myAttributes;
|
||||
}
|
||||
@@ -87,12 +84,23 @@ void StdLPersistent_PDF_Data::Read (StdObjMgt_ReadData& theReadData)
|
||||
//function : Import
|
||||
//purpose : Import transient data from the persistent data
|
||||
//=======================================================================
|
||||
Handle(TDF_Data) StdLPersistent_PDF_Data::Import() const
|
||||
Handle(TDF_Data) StdLPersistent_Data::Import() const
|
||||
{
|
||||
if (myLabels.IsNull() || myAttributes.IsNull())
|
||||
return NULL;
|
||||
|
||||
// Create tree of labels and add empty transient attributes to them
|
||||
Handle(TDF_Data) aData = new TDF_Data;
|
||||
Parser (*this).FillLabel (aData->Root());
|
||||
Parser (*myLabels->Array(), *myAttributes->Array()).FillLabel (aData->Root());
|
||||
|
||||
// Import transient attribuites from persistent data
|
||||
StdLPersistent_HArray1OfPersistent::Iterator anAttribIter (*myAttributes->Array());
|
||||
for (; anAttribIter.More(); anAttribIter.Next())
|
||||
{
|
||||
Handle(StdObjMgt_Persistent)& aPAttrib = anAttribIter.ChangeValue();
|
||||
if (aPAttrib)
|
||||
aPAttrib->ImportAttribute();
|
||||
}
|
||||
|
||||
return aData;
|
||||
}
|
@@ -12,17 +12,16 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef _StdLPersistent_PDF_Data_HeaderFile
|
||||
#define _StdLPersistent_PDF_Data_HeaderFile
|
||||
#ifndef _StdLPersistent_Data_HeaderFile
|
||||
#define _StdLPersistent_Data_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
#include <StdLPersistent_PColStd_HArray1.hxx>
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
|
||||
class TDF_Data;
|
||||
|
||||
|
||||
class StdLPersistent_PDF_Data : public StdObjMgt_Persistent
|
||||
class StdLPersistent_Data : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
@@ -35,9 +34,9 @@ private:
|
||||
class Parser;
|
||||
|
||||
private:
|
||||
Standard_Integer myVersion;
|
||||
Handle(StdLPersistent_PColStd_HArray1OfInteger) myLabels;
|
||||
Handle(StdLPersistent_PDF_HAttributeArray1) myAttributes;
|
||||
Value <Standard_Integer> myVersion;
|
||||
Reference <StdLPersistent_HArray1::Integer> myLabels;
|
||||
Reference <StdLPersistent_HArray1::Persistent> myAttributes;
|
||||
};
|
||||
|
||||
#endif
|
51
src/StdLPersistent/StdLPersistent_Dependency.cxx
Normal file
51
src/StdLPersistent/StdLPersistent_Dependency.cxx
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_Dependency.hxx>
|
||||
|
||||
|
||||
static void ImportName (const Handle(TDataStd_Expression)& theAttribute,
|
||||
const TCollection_ExtendedString& theName)
|
||||
{ theAttribute->SetExpression (theName); }
|
||||
|
||||
static void ImportName (const Handle(TDataStd_Relation)& theAttribute,
|
||||
const TCollection_ExtendedString& theName)
|
||||
{ theAttribute->SetRelation (theName); }
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template <class AttribClass>
|
||||
void StdLPersistent_Dependency::instance<AttribClass>::Import
|
||||
(const Handle(AttribClass)& theAttribute) const
|
||||
{
|
||||
if (myName)
|
||||
ImportName (theAttribute, myName->Value()->String());
|
||||
|
||||
if (myVariables)
|
||||
{
|
||||
StdLPersistent_HArray1OfPersistent::Iterator anIter (*myVariables->Array());
|
||||
for (; anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(StdObjMgt_Persistent) aPersistent = anIter.Value();
|
||||
if (aPersistent)
|
||||
theAttribute->GetVariables().Append (aPersistent->GetAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_Dependency::instance<TDataStd_Expression>;
|
||||
template class StdLPersistent_Dependency::instance<TDataStd_Relation>;
|
49
src/StdLPersistent/StdLPersistent_Dependency.hxx
Normal file
49
src/StdLPersistent/StdLPersistent_Dependency.hxx
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_Dependency_HeaderFile
|
||||
#define _StdLPersistent_Dependency_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLPersistent_HString.hxx>
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
|
||||
#include <TDataStd_Expression.hxx>
|
||||
#include <TDataStd_Relation.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Dependency
|
||||
{
|
||||
template <class AttribClass>
|
||||
class instance : public StdObjMgt_Attribute<AttribClass>
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myName >> myVariables; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(AttribClass)& theAttribute) const;
|
||||
|
||||
private:
|
||||
StdObjMgt_ContentTypes::Reference<StdLPersistent_HString::Extended> myName;
|
||||
StdObjMgt_ContentTypes::Reference<StdLPersistent_HArray1::Persistent> myVariables;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TDataStd_Expression> Expression;
|
||||
typedef instance<TDataStd_Relation> Relation;
|
||||
};
|
||||
|
||||
#endif
|
@@ -11,19 +11,19 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdLPersistent_PDocStd_Document.hxx>
|
||||
#include <StdLPersistent_PDF_Data.hxx>
|
||||
|
||||
#include <StdLPersistent_Document.hxx>
|
||||
#include <StdLPersistent_Data.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDocStd_Owner.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDocStd_Document::Read (StdObjMgt_ReadData& theReadData)
|
||||
void StdLPersistent_Document::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myData;
|
||||
}
|
||||
@@ -32,13 +32,16 @@ void StdLPersistent_PDocStd_Document::Read (StdObjMgt_ReadData& theReadData)
|
||||
//function : Import
|
||||
//purpose : Import transient document from the persistent data
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDocStd_Document::Import (const Handle(CDM_Document)& theDocument) const
|
||||
void StdLPersistent_Document::ImportDocument
|
||||
(const Handle(TDocStd_Document)& theDocument) const
|
||||
{
|
||||
Handle(TDocStd_Document) aDocument = Handle(TDocStd_Document)::DownCast (theDocument);
|
||||
if (aDocument.IsNull() || myData.IsNull())
|
||||
if (theDocument.IsNull() || myData.IsNull())
|
||||
return;
|
||||
|
||||
Handle(TDF_Data) aData = myData->Import();
|
||||
aDocument->SetData (aData);
|
||||
TDocStd_Owner::SetDocument (aData, aDocument);
|
||||
if (aData.IsNull())
|
||||
return;
|
||||
|
||||
theDocument->SetData (aData);
|
||||
TDocStd_Owner::SetDocument (aData, theDocument);
|
||||
}
|
@@ -12,26 +12,27 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef _StdLPersistent_PDocStd_Document_HeaderFile
|
||||
#define _StdLPersistent_PDocStd_Document_HeaderFile
|
||||
#ifndef _StdLPersistent_Document_HeaderFile
|
||||
#define _StdLPersistent_Document_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
class CDM_Document;
|
||||
class StdLPersistent_PDF_Data;
|
||||
class TDocStd_Document;
|
||||
class StdLPersistent_Data;
|
||||
|
||||
|
||||
class StdLPersistent_PDocStd_Document : public StdObjMgt_Persistent
|
||||
class StdLPersistent_Document : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient document from the persistent data.
|
||||
Standard_EXPORT void Import (const Handle(CDM_Document)& theDocument) const;
|
||||
Standard_EXPORT virtual void ImportDocument
|
||||
(const Handle(TDocStd_Document)& theDocument) const;
|
||||
|
||||
private:
|
||||
Handle(StdLPersistent_PDF_Data) myData;
|
||||
Reference<StdLPersistent_Data> myData;
|
||||
};
|
||||
|
||||
#endif
|
43
src/StdLPersistent/StdLPersistent_Function.hxx
Normal file
43
src/StdLPersistent/StdLPersistent_Function.hxx
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_Function_HeaderFile
|
||||
#define _StdLPersistent_Function_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLObject_GUID.hxx>
|
||||
|
||||
#include <TFunction_Function.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Function : public StdObjMgt_Attribute<TFunction_Function>
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myDriverGUID >> myFailure; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TFunction_Function)& theAttribute) const
|
||||
{
|
||||
theAttribute->SetDriverGUID (myDriverGUID);
|
||||
theAttribute->SetFailure (myFailure);
|
||||
}
|
||||
|
||||
private:
|
||||
Object<StdLObject_GUID> myDriverGUID;
|
||||
Value<Standard_Integer> myFailure;
|
||||
};
|
||||
|
||||
#endif
|
@@ -11,27 +11,45 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdLPersistent_PColStd_HArray1Base.hxx>
|
||||
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PColStd_HArray1Base::Read (StdObjMgt_ReadData& theReadData)
|
||||
void StdLPersistent_HArray1::commonBase::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
Standard_Integer aLowerBound, anUpperBound;
|
||||
Value<Standard_Integer> aLowerBound, anUpperBound;
|
||||
theReadData >> aLowerBound >> anUpperBound;
|
||||
CreateArray (aLowerBound, anUpperBound);
|
||||
createArray (aLowerBound, anUpperBound);
|
||||
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData >> aSize;
|
||||
theReadData.ReadValue (aSize);
|
||||
|
||||
for (Standard_Integer i = aLowerBound; i <= anUpperBound; i++)
|
||||
ReadValue (theReadData, i);
|
||||
readValue (theReadData, i);
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
||||
|
||||
template <class ArrayClass, class ValueClass>
|
||||
void StdLPersistent_HArray1::instance<ArrayClass, ValueClass>::readValue (
|
||||
StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex)
|
||||
{
|
||||
ValueClass aValue;
|
||||
theReadData >> aValue;
|
||||
this->myArray->SetValue (theIndex, static_cast<typename ArrayClass::value_type> (aValue));
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfInteger>;
|
||||
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfReal>;
|
||||
template class StdLPersistent_HArray1::instance<TColStd_HArray1OfByte,
|
||||
StdObjMgt_ContentTypes::Value<Standard_Character> >;
|
||||
template class StdLPersistent_HArray1::instance<StdLPersistent_HArray1OfPersistent,
|
||||
StdObjMgt_ContentTypes::Reference<> >;
|
83
src/StdLPersistent/StdLPersistent_HArray1.hxx
Normal file
83
src/StdLPersistent/StdLPersistent_HArray1.hxx
Normal file
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_HArray1_HeaderFile
|
||||
#define _StdLPersistent_HArray1_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdLPersistent_HArray1OfPersistent.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
|
||||
class TCollection_HExtendedString;
|
||||
class TDF_Label;
|
||||
class TDF_Data;
|
||||
|
||||
|
||||
class StdLPersistent_HArray1 : protected StdObjMgt_ContentTypes
|
||||
{
|
||||
class commonBase : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
protected:
|
||||
virtual void createArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound) = 0;
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex) = 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
template <class ArrayClass>
|
||||
class base : public commonBase
|
||||
{
|
||||
public:
|
||||
typedef Handle(ArrayClass) ArrayHandle;
|
||||
typedef typename ArrayClass::value_type ValueType;
|
||||
typedef typename ArrayClass::Iterator Iterator;
|
||||
|
||||
public:
|
||||
//! Get the array.
|
||||
const Handle(ArrayClass)& Array() const { return myArray; }
|
||||
|
||||
protected:
|
||||
virtual void createArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound)
|
||||
{ myArray = new ArrayClass (theLowerBound, theUpperBound); }
|
||||
|
||||
protected:
|
||||
Handle(ArrayClass) myArray;
|
||||
};
|
||||
|
||||
private:
|
||||
template <class ArrayClass, class ValueClass = Value<typename ArrayClass::value_type> >
|
||||
class instance : public base<ArrayClass>
|
||||
{
|
||||
protected:
|
||||
Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex);
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TColStd_HArray1OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray1OfReal> Real;
|
||||
typedef instance<TColStd_HArray1OfByte, Value<Standard_Character> >Byte;
|
||||
typedef instance<StdLPersistent_HArray1OfPersistent, Reference<> > Persistent;
|
||||
};
|
||||
|
||||
#endif
|
@@ -11,24 +11,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _StdLPersistent_HArray1OfPersistent_HeaderFile
|
||||
#define _StdLPersistent_HArray1OfPersistent_HeaderFile
|
||||
|
||||
#ifndef _StdLPersistent_PDataStd_Integer_HeaderFile
|
||||
#define _StdLPersistent_PDataStd_Integer_HeaderFile
|
||||
|
||||
#include <NCollection_DefineHArray1.hxx>
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
DEFINE_HARRAY1 (StdLPersistent_HArray1OfPersistent,
|
||||
NCollection_Array1<Handle(StdObjMgt_Persistent)>)
|
||||
|
||||
class StdLPersistent_PDataStd_Integer : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
|
||||
|
||||
private:
|
||||
Standard_Integer myValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // _StdLPersistent_HArray1OfPersistent_HeaderFile
|
56
src/StdLPersistent/StdLPersistent_HArray2.cxx
Normal file
56
src/StdLPersistent/StdLPersistent_HArray2.cxx
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_HArray2.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TColStd_HArray2OfInteger.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_HArray2::commonBase::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
Value<Standard_Integer> aLowerRow, aLowerCol, anUpperRow, anUpperCol;
|
||||
theReadData >> aLowerRow >> aLowerCol >> anUpperRow >> anUpperCol;
|
||||
createArray (aLowerRow, aLowerCol, anUpperRow, anUpperCol);
|
||||
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData.ReadValue (aSize);
|
||||
|
||||
for (Standard_Integer aRow = aLowerRow; aRow <= anUpperRow; aRow++)
|
||||
for (Standard_Integer aCol = aLowerCol; aCol <= anUpperCol; aCol++)
|
||||
readValue (theReadData, aRow, aCol);
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
||||
|
||||
template <class ArrayClass>
|
||||
void StdLPersistent_HArray2::instance<ArrayClass>::readValue (
|
||||
StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol)
|
||||
{
|
||||
typename ArrayClass::value_type aValue;
|
||||
theReadData.ReadValue (aValue);
|
||||
this->myArray->SetValue (theRow, theCol, aValue);
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_HArray2::instance<TColStd_HArray2OfInteger>;
|
||||
template class StdLPersistent_HArray2::instance<TColStd_HArray2OfReal>;
|
82
src/StdLPersistent/StdLPersistent_HArray2.hxx
Normal file
82
src/StdLPersistent/StdLPersistent_HArray2.hxx
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_HArray2_HeaderFile
|
||||
#define _StdLPersistent_HArray2_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
#include <TColStd_HArray2OfInteger.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_HArray2
|
||||
{
|
||||
class commonBase : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
protected:
|
||||
virtual void createArray (
|
||||
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
|
||||
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
|
||||
= 0;
|
||||
|
||||
virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol) = 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
template <class ArrayClass>
|
||||
class base : public commonBase
|
||||
{
|
||||
public:
|
||||
typedef Handle(ArrayClass) ArrayHandle;
|
||||
|
||||
public:
|
||||
//! Get the array.
|
||||
const Handle(ArrayClass)& Array() const { return myArray; }
|
||||
|
||||
protected:
|
||||
virtual void createArray (
|
||||
const Standard_Integer theLowerRow, const Standard_Integer theLowerCol,
|
||||
const Standard_Integer theUpperRow, const Standard_Integer theUpperCol)
|
||||
{
|
||||
myArray = new ArrayClass (theLowerRow, theUpperRow,
|
||||
theLowerCol, theUpperCol);
|
||||
}
|
||||
|
||||
protected:
|
||||
Handle(ArrayClass) myArray;
|
||||
};
|
||||
|
||||
private:
|
||||
template <class ArrayClass>
|
||||
class instance : public base<ArrayClass>
|
||||
{
|
||||
protected:
|
||||
Standard_EXPORT virtual void readValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theRow,
|
||||
const Standard_Integer theCol);
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TColStd_HArray2OfInteger> Integer;
|
||||
typedef instance<TColStd_HArray2OfReal> Real;
|
||||
};
|
||||
|
||||
#endif
|
81
src/StdLPersistent/StdLPersistent_HString.cxx
Normal file
81
src/StdLPersistent/StdLPersistent_HString.cxx
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_HString.hxx>
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
template <class StringClass, typename CharType>
|
||||
void StdLPersistent_HString::instance<StringClass, CharType>::Read
|
||||
(StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData.ReadValue (aSize);
|
||||
myValue = new StringClass (aSize, 0);
|
||||
|
||||
for (Standard_Integer i = 1; i <= aSize; i++)
|
||||
{
|
||||
CharType aChar;
|
||||
theReadData.ReadValue (aChar);
|
||||
myValue->SetValue (i, aChar);
|
||||
}
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Label
|
||||
//purpose : Get/create a label defined by referenced string
|
||||
//=======================================================================
|
||||
template <class StringClass, typename CharType>
|
||||
TDF_Label StdLPersistent_HString::instance<StringClass, CharType>::Label
|
||||
(const Handle(TDF_Data)& theDF) const
|
||||
{
|
||||
TDF_Label aLabel;
|
||||
|
||||
if (!myValue.IsNull())
|
||||
TDF_Tool::Label (theDF, myValue->String(), aLabel, Standard_True);
|
||||
|
||||
return aLabel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AsciiString
|
||||
//purpose : Get referenced ASCII string
|
||||
//=======================================================================
|
||||
Handle(TCollection_HAsciiString)
|
||||
StdLPersistent_HString::Ascii::AsciiString() const
|
||||
{ return myValue; }
|
||||
|
||||
//=======================================================================
|
||||
//function : ExtString
|
||||
//purpose : Get referenced extended string
|
||||
//=======================================================================
|
||||
Handle(TCollection_HExtendedString)
|
||||
StdLPersistent_HString::Extended::ExtString() const
|
||||
{ return myValue; }
|
||||
|
||||
|
||||
template class StdLPersistent_HString::instance
|
||||
<TCollection_HAsciiString, Standard_Character>;
|
||||
|
||||
template class StdLPersistent_HString::instance
|
||||
<TCollection_HExtendedString, Standard_ExtCharacter>;
|
62
src/StdLPersistent/StdLPersistent_HString.hxx
Normal file
62
src/StdLPersistent/StdLPersistent_HString.hxx
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_HString_HeaderFile
|
||||
#define _StdLPersistent_HString_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_HString
|
||||
{
|
||||
template <class StringClass, typename CharType>
|
||||
class instance : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Get/create a label defined by referenced string.
|
||||
Standard_EXPORT virtual TDF_Label Label (const Handle(TDF_Data)& theDF) const;
|
||||
|
||||
//! Get the value.
|
||||
const Handle(StringClass)& Value() const { return myValue; }
|
||||
|
||||
protected:
|
||||
Handle(StringClass) myValue;
|
||||
};
|
||||
|
||||
public:
|
||||
class Ascii
|
||||
: public instance<TCollection_HAsciiString, Standard_Character>
|
||||
{
|
||||
public:
|
||||
//! Get referenced ASCII string.
|
||||
Standard_EXPORT virtual Handle(TCollection_HAsciiString) AsciiString() const;
|
||||
};
|
||||
|
||||
class Extended
|
||||
: public instance<TCollection_HExtendedString, Standard_ExtCharacter>
|
||||
{
|
||||
public:
|
||||
//! Get referenced extended string.
|
||||
Standard_EXPORT virtual Handle(TCollection_HExtendedString) ExtString() const;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
137
src/StdLPersistent/StdLPersistent_NamedData.cxx
Normal file
137
src/StdLPersistent/StdLPersistent_NamedData.cxx
Normal file
@@ -0,0 +1,137 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_NamedData.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
#include <TColStd_DataMapOfStringInteger.hxx>
|
||||
#include <TDataStd_DataMapOfStringReal.hxx>
|
||||
#include <TDataStd_DataMapOfStringString.hxx>
|
||||
#include <TDataStd_DataMapOfStringByte.hxx>
|
||||
#include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
|
||||
#include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Import
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
void StdLPersistent_NamedData::Import
|
||||
(const Handle(TDataStd_NamedData)& theAttribute) const
|
||||
{
|
||||
if (myDimensions.IsNull())
|
||||
return;
|
||||
|
||||
if (myInts)
|
||||
{
|
||||
TColStd_DataMapOfStringInteger aMap;
|
||||
for (Standard_Integer i = lower(0); i <= upper(0); i++)
|
||||
{
|
||||
Standard_Integer aValue = 0;
|
||||
aMap.Bind (myInts.Get (i, aValue), aValue);
|
||||
}
|
||||
theAttribute->ChangeIntegers (aMap);
|
||||
}
|
||||
|
||||
if (myReals)
|
||||
{
|
||||
TDataStd_DataMapOfStringReal aMap;
|
||||
for (Standard_Integer i = lower(1); i <= upper(1); i++)
|
||||
{
|
||||
Standard_Real aValue = 0.0;
|
||||
aMap.Bind (myReals.Get (i, aValue), aValue);
|
||||
}
|
||||
theAttribute->ChangeReals (aMap);
|
||||
}
|
||||
|
||||
if (myStrings)
|
||||
{
|
||||
TDataStd_DataMapOfStringString aMap;
|
||||
for (Standard_Integer i = lower(2); i <= upper(2); i++)
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aValue;
|
||||
aMap.Bind (myStrings.Get (i, aValue),
|
||||
aValue ? aValue->ExtString()->String()
|
||||
: TCollection_ExtendedString());
|
||||
}
|
||||
theAttribute->ChangeStrings (aMap);
|
||||
}
|
||||
|
||||
if (myBytes)
|
||||
{
|
||||
TDataStd_DataMapOfStringByte aMap;
|
||||
for (Standard_Integer i = lower(3); i <= upper(3); i++)
|
||||
{
|
||||
Standard_Byte aValue = 0;
|
||||
aMap.Bind (myBytes.Get (i, aValue), aValue);
|
||||
}
|
||||
theAttribute->ChangeBytes (aMap);
|
||||
}
|
||||
|
||||
if (myIntArrays)
|
||||
{
|
||||
TDataStd_DataMapOfStringHArray1OfInteger aMap;
|
||||
for (Standard_Integer i = lower(4); i <= upper(4); i++)
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aValue;
|
||||
const TCollection_ExtendedString& aKey = myIntArrays.Get (i, aValue);
|
||||
|
||||
Handle(StdLPersistent_HArray1::Integer) aPArray =
|
||||
Handle(StdLPersistent_HArray1::Integer)::DownCast (aValue);
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) aTArray;
|
||||
if (aPArray)
|
||||
aTArray = aPArray->Array();
|
||||
|
||||
aMap.Bind (aKey, aTArray);
|
||||
}
|
||||
theAttribute->ChangeArraysOfIntegers (aMap);
|
||||
}
|
||||
|
||||
if (myRealArrays)
|
||||
{
|
||||
TDataStd_DataMapOfStringHArray1OfReal aMap;
|
||||
for (Standard_Integer i = lower(5); i <= upper(5); i++)
|
||||
{
|
||||
Handle(StdObjMgt_Persistent) aValue;
|
||||
const TCollection_ExtendedString& aKey = myRealArrays.Get (i, aValue);
|
||||
|
||||
Handle(StdLPersistent_HArray1::Real) aPArray =
|
||||
Handle(StdLPersistent_HArray1::Real)::DownCast (aValue);
|
||||
|
||||
Handle(TColStd_HArray1OfReal) aTArray;
|
||||
if (aPArray)
|
||||
aTArray = aPArray->Array();
|
||||
|
||||
aMap.Bind (aKey, aTArray);
|
||||
}
|
||||
theAttribute->ChangeArraysOfReals (aMap);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer
|
||||
StdLPersistent_NamedData::lower (Standard_Integer theIndex) const
|
||||
{
|
||||
const Handle(TColStd_HArray2OfInteger)& aDimensions = myDimensions->Array();
|
||||
return aDimensions->Value (aDimensions->LowerRow() + theIndex,
|
||||
aDimensions->LowerCol());
|
||||
}
|
||||
|
||||
Standard_Integer
|
||||
StdLPersistent_NamedData::upper (Standard_Integer theIndex) const
|
||||
{
|
||||
const Handle(TColStd_HArray2OfInteger)& aDimensions = myDimensions->Array();
|
||||
return aDimensions->Value (aDimensions->LowerRow() + theIndex,
|
||||
aDimensions->UpperCol());
|
||||
}
|
76
src/StdLPersistent/StdLPersistent_NamedData.hxx
Normal file
76
src/StdLPersistent/StdLPersistent_NamedData.hxx
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_NamedData_HeaderFile
|
||||
#define _StdLPersistent_NamedData_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLPersistent_HArray1.hxx>
|
||||
#include <StdLPersistent_HArray2.hxx>
|
||||
|
||||
#include <TDataStd_NamedData.hxx>
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
class StdLPersistent_NamedData : public StdObjMgt_Attribute<TDataStd_NamedData>
|
||||
{
|
||||
template <class HValuesArray>
|
||||
class element
|
||||
{
|
||||
public:
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myKeys >> myValues; }
|
||||
|
||||
inline operator bool() const
|
||||
{ return ! myKeys.IsNull(); }
|
||||
|
||||
template <class Value>
|
||||
inline const TCollection_ExtendedString& Get
|
||||
(Standard_Integer theIndex, Value& theValue) const
|
||||
{
|
||||
if (myValues)
|
||||
theValue = myValues->Array()->Value(theIndex);
|
||||
return myKeys->Array()->Value(theIndex)->ExtString()->String();
|
||||
}
|
||||
|
||||
private:
|
||||
Reference <StdLPersistent_HArray1::Persistent> myKeys;
|
||||
Reference <HValuesArray> myValues;
|
||||
};
|
||||
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myDimensions >>
|
||||
myInts >> myReals >> myStrings >> myBytes >> myIntArrays >> myRealArrays;
|
||||
}
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataStd_NamedData)& theAttribute) const;
|
||||
|
||||
private:
|
||||
inline Standard_Integer lower (Standard_Integer theIndex) const;
|
||||
inline Standard_Integer upper (Standard_Integer theIndex) const;
|
||||
|
||||
private:
|
||||
Reference <StdLPersistent_HArray2::Integer> myDimensions;
|
||||
Object <element<StdLPersistent_HArray1::Integer> > myInts;
|
||||
Object <element<StdLPersistent_HArray1::Real> > myReals;
|
||||
Object <element<StdLPersistent_HArray1::Persistent> > myStrings;
|
||||
Object <element<StdLPersistent_HArray1::Byte> > myBytes;
|
||||
Object <element<StdLPersistent_HArray1::Persistent> > myIntArrays;
|
||||
Object <element<StdLPersistent_HArray1::Persistent> > myRealArrays;
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,62 +0,0 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_PColStd_HArray1_HeaderFile
|
||||
#define _StdLPersistent_PColStd_HArray1_HeaderFile
|
||||
|
||||
#include <StdLPersistent_PColStd_HArray1Base.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
class StdObjMgt_Persistent;
|
||||
|
||||
|
||||
template <class Type>
|
||||
class StdLPersistent_PColStd_HArray1 : public StdLPersistent_PColStd_HArray1Base
|
||||
{
|
||||
public:
|
||||
//! Get the value.
|
||||
const NCollection_Array1<Type>& Array() const { return *myArray; }
|
||||
|
||||
protected:
|
||||
virtual void CreateArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound)
|
||||
{
|
||||
myArray = new NCollection_Array1<Type> (theLowerBound, theUpperBound);
|
||||
}
|
||||
|
||||
virtual void ReadValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex)
|
||||
{
|
||||
Type aValue;
|
||||
theReadData >> aValue;
|
||||
myArray->SetValue (theIndex, aValue);
|
||||
}
|
||||
|
||||
private:
|
||||
NCollection_Handle<NCollection_Array1<Type>> myArray;
|
||||
};
|
||||
|
||||
typedef StdLPersistent_PColStd_HArray1<Standard_Integer>
|
||||
StdLPersistent_PColStd_HArray1OfInteger;
|
||||
|
||||
typedef StdLPersistent_PColStd_HArray1<Handle(StdObjMgt_Persistent)>
|
||||
StdLPersistent_PDF_HAttributeArray1;
|
||||
|
||||
#endif
|
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_PColStd_HArray1Base_HeaderFile
|
||||
#define _StdLPersistent_PColStd_HArray1Base_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_PColStd_HArray1Base : public StdObjMgt_Persistent
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
protected:
|
||||
virtual void CreateArray (const Standard_Integer theLowerBound,
|
||||
const Standard_Integer theUpperBound) = 0;
|
||||
|
||||
virtual void ReadValue (StdObjMgt_ReadData& theReadData,
|
||||
const Standard_Integer theIndex) = 0;
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,40 +0,0 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_PCollection_HExtendedString.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PCollection_HExtendedString::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData.Driver().BeginReadObjectData();
|
||||
|
||||
Standard_Integer aSize;
|
||||
theReadData >> aSize;
|
||||
myValue = new TCollection_HExtendedString (aSize, 0);
|
||||
|
||||
for (Standard_Integer i = 1; i <= aSize; i++)
|
||||
{
|
||||
Standard_ExtCharacter aChar;
|
||||
theReadData >> aChar;
|
||||
myValue->SetValue (i, aChar);
|
||||
}
|
||||
|
||||
theReadData.Driver().EndReadObjectData();
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_PDataStd_Integer.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TDataStd_Integer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDataStd_Integer::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myValue;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_PDataStd_Integer::ImportAttribute() const
|
||||
{
|
||||
Handle(TDataStd_Integer) aValue = new TDataStd_Integer;
|
||||
aValue->Set (myValue);
|
||||
return aValue;
|
||||
}
|
@@ -12,25 +12,32 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef _StdLPersistent_PDataStd_Name_HeaderFile
|
||||
#define _StdLPersistent_PDataStd_Name_HeaderFile
|
||||
#ifndef _StdLPersistent_Real_HeaderFile
|
||||
#define _StdLPersistent_Real_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
|
||||
class StdLPersistent_PCollection_HExtendedString;
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_RealEnum.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_PDataStd_Name : public StdObjMgt_Persistent
|
||||
class StdLPersistent_Real : public StdObjMgt_Attribute<TDataStd_Real>
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myValue >> myDimension; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) ImportAttribute() const;
|
||||
void Import (const Handle(TDataStd_Real)& theAttribute) const
|
||||
{
|
||||
theAttribute->Set (myValue);
|
||||
theAttribute->SetDimension (myDimension);
|
||||
}
|
||||
|
||||
private:
|
||||
Handle(StdLPersistent_PCollection_HExtendedString) myString;
|
||||
Value<Standard_Real> myValue;
|
||||
Enum<TDataStd_RealEnum> myDimension;
|
||||
};
|
||||
|
||||
#endif
|
@@ -11,33 +11,48 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <StdLPersistent_PDataStd_Name.hxx>
|
||||
#include <StdLPersistent_PCollection_HExtendedString.hxx>
|
||||
#include <StdLPersistent_TreeNode.hxx>
|
||||
|
||||
#include <StdObjMgt_ReadData.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read persistent data from a file
|
||||
//=======================================================================
|
||||
void StdLPersistent_PDataStd_Name::Read (StdObjMgt_ReadData& theReadData)
|
||||
void StdLPersistent_TreeNode::Read (StdObjMgt_ReadData& theReadData)
|
||||
{
|
||||
theReadData >> myString;
|
||||
myDynamicData = new dynamic;
|
||||
theReadData >> myDynamicData->First >> myNext >> myDynamicData->TreeID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CreateAttribute
|
||||
//purpose : Create an empty transient attribuite
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_TreeNode::CreateAttribute()
|
||||
{
|
||||
Static::CreateAttribute();
|
||||
myTransient->SetTreeID (myDynamicData->TreeID);
|
||||
return myTransient;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_PDataStd_Name::ImportAttribute() const
|
||||
void StdLPersistent_TreeNode::ImportAttribute()
|
||||
{
|
||||
if (myString.IsNull() || myString->Value().IsNull())
|
||||
return NULL;
|
||||
if (myDynamicData)
|
||||
{
|
||||
Handle(StdLPersistent_TreeNode) aChild = myDynamicData->First;
|
||||
while (aChild)
|
||||
{
|
||||
if (aChild->myTransient)
|
||||
myTransient->Append(aChild->myTransient);
|
||||
StdLPersistent_TreeNode* aCurr = aChild.get();
|
||||
aChild = aChild->myNext;
|
||||
aCurr->myNext.Nullify(); // this reference is no longer needed
|
||||
}
|
||||
|
||||
Handle(TDataStd_Name) aName = new TDataStd_Name;
|
||||
aName->Set (myString->Value()->String());
|
||||
return aName;
|
||||
myDynamicData.Nullify();
|
||||
}
|
||||
}
|
@@ -12,25 +12,37 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef _StdLPersistent_PCollection_HExtendedString_HeaderFile
|
||||
#define _StdLPersistent_PCollection_HExtendedString_HeaderFile
|
||||
#ifndef _StdLPersistent_TreeNode_HeaderFile
|
||||
#define _StdLPersistent_TreeNode_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Persistent.hxx>
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLObject_GUID.hxx>
|
||||
|
||||
class TCollection_HExtendedString;
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_PCollection_HExtendedString : public StdObjMgt_Persistent
|
||||
class StdLPersistent_TreeNode
|
||||
: public StdObjMgt_Attribute<TDataStd_TreeNode>::Static
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
|
||||
|
||||
//! Get the value.
|
||||
Handle(TCollection_HExtendedString) Value() const { return myValue; }
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual void ImportAttribute();
|
||||
|
||||
private:
|
||||
Handle(TCollection_HExtendedString) myValue;
|
||||
struct dynamic : public Standard_Transient
|
||||
{
|
||||
Reference <StdLPersistent_TreeNode> First;
|
||||
Object <StdLObject_GUID> TreeID;
|
||||
};
|
||||
|
||||
Handle(dynamic) myDynamicData;
|
||||
Reference<StdLPersistent_TreeNode> myNext;
|
||||
};
|
||||
|
||||
#endif
|
97
src/StdLPersistent/StdLPersistent_Value.cxx
Normal file
97
src/StdLPersistent/StdLPersistent_Value.cxx
Normal file
@@ -0,0 +1,97 @@
|
||||
// Copyright (c) 2015 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 <StdLPersistent_Value.hxx>
|
||||
|
||||
#include <TCollection_HExtendedString.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template <class AttribClass>
|
||||
void StdLPersistent_Value::integer<AttribClass>::ImportAttribute()
|
||||
{
|
||||
this->myTransient->Set (this->myData);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template <class AttribClass, class HStringClass>
|
||||
void StdLPersistent_Value::string<AttribClass, HStringClass>::ImportAttribute()
|
||||
{
|
||||
Handle(HStringClass) anHString;
|
||||
if (this->myData.Cast (anHString))
|
||||
{
|
||||
this->myTransient->Set (anHString->Value()->String());
|
||||
this->myData.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template<>
|
||||
void StdLPersistent_Value::string<TDF_Reference>::ImportAttribute()
|
||||
{
|
||||
if (this->myData)
|
||||
{
|
||||
TDF_Label aLabel = myData->Label (this->myTransient->Label().Data());
|
||||
if (!aLabel.IsNull())
|
||||
this->myTransient->Set (aLabel);
|
||||
this->myData.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ImportAttribute
|
||||
//purpose : Import transient attribuite from the persistent data
|
||||
//=======================================================================
|
||||
template<>
|
||||
void StdLPersistent_Value::string<TDataStd_UAttribute>::ImportAttribute()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : CreateAttribute
|
||||
//purpose : Create an empty transient attribuite
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) StdLPersistent_Value::UAttribute::CreateAttribute()
|
||||
{
|
||||
string<TDataStd_UAttribute,StdLPersistent_HString::Extended>::CreateAttribute();
|
||||
|
||||
if (this->myData)
|
||||
{
|
||||
Handle(TCollection_HExtendedString) aString = this->myData->ExtString();
|
||||
if (aString)
|
||||
this->myTransient->SetID (Standard_GUID (aString->String().ToExtString()));
|
||||
this->myData.Nullify();
|
||||
}
|
||||
|
||||
return this->myTransient;
|
||||
}
|
||||
|
||||
|
||||
template class StdLPersistent_Value::integer <TDataStd_Integer>;
|
||||
template class StdLPersistent_Value::integer <TDF_TagSource>;
|
||||
|
||||
template class StdLPersistent_Value::string <TDF_Reference>;
|
||||
template class StdLPersistent_Value::string <TDataStd_UAttribute>;
|
||||
template class StdLPersistent_Value::string <TDataStd_Name>;
|
||||
template class StdLPersistent_Value::string <TDataStd_Comment>;
|
||||
template class StdLPersistent_Value::string <TDataStd_AsciiString,
|
||||
StdLPersistent_HString::Ascii>;
|
67
src/StdLPersistent/StdLPersistent_Value.hxx
Normal file
67
src/StdLPersistent/StdLPersistent_Value.hxx
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_Value_HeaderFile
|
||||
#define _StdLPersistent_Value_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLPersistent_HString.hxx>
|
||||
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <TDF_Reference.hxx>
|
||||
#include <TDataStd_UAttribute.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDataStd_Comment.hxx>
|
||||
#include <TDataStd_AsciiString.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Value
|
||||
{
|
||||
template <class AttribClass>
|
||||
class integer : public StdObjMgt_Attribute<AttribClass>::SingleInt
|
||||
{
|
||||
public:
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual void ImportAttribute();
|
||||
};
|
||||
|
||||
template <class AttribClass,
|
||||
class HStringClass = StdLPersistent_HString::Extended>
|
||||
class string : public StdObjMgt_Attribute<AttribClass>::SingleRef
|
||||
{
|
||||
public:
|
||||
//! Import transient attribuite from the persistent data.
|
||||
Standard_EXPORT virtual void ImportAttribute();
|
||||
};
|
||||
|
||||
public:
|
||||
typedef integer <TDataStd_Integer> Integer;
|
||||
typedef integer <TDF_TagSource> TagSource;
|
||||
|
||||
typedef string <TDF_Reference> Reference;
|
||||
typedef string <TDataStd_Name> Name;
|
||||
typedef string <TDataStd_Comment> Comment;
|
||||
typedef string <TDataStd_AsciiString,
|
||||
StdLPersistent_HString::Ascii> AsciiString;
|
||||
|
||||
class UAttribute : public string <TDataStd_UAttribute>
|
||||
{
|
||||
public:
|
||||
//! Create an empty transient attribuite
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) CreateAttribute();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
44
src/StdLPersistent/StdLPersistent_Variable.hxx
Normal file
44
src/StdLPersistent/StdLPersistent_Variable.hxx
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_Variable_HeaderFile
|
||||
#define _StdLPersistent_Variable_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLPersistent_HString.hxx>
|
||||
|
||||
#include <TDataStd_Variable.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Variable : public StdObjMgt_Attribute<TDataStd_Variable>
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myIsConstant >> myUnit; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDataStd_Variable)& theAttribute) const
|
||||
{
|
||||
theAttribute->Constant (myIsConstant);
|
||||
if (myUnit)
|
||||
theAttribute->Unit (myUnit->Value()->String());
|
||||
}
|
||||
|
||||
private:
|
||||
Value <Standard_Boolean> myIsConstant;
|
||||
Reference <StdLPersistent_HString::Ascii> myUnit;
|
||||
};
|
||||
|
||||
#endif
|
45
src/StdLPersistent/StdLPersistent_Void.hxx
Normal file
45
src/StdLPersistent/StdLPersistent_Void.hxx
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_Void_HeaderFile
|
||||
#define _StdLPersistent_Void_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
|
||||
#include <TDataStd_Directory.hxx>
|
||||
#include <TDataStd_Tick.hxx>
|
||||
#include <TDataStd_NoteBook.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_Void
|
||||
{
|
||||
protected:
|
||||
template <class AttribClass>
|
||||
class instance : public StdObjMgt_Attribute<AttribClass>::Static
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
Standard_EXPORT virtual void Read (StdObjMgt_ReadData&) {}
|
||||
|
||||
//! Import transient attribuite from the persistent data
|
||||
Standard_EXPORT virtual void ImportAttribute() {}
|
||||
};
|
||||
|
||||
public:
|
||||
typedef instance<TDataStd_Directory> Directory;
|
||||
typedef instance<TDataStd_Tick> Tick;
|
||||
typedef instance<TDataStd_NoteBook> NoteBook;
|
||||
};
|
||||
|
||||
#endif
|
46
src/StdLPersistent/StdLPersistent_XLink.hxx
Normal file
46
src/StdLPersistent/StdLPersistent_XLink.hxx
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2015 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 _StdLPersistent_XLink_HeaderFile
|
||||
#define _StdLPersistent_XLink_HeaderFile
|
||||
|
||||
#include <StdObjMgt_Attribute.hxx>
|
||||
#include <StdLPersistent_HString.hxx>
|
||||
|
||||
#include <TDocStd_XLink.hxx>
|
||||
|
||||
|
||||
class StdLPersistent_XLink : public StdObjMgt_Attribute<TDocStd_XLink>
|
||||
{
|
||||
public:
|
||||
//! Read persistent data from a file.
|
||||
inline void Read (StdObjMgt_ReadData& theReadData)
|
||||
{ theReadData >> myDocEntry >> myLabEntry; }
|
||||
|
||||
//! Import transient attribuite from the persistent data.
|
||||
void Import (const Handle(TDocStd_XLink)& theAttribute) const
|
||||
{
|
||||
if (myDocEntry)
|
||||
theAttribute->DocumentEntry (myDocEntry->Value()->String());
|
||||
|
||||
if (myLabEntry)
|
||||
theAttribute->LabelEntry (myLabEntry->Value()->String());
|
||||
}
|
||||
|
||||
private:
|
||||
Reference<StdLPersistent_HString::Ascii> myDocEntry;
|
||||
Reference<StdLPersistent_HString::Ascii> myLabEntry;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user