cgma
CubitObservable Class Reference

#include <CubitObservable.hpp>

Inheritance diagram for CubitObservable:
CubitCoordinateSystem RefEntity SenseEntity BasicTopologyEntity Body RefCollection CoEdge CoFace CoVertex CoVolume RefEdge RefFace RefVertex RefVolume RefGroup

List of all members.

Public Member Functions

 CubitObservable ()
virtual ~CubitObservable ()
void get_observer_list (DLIList< CubitObserver * > &observers)
void notify_observers (const CubitEvent *event)

Protected Member Functions

void remove_from_observers ()
virtual CubitStatus add_observer (CubitObserver *observer)
virtual CubitStatus remove_observer (CubitObserver *observer)
 CubitObservable (const CubitObservable &)
void operator= (const CubitObservable &)

Protected Attributes

DLIList< CubitObserver * > * observerList

Friends

class CubitObserver
class CubitEventDispatcher

Detailed Description

Definition at line 15 of file CubitObservable.hpp.


Constructor & Destructor Documentation

Definition at line 5 of file CubitObservable.cpp.

{
  observerList = NULL;
}

Definition at line 10 of file CubitObservable.cpp.

{
  if (observerList) 
  {
    assert( (observerList->remove_all_with_value( NULL ),
             observerList->size() == 0) );
    delete observerList;
    observerList = NULL;
  }
}

Member Function Documentation

CubitStatus CubitObservable::add_observer ( CubitObserver observer) [protected, virtual]

Definition at line 21 of file CubitObservable.cpp.

Definition at line 58 of file CubitObservable.cpp.

{
  if (observerList)
  {
    for( int i = observerList->size(); i > 0; i-- )
    {
      CubitObserver* observer = observerList->get_and_step();
      if( observer )
         observers.append( observer );
    }
  }
}

Definition at line 71 of file CubitObservable.cpp.

{
  if ( ! observerList || observerList->size() == 0 )
     return;

  CubitObserver *observer = NULL;
  for ( int i = 0; i < observerList->size(); i++ )
  {
    observerList->reset();
    observerList->step(i);
    observer = observerList->get();
    if ( observer != NULL )
    {
       observer->notify_observer(event);
    }
  }
  observerList->remove_all_with_value( NULL );
}
void CubitObservable::operator= ( const CubitObservable ) [protected]

Definition at line 52 of file CubitObservable.cpp.

{
  if( observerList != NULL )
     observerList->clean_out();
}
CubitStatus CubitObservable::remove_observer ( CubitObserver observer) [protected, virtual]

Definition at line 32 of file CubitObservable.cpp.

{
  CubitStatus success = CUBIT_FAILURE;
  if( observerList != NULL )
  {
    int i;
    for ( i = 0; i < observerList->size(); i++ )
    {
      if ( observerList->get() == observer )
      {
        success = CUBIT_SUCCESS;
        observerList->change_to( NULL );
        break;
      }
      observerList->step();
    }
  }
  return success;
}

Friends And Related Function Documentation

friend class CubitEventDispatcher [friend]

Definition at line 21 of file CubitObservable.hpp.

friend class CubitObserver [friend]

Definition at line 20 of file CubitObservable.hpp.


Member Data Documentation

Definition at line 53 of file CubitObservable.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines