0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / NCollection / NCollection_BaseSequence.hxx
CommitLineData
b311480e 1// Created on: 2002-04-10
2// Created by: Alexander KARTOMIN (akm)
973c2be1 3// Copyright (c) 2002-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#ifndef NCollection_BaseSequence_HeaderFile
17#define NCollection_BaseSequence_HeaderFile
18
19#include <Standard.hxx>
20#include <NCollection_BaseAllocator.hxx>
ddf2fe8e 21#include <NCollection_DefineAlloc.hxx>
7fd59977 22
23// **************************************** Class SeqNode ********************
24
25class NCollection_SeqNode
26{
ddf2fe8e 27public:
28 // define new operator for use with NCollection allocators
29 DEFINE_NCOLLECTION_ALLOC
30public:
79a35943 31 NCollection_SeqNode () : myNext (NULL), myPrevious (NULL) {}
32 NCollection_SeqNode * Next () const { return myNext; }
33 NCollection_SeqNode * Previous () const { return myPrevious; }
34 void SetNext (NCollection_SeqNode * theNext) { myNext = theNext; }
35 void SetPrevious (NCollection_SeqNode * thePrev) { myPrevious = thePrev; }
7fd59977 36
37 private:
79a35943 38 NCollection_SeqNode* myNext;
39 NCollection_SeqNode* myPrevious;
7fd59977 40};
41
42typedef void (* NCollection_DelSeqNode)
43 (NCollection_SeqNode*, Handle(NCollection_BaseAllocator)& theAl);
44
45/**
46 * Purpose: This is a base class for the Sequence. It deals with
47 * an indexed bidirectional list of NCollection_SeqNode's.
48 */
49class NCollection_BaseSequence
50{
ddf2fe8e 51public:
52 //! Memory allocation
53 DEFINE_STANDARD_ALLOC
54 DEFINE_NCOLLECTION_ALLOC
55
56public:
7fd59977 57 class Iterator
58 {
59 public:
60 //! Empty constructor
79a35943 61 Iterator (void) : myCurrent (NULL), myPrevious(NULL) {}
62
7fd59977 63 //! Constructor with initialisation
79a35943 64 Iterator (const NCollection_BaseSequence& theSeq,
65 const Standard_Boolean isStart)
66 {
67 Init (theSeq, isStart);
68 }
69
70 //! Initialisation
71 void Init (const NCollection_BaseSequence& theSeq,
72 const Standard_Boolean isStart = Standard_True)
73 {
74 myCurrent = (isStart ? theSeq.myFirstItem : NULL);
75 myPrevious = (isStart ? NULL : theSeq.myLastItem);
76 }
77
79a35943 78 //! Switch to previous element; note that it will reset
79 void Previous()
80 {
81 myCurrent = myPrevious;
82 if (myCurrent)
83 myPrevious = myCurrent->Previous();
84 }
7fd59977 85
86 protected:
79a35943 87 NCollection_SeqNode* myCurrent; //!< Pointer to the current node
88 NCollection_SeqNode* myPrevious; //!< Pointer to the previous node
7fd59977 89 friend class NCollection_BaseSequence;
90 };
91
92 public:
93 // Methods PUBLIC
94 //
95 Standard_Boolean IsEmpty () const {return (mySize == 0);}
96 Standard_Integer Length () const {return mySize;}
97
e1c1b6b9 98 //! Returns attached allocator
99 const Handle(NCollection_BaseAllocator)& Allocator() const
100 { return myAllocator; }
101
7fd59977 102 protected:
103 // Methods PROTECTED
104 //
ddf2fe8e 105 NCollection_BaseSequence (const Handle(NCollection_BaseAllocator)& theAllocator) :
106 myFirstItem (NULL),
107 myLastItem (NULL),
108 myCurrentItem (NULL),
109 myCurrentIndex (0),
110 mySize (0)
111 {
112 myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
113 }
114
6928e351 115 //! Destructor
116 virtual ~NCollection_BaseSequence() {}
117
ddf2fe8e 118 Standard_EXPORT void ClearSeq (NCollection_DelSeqNode fDel);
7fd59977 119 Standard_EXPORT void PAppend (NCollection_SeqNode *);
120 Standard_EXPORT void PAppend (NCollection_BaseSequence& S);
121 Standard_EXPORT void PPrepend (NCollection_SeqNode *);
122 Standard_EXPORT void PPrepend (NCollection_BaseSequence& S);
123 Standard_EXPORT void PInsertAfter(Iterator& thePosition,
124 NCollection_SeqNode *);
125 Standard_EXPORT void PInsertAfter(const Standard_Integer Index,
126 NCollection_SeqNode *);
127 Standard_EXPORT void PInsertAfter(const Standard_Integer Index,
128 NCollection_BaseSequence& S);
129 Standard_EXPORT void PSplit (const Standard_Integer Index,
130 NCollection_BaseSequence& Sub);
131 Standard_EXPORT void RemoveSeq (Iterator& thePosition,
ddf2fe8e 132 NCollection_DelSeqNode fDel);
7fd59977 133 Standard_EXPORT void RemoveSeq (const Standard_Integer Index,
ddf2fe8e 134 NCollection_DelSeqNode fDel);
7fd59977 135 Standard_EXPORT void RemoveSeq (const Standard_Integer From,
136 const Standard_Integer To,
ddf2fe8e 137 NCollection_DelSeqNode fDel);
7fd59977 138 Standard_EXPORT void PReverse ();
139 Standard_EXPORT void PExchange (const Standard_Integer I,
140 const Standard_Integer J) ;
79a35943 141 Standard_EXPORT NCollection_SeqNode *
7fd59977 142 Find (const Standard_Integer) const;
143
144 protected:
145 // Fields PROTECTED
146 //
ddf2fe8e 147 Handle(NCollection_BaseAllocator) myAllocator;
79a35943 148 NCollection_SeqNode* myFirstItem;
149 NCollection_SeqNode* myLastItem;
150 NCollection_SeqNode* myCurrentItem;
151 Standard_Integer myCurrentIndex;
152 Standard_Integer mySize;
7fd59977 153
154 private:
155 // Methods PRIVATE
156 //
157 Standard_EXPORT NCollection_BaseSequence
158 (const NCollection_BaseSequence& Other);
746cb7c3 159 void Nullify()
160 {
161 myFirstItem = myLastItem = myCurrentItem = NULL;
162 myCurrentIndex = mySize = 0;
163 }
164
7fd59977 165 friend class Iterator;
166};
167
7fd59977 168#endif