Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:59

0001 // Copyright (c) 2015 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 
0015 #ifndef _StdLPersistent_Collection_HeaderFile
0016 #define _StdLPersistent_Collection_HeaderFile
0017 
0018 #include <StdObjMgt_Attribute.hxx>
0019 #include <StdLPersistent_HArray1.hxx>
0020 
0021 #include <TDataStd_IntegerArray.hxx>
0022 #include <TDataStd_RealArray.hxx>
0023 #include <TDataStd_ByteArray.hxx>
0024 #include <TDataStd_ExtStringArray.hxx>
0025 #include <TDataStd_BooleanArray.hxx>
0026 #include <TDataStd_ReferenceArray.hxx>
0027 #include <TDataStd_IntegerList.hxx>
0028 #include <TDataStd_RealList.hxx>
0029 #include <TDataStd_ExtStringList.hxx>
0030 #include <TDataStd_BooleanList.hxx>
0031 #include <TDataStd_ReferenceList.hxx>
0032 #include <TDataStd_IntPackedMap.hxx>
0033 
0034 
0035 class StdLPersistent_Collection
0036 {
0037   // Converters
0038   struct noConversion;
0039   struct byteConverter;
0040   struct boolConverter;
0041   struct stringConverter;
0042   struct referenceConverter;
0043 
0044   // Base templates
0045   template <class Base>
0046   class booleanArrayBase : public Base
0047   {
0048   public:
0049     //! Empty constructor.
0050     booleanArrayBase()
0051     : myLower(0),
0052       myUpper(0)
0053     {
0054     }
0055 
0056     //! Read persistent data from a file.
0057     virtual void Read (StdObjMgt_ReadData& theReadData)
0058     {
0059       Base::Read (theReadData);
0060       theReadData >> myLower >> myUpper;
0061     }
0062 
0063   protected:
0064     template <class ArrayHandle, class Converter>
0065     inline void import (const ArrayHandle& theArray, Converter theConverter)
0066       const;
0067 
0068   protected:
0069     Standard_Integer myLower;
0070     Standard_Integer myUpper;
0071   };
0072 
0073   template <class Base>
0074   class directArrayBase : public Base
0075   {
0076   protected:
0077     template <class ArrayHandle, class Converter>
0078     inline void import (const ArrayHandle& theArray, Converter theConverter)
0079       const;
0080   };
0081 
0082   template <class Base>
0083   class arrayBase : public Base
0084   {
0085   protected:
0086     template <class ArrayHandle, class Converter>
0087     inline void import (const ArrayHandle& theArray, Converter theConverter)
0088       const;
0089   };
0090 
0091   template <class Base>
0092   class listBase : public Base
0093   {
0094   protected:
0095     template <class ArrayHandle, class Converter>
0096     inline void import (const ArrayHandle& theArray, Converter theConverter)
0097       const;
0098   };
0099 
0100   template <class Base>
0101   class mapBase : public Base
0102   {
0103   protected:
0104     template <class ArrayHandle, class Converter>
0105     inline void import (const ArrayHandle& theArray, Converter theConverter)
0106       const;
0107   };
0108 
0109   // Instance templates
0110   template <template<class> class BaseT,
0111             class HArrayClass,
0112             class AttribClass,
0113             class Converter>
0114   class instance
0115     : public BaseT <typename StdObjMgt_Attribute<AttribClass>::SingleRef>
0116   {
0117   public:
0118     //! Import transient attribute from the persistent data.
0119     Standard_EXPORT virtual void ImportAttribute();
0120   };
0121 
0122   template <class Instance>
0123   class instance_1 : public Instance
0124   {
0125   public:
0126     //! Empty constructor.
0127     instance_1()
0128     : myDelta(Standard_False)
0129     {
0130     }
0131 
0132     //! Read persistent data from a file.
0133     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
0134 
0135     //! Import transient attribute from the persistent data.
0136     Standard_EXPORT virtual void ImportAttribute();
0137 
0138   private:
0139     Standard_Boolean myDelta;
0140   };
0141 
0142 
0143   // Collection type specialization
0144   template<class HArrayClass, class AttribClass, class Converter = noConversion>
0145   struct booleanArrayT
0146     : instance<booleanArrayBase, HArrayClass, AttribClass, Converter> {};
0147 
0148   template<class HArrayClass, class AttribClass, class Converter = noConversion>
0149   struct directArrayT
0150     : instance<directArrayBase, HArrayClass, AttribClass, Converter> {};
0151 
0152   template<class HArrayClass, class AttribClass, class Converter = noConversion>
0153   struct arrayT
0154     : instance<arrayBase, HArrayClass, AttribClass, Converter> {};
0155 
0156   template<class HArrayClass, class AttribClass, class Converter = noConversion>
0157   struct listT
0158     : instance<listBase, HArrayClass, AttribClass, Converter> {};
0159 
0160   template<class HArrayClass, class AttribClass, class Converter = noConversion>
0161   struct mapT
0162     : instance<mapBase, HArrayClass, AttribClass, Converter> {};
0163 
0164 
0165   // Internal array types
0166   typedef StdLPersistent_HArray1::Integer    integer;
0167   typedef StdLPersistent_HArray1::Real       real;
0168   typedef StdLPersistent_HArray1::Persistent persistent;
0169 
0170 public:
0171   // Final specialization
0172   typedef booleanArrayT <integer, TDataStd_BooleanArray, byteConverter>
0173     BooleanArray;
0174 
0175   typedef directArrayT <integer, TDataStd_IntegerArray>
0176     IntegerArray;
0177 
0178   typedef directArrayT <real, TDataStd_RealArray>
0179     RealArray;
0180 
0181   typedef arrayT <integer, TDataStd_ByteArray, byteConverter>
0182     ByteArray;
0183 
0184   typedef arrayT <persistent, TDataStd_ExtStringArray, stringConverter>
0185     ExtStringArray;
0186 
0187   typedef arrayT <persistent, TDataStd_ReferenceArray, referenceConverter>
0188     ReferenceArray;
0189 
0190   typedef listT <integer, TDataStd_IntegerList>
0191     IntegerList;
0192 
0193   typedef listT <real, TDataStd_RealList>
0194     RealList;
0195 
0196   typedef listT <integer, TDataStd_BooleanList, boolConverter>
0197     BooleanList;
0198 
0199   typedef listT <persistent, TDataStd_ExtStringList, stringConverter>
0200     ExtStringList;
0201 
0202   typedef listT <persistent, TDataStd_ReferenceList, referenceConverter>
0203     ReferenceList;
0204 
0205   typedef mapT <integer, TDataStd_IntPackedMap>
0206     IntPackedMap;
0207 
0208   typedef instance_1<IntegerArray>    IntegerArray_1;
0209   typedef instance_1<RealArray>       RealArray_1;
0210   typedef instance_1<ByteArray>       ByteArray_1;
0211   typedef instance_1<ExtStringArray>  ExtStringArray_1;
0212   typedef instance_1<IntPackedMap>    IntPackedMap_1;
0213 };
0214 
0215 #endif