OpenStudio:utilities
Loading...
Searching...
No Matches
openstudio::IdfObjectWatcher Class Reference

#include <IdfObjectWatcher.hpp>

+ Inheritance diagram for openstudio::IdfObjectWatcher:

Public Member Functions

void change ()
 
virtual void clearState ()
 reset dirty, dataChanged, and nameChanged
 
void dataChange ()
 
bool dataChanged () const
 if dirty, then true if data field changed, false if some other change
 
bool dirty () const
 true if object has changed
 
bool disable ()
 
void enable ()
 enable the watcher
 
bool enabled () const
 is the watcher currently enabled
 
 IdfObjectWatcher (const IdfObject &idfObject)
 constructor with IdfObject to watch
 
void nameChange ()
 
bool nameChanged () const
 if dirty, then true if name field changed, false otherwise
 
virtual void onBecomeClean ()
 called after dirty transitions from true to false if watcher enabled
 
virtual void onBecomeDirty ()
 called after dirty transitions from false to true if watcher enabled
 
virtual void onChangeIdfObject ()
 called each time the IdfObject changes if watcher enabled
 
virtual void onDataFieldChange ()
 called each time one of the IdfObject's data fields changes if watcher enabled
 
virtual void onNameChange ()
 called each time the IdfObject's name changes if watcher enabled
 
virtual ~IdfObjectWatcher ()=default
 virtual destructor
 

Protected Attributes

bool m_dataChanged
 
bool m_dirty
 
bool m_enabled
 
bool m_nameChanged
 

Detailed Description

IdfObjectWatcher watches an IdfObject for signals emitted on changes.

These signals will cause the watcher to mark the IdfObject as dirty. The dirty flag will persist until reset by the user. Virtual methods onChangeIdfObject and onDataFieldChange are also available to override. The former is called every time the IdfObject changes in any way; the latter is called whenever a data field changes (not triggered by comment changes, and is superceded by onRelationshipChange for WorkspaceObject pointer fields.) The virtual method onBecomeDirty is called only after dirty transitions from false to true. Alternatively, the virtual method onBecomeClean is called only after dirty transitions from true to false.

IdfObjectWatcher is an atypical object because it is designed to be stack allocated. In many cases it would be preferred to connect your own heap allocated object to the Workspace signals directly rather than using this convenience class.

Constructor & Destructor Documentation

◆ IdfObjectWatcher()

openstudio::IdfObjectWatcher::IdfObjectWatcher ( const IdfObject & idfObject)

constructor with IdfObject to watch

◆ ~IdfObjectWatcher()

virtual openstudio::IdfObjectWatcher::~IdfObjectWatcher ( )
virtualdefault

virtual destructor

Member Function Documentation

◆ change()

void openstudio::IdfObjectWatcher::change ( )

◆ clearState()

virtual void openstudio::IdfObjectWatcher::clearState ( )
virtual

reset dirty, dataChanged, and nameChanged

Reimplemented in openstudio::WorkspaceObjectWatcher.

◆ dataChange()

void openstudio::IdfObjectWatcher::dataChange ( )

◆ dataChanged()

bool openstudio::IdfObjectWatcher::dataChanged ( ) const

if dirty, then true if data field changed, false if some other change

◆ dirty()

bool openstudio::IdfObjectWatcher::dirty ( ) const

true if object has changed

◆ disable()

bool openstudio::IdfObjectWatcher::disable ( )

◆ enable()

void openstudio::IdfObjectWatcher::enable ( )

enable the watcher

◆ enabled()

bool openstudio::IdfObjectWatcher::enabled ( ) const

is the watcher currently enabled

◆ nameChange()

void openstudio::IdfObjectWatcher::nameChange ( )

◆ nameChanged()

bool openstudio::IdfObjectWatcher::nameChanged ( ) const

if dirty, then true if name field changed, false otherwise

◆ onBecomeClean()

virtual void openstudio::IdfObjectWatcher::onBecomeClean ( )
virtual

called after dirty transitions from true to false if watcher enabled

◆ onBecomeDirty()

virtual void openstudio::IdfObjectWatcher::onBecomeDirty ( )
virtual

called after dirty transitions from false to true if watcher enabled

◆ onChangeIdfObject()

virtual void openstudio::IdfObjectWatcher::onChangeIdfObject ( )
virtual

called each time the IdfObject changes if watcher enabled

◆ onDataFieldChange()

virtual void openstudio::IdfObjectWatcher::onDataFieldChange ( )
virtual

called each time one of the IdfObject's data fields changes if watcher enabled

◆ onNameChange()

virtual void openstudio::IdfObjectWatcher::onNameChange ( )
virtual

called each time the IdfObject's name changes if watcher enabled

Member Data Documentation

◆ m_dataChanged

bool openstudio::IdfObjectWatcher::m_dataChanged
protected

◆ m_dirty

bool openstudio::IdfObjectWatcher::m_dirty
protected

◆ m_enabled

bool openstudio::IdfObjectWatcher::m_enabled
protected

◆ m_nameChanged

bool openstudio::IdfObjectWatcher::m_nameChanged
protected