Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/StdLPersistent_Collection.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 #ifndef _StdLPersistent_Collection_HeaderFile
0015 #define _StdLPersistent_Collection_HeaderFile
0016 
0017 #include <StdObjMgt_Attribute.hxx>
0018 #include <StdLPersistent_HArray1.hxx>
0019 
0020 #include <TDataStd_IntegerArray.hxx>
0021 #include <TDataStd_RealArray.hxx>
0022 #include <TDataStd_ByteArray.hxx>
0023 #include <TDataStd_ExtStringArray.hxx>
0024 #include <TDataStd_BooleanArray.hxx>
0025 #include <TDataStd_ReferenceArray.hxx>
0026 #include <TDataStd_IntegerList.hxx>
0027 #include <TDataStd_RealList.hxx>
0028 #include <TDataStd_ExtStringList.hxx>
0029 #include <TDataStd_BooleanList.hxx>
0030 #include <TDataStd_ReferenceList.hxx>
0031 #include <TDataStd_IntPackedMap.hxx>
0032 
0033 class StdLPersistent_Collection
0034 {
0035   // Converters
0036   struct noConversion;
0037   struct byteConverter;
0038   struct boolConverter;
0039   struct stringConverter;
0040   struct referenceConverter;
0041 
0042   // Base templates
0043   template <class Base>
0044   class booleanArrayBase : public Base
0045   {
0046   public:
0047     //! Empty constructor.
0048     booleanArrayBase()
0049         : myLower(0),
0050           myUpper(0)
0051     {
0052     }
0053 
0054     //! Read persistent data from a file.
0055     void Read(StdObjMgt_ReadData& theReadData) override
0056     {
0057       Base::Read(theReadData);
0058       theReadData >> myLower >> myUpper;
0059     }
0060 
0061   protected:
0062     template <class ArrayHandle, class Converter>
0063     inline void import(const ArrayHandle& theArray, Converter theConverter) const;
0064 
0065   protected:
0066     int myLower;
0067     int myUpper;
0068   };
0069 
0070   template <class Base>
0071   class directArrayBase : public Base
0072   {
0073   protected:
0074     template <class ArrayHandle, class Converter>
0075     inline void import(const ArrayHandle& theArray, Converter theConverter) const;
0076   };
0077 
0078   template <class Base>
0079   class arrayBase : public Base
0080   {
0081   protected:
0082     template <class ArrayHandle, class Converter>
0083     inline void import(const ArrayHandle& theArray, Converter theConverter) const;
0084   };
0085 
0086   template <class Base>
0087   class listBase : public Base
0088   {
0089   protected:
0090     template <class ArrayHandle, class Converter>
0091     inline void import(const ArrayHandle& theArray, Converter theConverter) const;
0092   };
0093 
0094   template <class Base>
0095   class mapBase : public Base
0096   {
0097   protected:
0098     template <class ArrayHandle, class Converter>
0099     inline void import(const ArrayHandle& theArray, Converter theConverter) const;
0100   };
0101 
0102   // Instance templates
0103   template <template <class> class BaseT, class HArrayClass, class AttribClass, class Converter>
0104   class instance : public BaseT<typename StdObjMgt_Attribute<AttribClass>::SingleRef>
0105   {
0106   public:
0107     //! Import transient attribute from the persistent data.
0108     Standard_EXPORT void ImportAttribute() override;
0109   };
0110 
0111   template <class Instance>
0112   class instance_1 : public Instance
0113   {
0114   public:
0115     //! Empty constructor.
0116     instance_1()
0117         : myDelta(false)
0118     {
0119     }
0120 
0121     //! Read persistent data from a file.
0122     Standard_EXPORT void Read(StdObjMgt_ReadData& theReadData) override;
0123 
0124     //! Import transient attribute from the persistent data.
0125     Standard_EXPORT void ImportAttribute() override;
0126 
0127   private:
0128     bool myDelta;
0129   };
0130 
0131   // Collection type specialization
0132   template <class HArrayClass, class AttribClass, class Converter = noConversion>
0133   struct booleanArrayT : instance<booleanArrayBase, HArrayClass, AttribClass, Converter>
0134   {
0135   };
0136 
0137   template <class HArrayClass, class AttribClass, class Converter = noConversion>
0138   struct directArrayT : instance<directArrayBase, HArrayClass, AttribClass, Converter>
0139   {
0140   };
0141 
0142   template <class HArrayClass, class AttribClass, class Converter = noConversion>
0143   struct arrayT : instance<arrayBase, HArrayClass, AttribClass, Converter>
0144   {
0145   };
0146 
0147   template <class HArrayClass, class AttribClass, class Converter = noConversion>
0148   struct listT : instance<listBase, HArrayClass, AttribClass, Converter>
0149   {
0150   };
0151 
0152   template <class HArrayClass, class AttribClass, class Converter = noConversion>
0153   struct mapT : instance<mapBase, HArrayClass, AttribClass, Converter>
0154   {
0155   };
0156 
0157   // Internal array types
0158   typedef StdLPersistent_HArray1::Integer    integer;
0159   typedef StdLPersistent_HArray1::Real       real;
0160   typedef StdLPersistent_HArray1::Persistent persistent;
0161 
0162 public:
0163   // Final specialization
0164   typedef booleanArrayT<integer, TDataStd_BooleanArray, byteConverter> BooleanArray;
0165 
0166   typedef directArrayT<integer, TDataStd_IntegerArray> IntegerArray;
0167 
0168   typedef directArrayT<real, TDataStd_RealArray> RealArray;
0169 
0170   typedef arrayT<integer, TDataStd_ByteArray, byteConverter> ByteArray;
0171 
0172   typedef arrayT<persistent, TDataStd_ExtStringArray, stringConverter> ExtStringArray;
0173 
0174   typedef arrayT<persistent, TDataStd_ReferenceArray, referenceConverter> ReferenceArray;
0175 
0176   typedef listT<integer, TDataStd_IntegerList> IntegerList;
0177 
0178   typedef listT<real, TDataStd_RealList> RealList;
0179 
0180   typedef listT<integer, TDataStd_BooleanList, boolConverter> BooleanList;
0181 
0182   typedef listT<persistent, TDataStd_ExtStringList, stringConverter> ExtStringList;
0183 
0184   typedef listT<persistent, TDataStd_ReferenceList, referenceConverter> ReferenceList;
0185 
0186   typedef mapT<integer, TDataStd_IntPackedMap> IntPackedMap;
0187 
0188   typedef instance_1<IntegerArray>   IntegerArray_1;
0189   typedef instance_1<RealArray>      RealArray_1;
0190   typedef instance_1<ByteArray>      ByteArray_1;
0191   typedef instance_1<ExtStringArray> ExtStringArray_1;
0192   typedef instance_1<IntPackedMap>   IntPackedMap_1;
0193 };
0194 
0195 #endif