1 // Created on: 1992-11-02
2 // Created by: Christian CAILLET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_EntityCluster_HeaderFile
18 #define _Interface_EntityCluster_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Transient.hxx>
24 #include <Standard_Integer.hxx>
25 class Interface_EntityIterator;
28 class Interface_EntityCluster;
29 DEFINE_STANDARD_HANDLE(Interface_EntityCluster, Standard_Transient)
31 //! Auxiliary class for EntityList. An EntityList designates an
32 //! EntityCluster, which brings itself an fixed maximum count of
33 //! Entities. If it is full, it gives access to another cluster
34 //! ("Next"). This class is intended to give a good compromise
35 //! between access time (faster than a Sequence, good for little
36 //! count) and memory use (better than a Sequence in any case,
37 //! overall for little count, better than an Array for a very
38 //! little count. It is designed for a light management.
39 //! Remark that a new Item may not be Null, because this is the
40 //! criterium used for "End of List"
41 class Interface_EntityCluster : public Standard_Transient
47 //! Creates an empty, non-chained, EntityCluster
48 Standard_EXPORT Interface_EntityCluster();
50 //! Creates a non-chained EntityCluster, filled with one Entity
51 Standard_EXPORT Interface_EntityCluster(const Handle(Standard_Transient)& ent);
53 //! Creates an empty EntityCluster, chained with another one
54 //! (that is, put BEFORE this other one in the list)
55 Standard_EXPORT Interface_EntityCluster(const Handle(Interface_EntityCluster)& ec);
57 //! Creates an EntityCluster, filled with a first Entity, and
58 //! chained to another EntityCluster (BEFORE it, as above)
59 Standard_EXPORT Interface_EntityCluster(const Handle(Standard_Transient)& ant, const Handle(Interface_EntityCluster)& ec);
61 //! Appends an Entity to the Cluster. If it is not full, adds the
62 //! entity directly inside itself. Else, transmits to its Next
63 //! and Creates it if it does not yet exist
64 Standard_EXPORT void Append (const Handle(Standard_Transient)& ent);
66 //! Removes an Entity from the Cluster. If it is not found, calls
67 //! its Next one to do so.
68 //! Returns True if it becomes itself empty, False else
69 //! (thus, a Cluster which becomes empty is deleted from the list)
70 Standard_EXPORT Standard_Boolean Remove (const Handle(Standard_Transient)& ent);
72 //! Removes an Entity from the Cluster, given its rank. If <num>
73 //! is greater than NbLocal, calls its Next with (num - NbLocal),
74 //! Returns True if it becomes itself empty, False else
75 Standard_EXPORT Standard_Boolean Remove (const Standard_Integer num);
77 //! Returns total count of Entities (including Next)
78 Standard_EXPORT Standard_Integer NbEntities() const;
80 //! Returns the Entity identified by its rank in the list
82 Standard_EXPORT const Handle(Standard_Transient)& Value (const Standard_Integer num) const;
84 //! Changes an Entity given its rank.
85 Standard_EXPORT void SetValue (const Standard_Integer num, const Handle(Standard_Transient)& ent);
87 //! Fills an Iterator with designated Entities (includes Next)
88 Standard_EXPORT void FillIterator (Interface_EntityIterator& iter) const;
91 //! If Next exists, destroy from the last entity in reverse order.
92 Standard_EXPORT virtual ~Interface_EntityCluster();
94 friend class Interface_EntityList;
97 DEFINE_STANDARD_RTTIEXT(Interface_EntityCluster,Standard_Transient)
107 //! Returns True if all the set of entities local to a Cluster is
108 //! full. Used by EntityList.
109 Standard_EXPORT Standard_Boolean IsLocalFull() const;
111 //! Returns count of entities in the local set (without Next)
112 //! Entities can then be read normally by method Value
113 Standard_EXPORT Standard_Integer NbLocal() const;
115 //! Returns True if a Cluster has a Next
116 Standard_EXPORT Standard_Boolean HasNext() const;
118 //! Returns Next Cluster in the chain
119 Standard_EXPORT Handle(Interface_EntityCluster) Next() const;
121 Handle(Standard_Transient) theents[4];
122 Handle(Interface_EntityCluster) thenext;
133 #endif // _Interface_EntityCluster_HeaderFile