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
30 SUIT_DataOwner::SUIT_DataOwner()
35 SUIT_DataOwner::~SUIT_DataOwner()
39 /*! operator== : compares two owners*/
40 bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
42 if ( !p1.isNull() && !p2.isNull() )
43 return (p1->isEqual( *p2 ) && p2->isEqual( *p1 ));
44 return p1.isNull() && p2.isNull();
48 \class SUIT_DataOwnerPtrList
49 implements value list with unique items (uniqueness is
50 provided by operator==())
56 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList()
57 : QValueList<SUIT_DataOwnerPtr>(),
65 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const bool skipAllEqual )
66 : QValueList<SUIT_DataOwnerPtr>(),
67 mySkipEqual( skipAllEqual )
74 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l )
75 : QValueList<SUIT_DataOwnerPtr>( l ),
83 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l, const bool skipAllEqual )
84 : QValueList<SUIT_DataOwnerPtr>(),
85 mySkipEqual( skipAllEqual )
87 if ( skipAllEqual == l.mySkipEqual )
91 SUIT_DataOwnerPtrList::const_iterator beginIt = l.begin();
92 SUIT_DataOwnerPtrList::const_iterator endIt = l.end();
93 for( ; beginIt != endIt; ++beginIt )
100 Constructor (from stl)
102 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const std::list<SUIT_DataOwnerPtr>& l )
103 : QValueList<SUIT_DataOwnerPtr>( l ),
111 Constructor (from stl)
113 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const std::list<SUIT_DataOwnerPtr>& l, const bool skipAllEqual )
114 : QValueList<SUIT_DataOwnerPtr>(),
115 mySkipEqual( skipAllEqual )
117 std::list<SUIT_DataOwnerPtr>::const_iterator beginIt = l.begin();
118 std::list<SUIT_DataOwnerPtr>::const_iterator endIt = l.begin();
119 for( ; beginIt != endIt; ++beginIt )
125 Appends an item to the list
127 SUIT_DataOwnerPtrList::iterator SUIT_DataOwnerPtrList::append( const SUIT_DataOwnerPtr& x )
129 if( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
132 iterator it = QValueList<SUIT_DataOwnerPtr>::append( x );
135 myMap.insert( x, it );
143 void SUIT_DataOwnerPtrList::clear()
147 QValueList<SUIT_DataOwnerPtr>::clear();
151 Remove an item from the list
153 uint SUIT_DataOwnerPtrList::remove(const SUIT_DataOwnerPtr& x )
155 if( mySkipEqual && myMap.contains(x) )
157 return QValueList<SUIT_DataOwnerPtr>::remove( x );
161 Operator < allows to order suit data owners for map
163 bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
165 return p1.get()<p2.get();