Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:14:18

0001 // Created on: 1993-02-26
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TopLoc_SListOfItemLocation_HeaderFile
0018 #define _TopLoc_SListOfItemLocation_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Macro.hxx>
0025 class TopLoc_SListNodeOfItemLocation;
0026 class TopLoc_ItemLocation;
0027 
0028 //! An SListOfItemLocation is a LISP like list of Items.
0029 //! An SListOfItemLocation is:
0030 //! . Empty.
0031 //! . Or it has a Value and a Tail which is an other SListOfItemLocation.
0032 //!
0033 //! The Tail of an empty list is an empty list.
0034 //! SListOfItemLocation are shared. It means that they can be
0035 //! modified through other lists.
0036 //! SListOfItemLocation may be used as Iterators. They have Next,
0037 //! More, and value methods. To iterate on the content
0038 //! of the list S just do.
0039 //!
0040 //! SListOfItemLocation Iterator;
0041 //! for (Iterator = S; Iterator.More(); Iterator.Next())
0042 //! X = Iterator.Value();
0043 class TopLoc_SListOfItemLocation
0044 {
0045 public:
0046   DEFINE_STANDARD_ALLOC
0047 
0048   //! Creates an empty List.
0049   TopLoc_SListOfItemLocation() = default;
0050 
0051   //! Creates a List with <anItem> as value and <aTail> as tail.
0052   Standard_EXPORT TopLoc_SListOfItemLocation(const TopLoc_ItemLocation&        anItem,
0053                                              const TopLoc_SListOfItemLocation& aTail);
0054 
0055   //! Creates a list from an other one. The lists are shared.
0056   TopLoc_SListOfItemLocation(const TopLoc_SListOfItemLocation& Other) = default;
0057 
0058   //! Sets a list from an other one. The lists are
0059   //! shared. The list itself is returned.
0060   Standard_EXPORT TopLoc_SListOfItemLocation& Assign(const TopLoc_SListOfItemLocation& Other);
0061 
0062   //! Assignment
0063   TopLoc_SListOfItemLocation& operator=(const TopLoc_SListOfItemLocation& Other)
0064   {
0065     return Assign(Other);
0066   }
0067 
0068   //! Move constructor
0069   TopLoc_SListOfItemLocation(TopLoc_SListOfItemLocation&& theOther) noexcept
0070       : myNode(std::move(theOther.myNode))
0071   {
0072   }
0073 
0074   //! Move operator
0075   TopLoc_SListOfItemLocation& operator=(TopLoc_SListOfItemLocation&& theOther) noexcept
0076   {
0077     myNode = std::move(theOther.myNode);
0078     return *this;
0079   }
0080 
0081   //! Return true if this list is empty
0082   bool IsEmpty() const noexcept { return myNode.IsNull(); }
0083 
0084   //! Sets the list to be empty.
0085   void Clear() noexcept { myNode.Nullify(); }
0086 
0087   //! Destructor
0088   ~TopLoc_SListOfItemLocation() noexcept { Clear(); }
0089 
0090   //! Returns the current value of the list. An error is
0091   //! raised if the list is empty.
0092   Standard_EXPORT const TopLoc_ItemLocation& Value() const;
0093 
0094   //! Returns the current tail of the list. On an empty
0095   //! list the tail is the list itself.
0096   Standard_EXPORT const TopLoc_SListOfItemLocation& Tail() const;
0097 
0098   //! Replaces the list by a list with <anItem> as Value
0099   //! and the list <me> as tail.
0100   void Construct(const TopLoc_ItemLocation& anItem)
0101   {
0102     Assign(TopLoc_SListOfItemLocation(anItem, *this));
0103   }
0104 
0105   //! Replaces the list <me> by its tail.
0106   void ToTail() { Assign(Tail()); }
0107 
0108   //! Returns True if the iterator has a current value.
0109   //! This is !IsEmpty()
0110   bool More() const noexcept { return !IsEmpty(); }
0111 
0112   //! Moves the iterator to the next object in the list.
0113   //! If the iterator is empty it will stay empty. This is ToTail()
0114   void Next() { ToTail(); }
0115 
0116 private:
0117   occ::handle<TopLoc_SListNodeOfItemLocation> myNode;
0118 };
0119 
0120 #endif // _TopLoc_SListOfItemLocation_HeaderFile