1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 #include "SUIT_DataOwner.h"
27 #define _typeinfo std::type_info
30 #define _typeinfo type_info
34 SUIT_DataOwner::SUIT_DataOwner()
39 SUIT_DataOwner::~SUIT_DataOwner()
43 /*! Operator == compares two owners*/
44 bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
46 if ( !p1.isNull() && !p2.isNull() )
47 return (p1->keyString() == p2->keyString());
48 return p1.isNull() && p2.isNull();
52 /*! Operator < allows to order suit data owners for map */
53 bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
55 if ( p1.isNull() && p2.isNull() )
57 else if ( p1.isNull() )
59 else if ( p2.isNull() )
62 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 : QList<SUIT_DataOwnerPtr>(),
83 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const bool skipAllEqual )
84 : QList<SUIT_DataOwnerPtr>(),
85 mySkipEqual( skipAllEqual )
92 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l )
93 : QList<SUIT_DataOwnerPtr>( l ),
101 SUIT_DataOwnerPtrList::SUIT_DataOwnerPtrList( const SUIT_DataOwnerPtrList& l, const bool skipAllEqual )
102 : QList<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 )
117 Appends an item to the list
119 void SUIT_DataOwnerPtrList::append( const SUIT_DataOwnerPtr& x )
121 if ( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
124 QList<SUIT_DataOwnerPtr>::append( x );
127 myMap.insert( x, 0 );
133 void SUIT_DataOwnerPtrList::clear()
138 QList<SUIT_DataOwnerPtr>::clear();
142 Remove an item from the list
144 uint SUIT_DataOwnerPtrList::remove(const SUIT_DataOwnerPtr& x )
146 if ( mySkipEqual && myMap.contains(x) )
149 return QList<SUIT_DataOwnerPtr>::removeAll( x );