Version: 8.3.0
YACS::HMI::GuiObserver Class Reference

#include <guiObservers.hxx>

Inheritance diagram for YACS::HMI::GuiObserver:
Collaboration diagram for YACS::HMI::GuiObserver:

Public Member Functions

 GuiObserver ()
 
virtual ~GuiObserver ()
 
virtual void select (bool isSelected)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void incrementSubjects (Subject *subject)
 
virtual void decrementSubjects (Subject *subject)
 
int getNbSubjects ()
 
bool isDestructible ()
 

Static Public Member Functions

static std::string eventName (GuiEvent event)
 
static void setEventMap ()
 

Protected Attributes

std::set< Subject * > _subjectSet
 
bool _destructible
 

Static Protected Attributes

static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 154 of file guiObservers.hxx.

Constructor & Destructor Documentation

GuiObserver::GuiObserver ( )

Definition at line 336 of file guiObservers.cxx.

References _subjectSet.

337  : _destructible(true)
338 {
339  //DEBTRACE("GuiObserver::GuiObserver " << this);
340  _subjectSet.clear();
341 }
GuiObserver::~GuiObserver ( )
virtual

Definition at line 343 of file guiObservers.cxx.

References _subjectSet, and DEBTRACE.

344 {
345  DEBTRACE("GuiObserver::~GuiObserver " << this);
346  set<Subject*> subsetcpy = _subjectSet;
347  set<Subject*>::iterator it= subsetcpy.begin();
348  for (; it != subsetcpy.end(); ++it)
349  (*it)->detach(this);
350 }

Member Function Documentation

void GuiObserver::decrementSubjects ( Subject subject)
virtual

only called by subject when detach from subject.

See Also
Subject::detach

Definition at line 378 of file guiObservers.cxx.

References _subjectSet, and DEBTRACE.

Referenced by YACS::HMI::Subject::detach().

379 {
380  if (_subjectSet.count(subject))
381  _subjectSet.erase(subject);
382  else
383  DEBTRACE("subject " << subject << " is not a subject of observer " << this << "---------------------------");
384  //DEBTRACE(this << " " << _subjectSet.size());
385 }
int GuiObserver::getNbSubjects ( )

Gets the number of subjects observed. used by subject. When the subject is erased (Subject::erase), remaining observers are detached from subjects. If an observer has no more subject, it can be deleted.

See Also
Subject::erase Subject::localClean

Definition at line 394 of file guiObservers.cxx.

References _subjectSet.

Referenced by YACS::HMI::Subject::localclean().

395 {
396  return _subjectSet.size();
397 }
void GuiObserver::incrementSubjects ( Subject subject)
virtual

only called by subject when attach to subject.

See Also
Subject::attach

Definition at line 366 of file guiObservers.cxx.

References _subjectSet, and DEBTRACE.

Referenced by YACS::HMI::Subject::attach().

367 {
368  if (_subjectSet.count(subject))
369  DEBTRACE("subject " << subject << " is already a subject of observer " << this << "---------------------------");
370  _subjectSet.insert(subject);
371  //DEBTRACE(this << " " << _subjectSet.size());
372 }
bool YACS::HMI::GuiObserver::isDestructible ( )
inline

Definition at line 164 of file guiObservers.hxx.

164 { return _destructible; };
void GuiObserver::select ( bool  isSelected)
virtual
void GuiObserver::setEventMap ( )
static

Definition at line 399 of file guiObservers.cxx.

References _eventNameMap, YACS::HMI::ADD, YACS::HMI::ADDCHILDREF, YACS::HMI::ADDCONTROLLINK, YACS::HMI::ADDLINK, YACS::HMI::ADDREF, YACS::HMI::ASSOCIATE, YACS::HMI::CUT, YACS::HMI::DOWN, YACS::HMI::EDIT, YACS::HMI::ENDLOAD, YACS::HMI::GEOMETRY, YACS::HMI::NEWROOT, YACS::HMI::ORDER, YACS::HMI::PASTE, YACS::HMI::REMOVE, YACS::HMI::REMOVECHILDREF, YACS::HMI::RENAME, YACS::HMI::SETCASE, YACS::HMI::SETSELECT, YACS::HMI::SETVALUE, YACS::HMI::SYNCHRO, YACS::HMI::UP, YACS::HMI::UPDATE, and YACS::HMI::UPDATEPROGRESS.

400 {
401  _eventNameMap.clear();
402  _eventNameMap[ADD] = "ADD";
403  _eventNameMap[REMOVE] = "REMOVE";
404  _eventNameMap[CUT] = "CUT";
405  _eventNameMap[PASTE] = "PASTE";
406  _eventNameMap[ORDER] = "ORDER";
407  _eventNameMap[EDIT] = "EDIT";
408  _eventNameMap[UPDATE] = "UPDATE";
409  _eventNameMap[UPDATEPROGRESS] = "UPDATEPROGRESS";
410  _eventNameMap[SYNCHRO] = "SYNCHRO";
411  _eventNameMap[UP] = "UP";
412  _eventNameMap[DOWN] = "DOWN";
413  _eventNameMap[RENAME] = "RENAME";
414  _eventNameMap[NEWROOT] = "NEWROOT";
415  _eventNameMap[ENDLOAD] = "ENDLOAD";
416  _eventNameMap[ADDLINK] = "ADDLINK";
417  _eventNameMap[ADDCONTROLLINK] = "ADDCONTROLLINK";
418  _eventNameMap[ADDREF] = "ADDREF";
419  _eventNameMap[ADDCHILDREF] = "ADDCHILDREF";
420  _eventNameMap[REMOVECHILDREF] = "REMOVECHILDREF";
421  _eventNameMap[ASSOCIATE] = "ASSOCIATE";
422  _eventNameMap[SETVALUE] = "SETVALUE";
423  _eventNameMap[SETCASE] = "SETCASE";
424  _eventNameMap[SETSELECT] = "SETSELECT";
425  _eventNameMap[GEOMETRY] = "GEOMETRY";
426 }

Member Data Documentation

bool YACS::HMI::GuiObserver::_destructible
protected

Definition at line 169 of file guiObservers.hxx.

std::map< int, std::string > GuiObserver::_eventNameMap
staticprotected

Definition at line 170 of file guiObservers.hxx.

Referenced by eventName(), and setEventMap().


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