//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "LightApp_DataOwner.h"
#include "LightApp_DataObject.h"
#include <iostream>
/*!Constructor. Initialize by \a theEntry.*/
-LightApp_DataOwner
-::LightApp_DataOwner( const QString& theEntry ):
+LightApp_DataOwner::LightApp_DataOwner( const QString& theEntry ):
myEntry( theEntry )
{
}
#ifndef DISABLE_SALOMEOBJECT
/*!Constructor. Initialize by \a SALOME_InteractiveObject.*/
-LightApp_DataOwner
-::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ):
+LightApp_DataOwner::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ):
myEntry(!theIO.IsNull()? theIO->getEntry(): ""),
myIO(theIO)
{
#endif
/*!Destructor. Do nothing.*/
-LightApp_DataOwner
-::~LightApp_DataOwner()
-{
-}
-
-/*!Checks: Is current data owner equal \a obj.*/
-bool
-LightApp_DataOwner
-::isEqual( const SUIT_DataOwner& obj ) const
+LightApp_DataOwner::~LightApp_DataOwner()
{
- const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
-
- return other && entry() == other->entry();
}
-bool LightApp_DataOwner::operator<( const SUIT_DataOwner& obj ) const
+/*!Gets key string, used for data owners comparison.*/
+QString LightApp_DataOwner::keyString() const
{
- const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
- return entry() < other->entry();
+ return myEntry;
}
/*!Gets entry.*/
-QString
-LightApp_DataOwner
-::entry() const
+QString LightApp_DataOwner::entry() const
{
return myEntry;
}
#ifndef DISABLE_SALOMEOBJECT
/*!Gets SALOME_InteractiveObject.*/
-const Handle(SALOME_InteractiveObject)&
-LightApp_DataOwner
-::IO() const
+const Handle(SALOME_InteractiveObject)& LightApp_DataOwner::IO() const
{
return myIO;
}
LightApp_DataOwner( const QString& );
virtual ~LightApp_DataOwner();
- virtual bool isEqual( const SUIT_DataOwner& ) const;
- virtual bool operator<( const SUIT_DataOwner& ) const;
+ // *** jfa: The below line has been put here 14.02.2007.
+ // *** It cancels modifications from branch BR_Dev_For_4_0
+ virtual QString keyString() const;
#ifndef DISABLE_SALOMEOBJECT
const Handle(SALOME_InteractiveObject)& IO() const;
{
}
-/*!Checks: Is current data sub owner equal \a obj.*/
-bool LightApp_DataSubOwner::isEqual( const SUIT_DataOwner& obj ) const
-{
- if (LightApp_DataOwner::isEqual(obj)) {
- const LightApp_DataSubOwner* other = dynamic_cast<const LightApp_DataSubOwner*>( &obj );
- return other && index() == other->index();
- }
- return false;
+/*!Gets key string, used for data owners comparison.*/
+QString LightApp_DataSubOwner::keyString() const
+{
+ QString aKey = LightApp_DataOwner::keyString();
+ aKey += QString("_%1").arg(index());
+ return aKey;
}
/*!Gets index.*/
LightApp_DataSubOwner( const QString&, const int );
virtual ~LightApp_DataSubOwner();
- virtual bool isEqual( const SUIT_DataOwner& ) const;
- int index() const;
+ // *** jfa: The below line has been put here 14.02.2007.
+ // *** It cancels modifications from branch BR_Dev_For_4_0
+ virtual QString keyString() const;
+ int index() const;
private:
int myIndex;
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "SUIT_DataOwner.h"
#ifndef WNT
bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
{
if ( !p1.isNull() && !p2.isNull() )
- return (p1->isEqual( *p2 ) && p2->isEqual( *p1 ));
+ return (p1->keyString() == p2->keyString());
return p1.isNull() && p2.isNull();
}
+// *** jfa: The below function has been put here 14.02.2007 from branch BR_Dev_For_4_0
+// *** and also improved for better comparison of DataOwners with DataSubOwners.
+// *** This comment is to be removed after merging with BR_Dev_For_4_0.
+/*! Operator < allows to order suit data owners for map */
+bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
+{
+ if ( p1.isNull() && p2.isNull() )
+ return false;
+ else if ( p1.isNull() )
+ return true;
+ else if ( p2.isNull() )
+ return false;
+
+ return (p1->keyString() < p2->keyString());
+}
+// *** end
+
/*!
\class SUIT_DataOwnerPtrList
implements value list with unique items (uniqueness is
- provided by operator==())
+ provided by operator==() and operator<())
*/
/*!
myMap.remove(x);
return QValueList<SUIT_DataOwnerPtr>::remove( x );
}
-
-/*!
- Operator < allows to order suit data owners for map
-*/
-bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
-{
- return p1->operator<( *p2 );
-}
public:
SUIT_DataOwner();//!< constructor
virtual ~SUIT_DataOwner();//!< destructor
- //! compare function
- virtual bool isEqual( const SUIT_DataOwner& ) const = 0;
- virtual bool operator<( const SUIT_DataOwner& ) const = 0;
+ // *** jfa: The below line has been put here 14.02.2007.
+ // *** It cancels modifications from branch BR_Dev_For_4_0
+ virtual QString keyString() const = 0;//!< used for comparison
};
/*! \typedef SUIT_DataOwnerPtr