1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SUIT_DataOwner.h"
26 #define _typeinfo std::type_info
29 #define _typeinfo type_info
33 SUIT_DataOwner::SUIT_DataOwner()
38 SUIT_DataOwner::~SUIT_DataOwner()
42 /*! Operator == compares two owners*/
43 bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
45 if ( !p1.isNull() && !p2.isNull() )
46 return (p1->keyString() == p2->keyString());
47 return p1.isNull() && p2.isNull();
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());
65 \class SUIT_DataOwnerPtrList
66 implements value list with unique items (uniqueness is
67 provided by operator==() and operator<())
73 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList()
74 : QList<SUIT_DataOwnerPtr>(),
82 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const bool skipAllEqual )
83 : QList<SUIT_DataOwnerPtr>(),
84 mySkipEqual( skipAllEqual )
91 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l )
92 : QList<SUIT_DataOwnerPtr>( l ),
100 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l, const bool skipAllEqual )
101 : QList<SUIT_DataOwnerPtr>(),
102 mySkipEqual( skipAllEqual )
104 if ( skipAllEqual == l.mySkipEqual )
108 SUIT_DataOwnerPtrList::const_iterator beginIt = l.begin();
109 SUIT_DataOwnerPtrList::const_iterator endIt = l.end();
110 for ( ; beginIt != endIt; ++beginIt )
116 Appends an item to the list
118 void SUIT_DataOwnerPtrList::append( const SUIT_DataOwnerPtr& x )
120 if ( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
123 QList<SUIT_DataOwnerPtr>::append( x );
126 myMap.insert( x, 0 );
132 void SUIT_DataOwnerPtrList::clear()
137 QList<SUIT_DataOwnerPtr>::clear();
141 Remove an item from the list
143 uint SUIT_DataOwnerPtrList::remove(const SUIT_DataOwnerPtr& x )
145 if ( mySkipEqual && myMap.contains(x) )
148 return QList<SUIT_DataOwnerPtr>::removeAll( x );