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/ or email : webmaster.salome@opencascade.com
20 #include "SUIT_DataOwner.h"
24 #define _typeinfo std::type_info
27 #define _typeinfo type_info
31 SUIT_DataOwner::SUIT_DataOwner()
36 SUIT_DataOwner::~SUIT_DataOwner()
40 /*! Operator == compares two owners*/
41 bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
43 if ( !p1.isNull() && !p2.isNull() )
44 return (p1->keyString() == p2->keyString());
45 return p1.isNull() && p2.isNull();
48 // *** jfa: The below function has been put here 14.02.2007 from branch BR_Dev_For_4_0
49 // *** and also improved for better comparison of DataOwners with DataSubOwners.
50 // *** This comment is to be removed after merging with BR_Dev_For_4_0.
51 /*! Operator < allows to order suit data owners for map */
52 bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
54 if ( p1.isNull() && p2.isNull() )
56 else if ( p1.isNull() )
58 else if ( p2.isNull() )
61 return (p1->keyString() < p2->keyString());
66 \class SUIT_DataOwnerPtrList
67 implements value list with unique items (uniqueness is
68 provided by operator==() and operator<())
74 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList()
75 : QValueList<SUIT_DataOwnerPtr>(),
83 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const bool skipAllEqual )
84 : QValueList<SUIT_DataOwnerPtr>(),
85 mySkipEqual( skipAllEqual )
92 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l )
93 : QValueList<SUIT_DataOwnerPtr>( l ),
101 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l, const bool skipAllEqual )
102 : QValueList<SUIT_DataOwnerPtr>(),
103 mySkipEqual( skipAllEqual )
105 if ( skipAllEqual == l.mySkipEqual )
109 SUIT_DataOwnerPtrList::const_iterator beginIt = l.begin();
110 SUIT_DataOwnerPtrList::const_iterator endIt = l.end();
111 for( ; beginIt != endIt; ++beginIt )
118 Constructor (from stl)
120 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const std::list<SUIT_DataOwnerPtr>& l )
121 : QValueList<SUIT_DataOwnerPtr>( l ),
129 Constructor (from stl)
131 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const std::list<SUIT_DataOwnerPtr>& l, const bool skipAllEqual )
132 : QValueList<SUIT_DataOwnerPtr>(),
133 mySkipEqual( skipAllEqual )
135 std::list<SUIT_DataOwnerPtr>::const_iterator beginIt = l.begin();
136 std::list<SUIT_DataOwnerPtr>::const_iterator endIt = l.begin();
137 for( ; beginIt != endIt; ++beginIt )
143 Appends an item to the list
145 SUIT_DataOwnerPtrList::iterator SUIT_DataOwnerPtrList::append( const SUIT_DataOwnerPtr& x )
147 if ( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
150 iterator it = QValueList<SUIT_DataOwnerPtr>::append( x );
153 myMap.insert( x, it );
161 void SUIT_DataOwnerPtrList::clear()
165 QValueList<SUIT_DataOwnerPtr>::clear();
169 Remove an item from the list
171 uint SUIT_DataOwnerPtrList::remove(const SUIT_DataOwnerPtr& x )
173 if( mySkipEqual && myMap.contains(x) )
175 return QValueList<SUIT_DataOwnerPtr>::remove( x );