Version: 9.16.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 155 of file guiObservers.hxx.

Constructor & Destructor Documentation

◆ GuiObserver()

GuiObserver::GuiObserver ( )

Definition at line 336 of file guiObservers.cxx.

337 : _destructible(true)
338{
339 //DEBTRACE("GuiObserver::GuiObserver " << this);
340 _subjectSet.clear();
341}
std::set< Subject * > _subjectSet

References _subjectSet.

◆ ~GuiObserver()

GuiObserver::~GuiObserver ( )
virtual

Definition at line 343 of file guiObservers.cxx.

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}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _subjectSet, and DEBTRACE.

Member Function Documentation

◆ decrementSubjects()

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.

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}

References _subjectSet, and DEBTRACE.

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

◆ eventName()

◆ getNbSubjects()

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.

395{
396 return _subjectSet.size();
397}

References _subjectSet.

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

◆ incrementSubjects()

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.

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}

References _subjectSet, and DEBTRACE.

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

◆ isDestructible()

bool YACS::HMI::GuiObserver::isDestructible ( )
inline

Definition at line 165 of file guiObservers.hxx.

165{ return _destructible; };

◆ select()

void GuiObserver::select ( bool  isSelected)
virtual

◆ setEventMap()

void GuiObserver::setEventMap ( )
static

Definition at line 399 of file guiObservers.cxx.

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}

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.

Referenced by YACS::HMI::GenericGui::GenericGui().

◆ update()

Member Data Documentation

◆ _destructible

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

Definition at line 170 of file guiObservers.hxx.

◆ _eventNameMap

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

Definition at line 171 of file guiObservers.hxx.

Referenced by eventName(), and setEventMap().

◆ _subjectSet


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