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 <MMgt_TShared.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
26 class Standard_Transient;
27 class Standard_OutOfRange;
28 class Standard_NullObject;
29 class Interface_EntityList;
30 class Interface_EntityIterator;
33 class Interface_EntityCluster;
34 DEFINE_STANDARD_HANDLE(Interface_EntityCluster, MMgt_TShared)
36 //! Auxiliary class for EntityList. An EntityList designates an
37 //! EntityCluster, which brings itself an fixed maximum count of
38 //! Entities. If it is full, it gives access to another cluster
39 //! ("Next"). This class is intended to give a good compromise
40 //! between access time (faster than a Sequence, good for little
41 //! count) and memory use (better than a Sequence in any case,
42 //! overall for little count, better than an Array for a very
43 //! little count. It is designed for a light management.
44 //! Remark that a new Item may not be Null, because this is the
45 //! criterium used for "End of List"
46 class Interface_EntityCluster : public MMgt_TShared
52 //! Creates an empty, non-chained, EntityCluster
53 Standard_EXPORT Interface_EntityCluster();
55 //! Creates a non-chained EntityCluster, filled with one Entity
56 Standard_EXPORT Interface_EntityCluster(const Handle(Standard_Transient)& ent);
58 //! Creates an empty EntityCluster, chained with another one
59 //! (that is, put BEFORE this other one in the list)
60 Standard_EXPORT Interface_EntityCluster(const Handle(Interface_EntityCluster)& ec);
62 //! Creates an EntityCluster, filled with a first Entity, and
63 //! chained to another EntityCluster (BEFORE it, as above)
64 Standard_EXPORT Interface_EntityCluster(const Handle(Standard_Transient)& ant, const Handle(Interface_EntityCluster)& ec);
66 //! Appends an Entity to the Cluster. If it is not full, adds the
67 //! entity directly inside itself. Else, transmits to its Next
68 //! and Creates it if it does not yet exist
69 Standard_EXPORT void Append (const Handle(Standard_Transient)& ent);
71 //! Removes an Entity from the Cluster. If it is not found, calls
72 //! its Next one to do so.
73 //! Returns True if it becomes itself empty, False else
74 //! (thus, a Cluster which becomes empty is deleted from the list)
75 Standard_EXPORT Standard_Boolean Remove (const Handle(Standard_Transient)& ent);
77 //! Removes an Entity from the Cluster, given its rank. If <num>
78 //! is greater than NbLocal, calls its Next with (num - NbLocal),
79 //! Returns True if it becomes itself empty, False else
80 Standard_EXPORT Standard_Boolean Remove (const Standard_Integer num);
82 //! Returns total count of Entities (including Next)
83 Standard_EXPORT Standard_Integer NbEntities() const;
85 //! Returns the Entity identified by its rank in the list
87 Standard_EXPORT const Handle(Standard_Transient)& Value (const Standard_Integer num) const;
89 //! Changes an Entity given its rank.
90 Standard_EXPORT void SetValue (const Standard_Integer num, const Handle(Standard_Transient)& ent);
92 //! Fills an Iterator with designated Entities (includes Next)
93 Standard_EXPORT void FillIterator (Interface_EntityIterator& iter) const;
96 friend class Interface_EntityList;
99 DEFINE_STANDARD_RTTIEXT(Interface_EntityCluster,MMgt_TShared)
109 //! Returns True if all the set of entities local to a Cluster is
110 //! full. Used by EntityList.
111 Standard_EXPORT Standard_Boolean IsLocalFull() const;
113 //! Returns count of entities in the local set (without Next)
114 //! Entities can then be read normally by method Value
115 Standard_EXPORT Standard_Integer NbLocal() const;
117 //! Returns True if a Cluster has a Next
118 Standard_EXPORT Standard_Boolean HasNext() const;
120 //! Returns Next Cluster in the chain
121 Standard_EXPORT Handle(Interface_EntityCluster) Next() const;
123 Handle(Standard_Transient) theents[4];
124 Handle(Interface_EntityCluster) thenext;
135 #endif // _Interface_EntityCluster_HeaderFile