Back to index

salome-gui  6.5.0
Public Member Functions | Private Member Functions | Private Attributes
SalomeApp_DataModelSync Class Reference

Auxiliary class for synchronizing tree of kernel objects and SUIT_DataObjects. More...

Collaboration diagram for SalomeApp_DataModelSync:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SalomeApp_DataModelSync (_PTR(Study), SUIT_DataObject *)
 Constructor.
bool isEqual (const kerPtr &, const suitPtr &) const
kerPtr nullSrc () const
suitPtr nullTrg () const
suitPtr createItem (const kerPtr &, const suitPtr &, const suitPtr &) const
 Creates SUIT object by KERNEL object.
void updateItem (const kerPtr &, const suitPtr &) const
 Updates SUIT object.
void deleteItemWithChildren (const suitPtr &) const
 Deletes object with all children.
QList< kerPtr > children (const kerPtr &) const
 Fills list with children of kernel object.
QList< suitPtrchildren (const suitPtr &) const
 Fills list with children of SUIT object.
suitPtr parent (const suitPtr &) const

Private Member Functions

bool isCorrect (const kerPtr &) const
 _PTR (Study) myStudy

Private Attributes

SUIT_DataObjectmyRoot

Detailed Description

Auxiliary class for synchronizing tree of kernel objects and SUIT_DataObjects.

Definition at line 48 of file SalomeApp_DataModel.cxx.


Constructor & Destructor Documentation

Constructor.

Definition at line 74 of file SalomeApp_DataModel.cxx.

: myStudy( aStudy ),
  myRoot( aRoot )
{
}

Member Function Documentation

SalomeApp_DataModelSync::_PTR ( Study  ) [private]

Here is the caller graph for this function:

QList< kerPtr > SalomeApp_DataModelSync::children ( const kerPtr &  obj) const

Fills list with children of kernel object.

Parameters:
obj- kernel object
ch- list to be filled

Definition at line 184 of file SalomeApp_DataModel.cxx.

{
  QList<kerPtr> ch;

  _PTR( GenericAttribute ) anAttr;
  bool expandable = true;
  if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) {
    _PTR(AttributeExpandable) aAttrExp = anAttr;
    expandable = aAttrExp->IsExpandable();
  }

  if ( expandable ) {
    // tmp??
    _PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder();
    if (aUseCaseBuilder->HasChildren(obj)) {
      _PTR(UseCaseIterator) it ( aUseCaseBuilder->GetUseCaseIterator( obj ) );
      for ( ; it->More(); it->Next() )
        ch.append( it->Value() );
    }
    else {
      _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) );
      for ( ; it->More(); it->Next() )
        ch.append( it->Value() );
    }
  }

  return ch;
}

Here is the call graph for this function:

QList< suitPtr > SalomeApp_DataModelSync::children ( const suitPtr p) const

Fills list with children of SUIT object.

Parameters:
p- SUIT object
ch- list to be filled

Definition at line 218 of file SalomeApp_DataModel.cxx.

{
  QList<suitPtr> ch;
  if ( p )
    ch = p->children();
  return ch;
}
suitPtr SalomeApp_DataModelSync::createItem ( const kerPtr &  so,
const suitPtr parent,
const suitPtr after 
) const

Creates SUIT object by KERNEL object.

Parameters:
so- corresponding KERNEL object
parent- parent for SUIT object
after- previous sibling for SUIT object
prepend- SUIT object must be added to start of children list

Definition at line 109 of file SalomeApp_DataModel.cxx.

{
  if( !isCorrect( so ) )
    return 0;

  _PTR(SComponent) aSComp( so );
  suitPtr nitem = aSComp ? new SalomeApp_ModuleObject( aSComp, 0 ) :
                           new SalomeApp_DataObject( so, 0 );

  if( parent ) {
    int pos = after ? parent->childPos( after ) : 0;
    parent->insertChild( nitem, pos+1 );
  }
  else if( myRoot ) {
    myRoot->appendChild( nitem );
  }
  return nitem;
}

Here is the call graph for this function:

Deletes object with all children.

Parameters:
p- SUIT object

Definition at line 134 of file SalomeApp_DataModel.cxx.

{
  if( !p )
    return;

  DataObjectList ch;
  p->children( ch );
  DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
  for( ; anIt!=aLast; anIt++ )
    deleteItemWithChildren( *anIt );
  delete p;
}
bool SalomeApp_DataModelSync::isCorrect ( const kerPtr &  so) const [private]
Returns:
true if kernel object is correct (has non empty name or is reference)

Definition at line 83 of file SalomeApp_DataModel.cxx.

{
#ifdef WITH_SALOMEDS_OBSERVER
  // with GUI observers this function is not needed anymore
  return true;
#endif
  kerPtr refObj;
  QString name = so->GetName().c_str();
  _PTR( GenericAttribute ) anAttr;
  bool isDraw = true;
  if ( so->FindAttribute(anAttr, "AttributeDrawable") ) 
  {
    _PTR(AttributeDrawable) aAttrDraw = anAttr;
    isDraw = aAttrDraw->IsDrawable(); 
  }
  bool res = so && ( so->GetName().size() || so->ReferencedObject( refObj ) ) && isDraw;  
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool SalomeApp_DataModelSync::isEqual ( const kerPtr &  p,
const suitPtr q 
) const
Returns:
true if objects correspond each other at all
Parameters:
p- kernel object
q- suit object

Definition at line 152 of file SalomeApp_DataModel.cxx.

{
  LightApp_ModuleObject* lobj = dynamic_cast<LightApp_ModuleObject*>( q );
  SalomeApp_DataObject* sobj = dynamic_cast<SalomeApp_DataObject*>( q );
  _PTR( SComponent ) aComp( p );
  bool res = ( !p && !q ) ||
             ( lobj && !sobj && aComp ) ||
             ( sobj && isCorrect( p ) && p->GetID().c_str()==sobj->entry() );
  return res;
}

Here is the call graph for this function:

Returns:
null kernel object

Definition at line 166 of file SalomeApp_DataModel.cxx.

{
  return kerPtr();
}
Returns:
null suit object

Definition at line 174 of file SalomeApp_DataModel.cxx.

{
  return 0;
}
Returns:
parent of SUIT object
Parameters:
p- SUIT object

Definition at line 230 of file SalomeApp_DataModel.cxx.

{
  return p ? p->parent(): 0;
}
void SalomeApp_DataModelSync::updateItem ( const kerPtr &  obj,
const suitPtr  
) const

Updates SUIT object.

Parameters:
p- SUIT object

Definition at line 239 of file SalomeApp_DataModel.cxx.

{
}

Member Data Documentation

Definition at line 68 of file SalomeApp_DataModel.cxx.


The documentation for this class was generated from the following file: