// 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 #include #include struct StdLPersistent_Collection::noConversion { noConversion (const Handle(TDF_Data)&) {} template 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 (theValue); } }; struct StdLPersistent_Collection::boolConverter { boolConverter (const Handle(TDF_Data)&) {} Standard_Boolean operator() (Standard_Integer theValue) const { return theValue != 0; } }; struct StdLPersistent_Collection::stringConverter { stringConverter (const Handle(TDF_Data)&) {} const TCollection_ExtendedString& operator() (const Handle(StdObjMgt_Persistent)& theValue) const { static TCollection_ExtendedString anEmptyString; if (theValue.IsNull()) return anEmptyString; Handle(TCollection_HExtendedString) aString = theValue->ExtString(); return aString ? aString->String() : 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 void StdLPersistent_Collection::booleanArrayBase::Read (StdObjMgt_ReadData& theReadData) { Base::Read (theReadData); theReadData >> myLower >> myUpper; } template template void StdLPersistent_Collection::booleanArrayBase::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 template void StdLPersistent_Collection::directArrayBase::import (const ArrayHandle& theArray, Converter) const { this->myTransient->ChangeArray (theArray); } template template void StdLPersistent_Collection::arrayBase::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 template void StdLPersistent_Collection::listBase::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 template void StdLPersistent_Collection::mapBase::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 class BaseT, class HArrayClass, class AttribClass, class Converter> void StdLPersistent_Collection:: instance::ImportAttribute() { Handle(HArrayClass) anHArray = Handle(HArrayClass)::DownCast (this->myData); if (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 void StdLPersistent_Collection::instance_1::Read (StdObjMgt_ReadData& theReadData) { Instance::Read (theReadData); theReadData >> myDelta; } //======================================================================= //function : ImportAttribute //purpose : Import transient attribuite from the persistent data //======================================================================= template void StdLPersistent_Collection::instance_1::ImportAttribute() { Instance::ImportAttribute(); this->myTransient->SetDelta (myDelta); } template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance ; template class StdLPersistent_Collection::instance_1 ; template class StdLPersistent_Collection::instance_1 ; template class StdLPersistent_Collection::instance_1 ; template class StdLPersistent_Collection::instance_1 ; template class StdLPersistent_Collection::instance_1 ;