0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / TopLoc / TopLoc_SListOfItemLocation.hxx
1 // Created on: 1993-02-26
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _TopLoc_SListOfItemLocation_HeaderFile
18 #define _TopLoc_SListOfItemLocation_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Boolean.hxx>
25 class TopLoc_SListNodeOfItemLocation;
26 class Standard_NoSuchObject;
27 class TopLoc_ItemLocation;
28
29
30 //! An SListOfItemLocation is a LISP like list of Items.
31 //! An SListOfItemLocation is :
32 //! . Empty.
33 //! . Or it has a Value and a  Tail  which is an other SListOfItemLocation.
34 //!
35 //! The Tail of an empty list is an empty list.
36 //! SListOfItemLocation are  shared.  It  means   that they  can  be
37 //! modified through other lists.
38 //! SListOfItemLocation may  be used  as Iterators. They  have Next,
39 //! More, and value methods. To iterate on the content
40 //! of the list S just do.
41 //!
42 //! SListOfItemLocation Iterator;
43 //! for (Iterator = S; Iterator.More(); Iterator.Next())
44 //! X = Iterator.Value();
45 class TopLoc_SListOfItemLocation 
46 {
47 public:
48
49   DEFINE_STANDARD_ALLOC
50
51   //! Creates an empty List.
52   TopLoc_SListOfItemLocation() {}
53   
54   //! Creates a List with <anItem> as value  and <aTail> as tail.
55   Standard_EXPORT TopLoc_SListOfItemLocation(const TopLoc_ItemLocation& anItem, const TopLoc_SListOfItemLocation& aTail);
56   
57   //! Creates a list from an other one. The lists  are shared.
58   TopLoc_SListOfItemLocation(const TopLoc_SListOfItemLocation& Other)
59   : myNode(Other.myNode)
60   {
61   }
62   
63   //! Sets  a list  from  an  other  one. The  lists are
64   //! shared. The list itself is returned.
65   Standard_EXPORT TopLoc_SListOfItemLocation& Assign (const TopLoc_SListOfItemLocation& Other);
66
67   //! Assignment
68   TopLoc_SListOfItemLocation& operator = (const TopLoc_SListOfItemLocation& Other)
69   {
70     return Assign(Other);
71   }
72   
73 #ifndef OCCT_NO_RVALUE_REFERENCE
74
75   //! Move constructor
76   TopLoc_SListOfItemLocation (TopLoc_SListOfItemLocation&& theOther)
77     : myNode(std::move (theOther.myNode))
78   {
79   }
80
81   //! Move operator
82   TopLoc_SListOfItemLocation& operator= (TopLoc_SListOfItemLocation&& theOther)
83   {
84     myNode = std::move (theOther.myNode);
85     return *this;
86   }
87
88 #endif
89
90   //! Returne true if this list is empty
91   Standard_Boolean IsEmpty() const
92   {
93     return myNode.IsNull();
94   }
95   
96   //! Sets the list to be empty.
97   void Clear()
98   {
99     myNode.Nullify();
100   }
101
102   //! Destructor
103   ~TopLoc_SListOfItemLocation()
104   {
105     Clear();
106   }
107   
108   //! Returns the current value of the list. An error is
109   //! raised  if the list is empty.
110   Standard_EXPORT const TopLoc_ItemLocation& Value() const;
111   
112   //! Returns the current tail of  the list. On an empty
113   //! list the tail is the list itself.
114   Standard_EXPORT const TopLoc_SListOfItemLocation& Tail() const;
115   
116   //! Replaces the list by a list with <anItem> as Value
117   //! and the  list <me> as  tail.
118   void Construct(const TopLoc_ItemLocation& anItem)
119   {
120     Assign(TopLoc_SListOfItemLocation(anItem, *this));
121   }
122   
123   //! Replaces the list <me> by its tail.
124   void ToTail()
125   {
126     Assign(Tail());
127   }
128   
129   //! Returns True if the iterator  has a current value.
130   //! This is !IsEmpty()
131   Standard_Boolean More() const
132   {
133     return !IsEmpty();
134   }
135   
136   //! Moves the iterator to the next object in the list.
137   //! If the iterator is empty it will  stay empty. This is ToTail()
138   void Next()
139   {
140     ToTail();
141   }
142
143 private:
144   Handle(TopLoc_SListNodeOfItemLocation) myNode;
145 };
146
147 #endif // _TopLoc_SListOfItemLocation_HeaderFile