1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #include "SUIT_DataOwner.h"
23 #define _typeinfo std::type_info
26 #define _typeinfo type_info
29 //********************************************************************
30 // SUIT_DataOwner class
31 //********************************************************************
35 SUIT_DataOwner::SUIT_DataOwner()
40 SUIT_DataOwner::~SUIT_DataOwner()
44 /*! operator== : compares two owners*/
45 bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
47 if ( !p1.isNull() && !p2.isNull() )
48 return (p1->isEqual( *p2 ) && p2->isEqual( *p1 ));
49 return p1.isNull() && p2.isNull();
52 //********************************************************************
53 /*! \class SUIT_DataOwnerPtrList
54 * implements value list with unique items (uniqueness is
55 * provided by operator==())
57 //********************************************************************
59 //====================================================================
60 //! Constructor (default)
61 //====================================================================
62 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList()
63 : QValueList<SUIT_DataOwnerPtr>(),
68 //====================================================================
69 //! Constructor (default)
70 //====================================================================
71 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const bool skipAllEqual )
72 : QValueList<SUIT_DataOwnerPtr>(),
73 mySkipEqual( skipAllEqual )
77 //====================================================================
78 //! Constructor (copy)
79 //====================================================================
80 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l )
81 : QValueList<SUIT_DataOwnerPtr>( l ),
86 //====================================================================
87 //! Constructor (copy)
88 //====================================================================
89 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l, const bool skipAllEqual )
90 : QValueList<SUIT_DataOwnerPtr>(),
91 mySkipEqual( skipAllEqual )
93 if ( skipAllEqual == l.mySkipEqual )
97 SUIT_DataOwnerPtrList::const_iterator beginIt = l.begin();
98 SUIT_DataOwnerPtrList::const_iterator endIt = l.end();
99 for( ; beginIt != endIt; ++beginIt )
105 //====================================================================
106 //! Constructor (from stl)
107 //====================================================================
108 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const std::list<SUIT_DataOwnerPtr>& l )
109 : QValueList<SUIT_DataOwnerPtr>( l ),
116 //====================================================================
117 //! Constructor (from stl)
118 //====================================================================
119 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const std::list<SUIT_DataOwnerPtr>& l, const bool skipAllEqual )
120 : QValueList<SUIT_DataOwnerPtr>(),
121 mySkipEqual( skipAllEqual )
123 std::list<SUIT_DataOwnerPtr>::const_iterator beginIt = l.begin();
124 std::list<SUIT_DataOwnerPtr>::const_iterator endIt = l.begin();
125 for( ; beginIt != endIt; ++beginIt )
130 //====================================================================
131 //! Appends an item to the list
132 //====================================================================
133 SUIT_DataOwnerPtrList::iterator SUIT_DataOwnerPtrList::append( const SUIT_DataOwnerPtr& x )
135 if( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
138 iterator it = QValueList<SUIT_DataOwnerPtr>::append( x );
141 myMap.insert( x, it );
146 //====================================================================
148 //====================================================================
149 void SUIT_DataOwnerPtrList::clear()
153 QValueList<SUIT_DataOwnerPtr>::clear();
156 //====================================================================
157 //! Remove an item from the list
158 //====================================================================
159 uint SUIT_DataOwnerPtrList::remove(const SUIT_DataOwnerPtr& x )
161 if( mySkipEqual && myMap.contains(x) )
163 return QValueList<SUIT_DataOwnerPtr>::remove( x );