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

#include <WorkspaceWatcher.hpp>

Public Member Functions

void change ()
 
virtual void clearState ()
 resets dirty, objectAdded, and objectRemoved
 
bool dirty () const
 true if workspace has changed
 
bool disable ()
 
void enable ()
 enable the watcher
 
bool enabled () const
 is the watcher currently enabled
 
void objectAdd (const WorkspaceObject &addedObject, const openstudio::IddObjectType &type, const openstudio::UUID &uuid)
 
bool objectAdded () const
 true if an object has been added
 
void objectRemove (const WorkspaceObject &removedObject, const openstudio::IddObjectType &type, const openstudio::UUID &uuid)
 
bool objectRemoved () const
 true if an object has been removed
 
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 onChangeWorkspace ()
 called each time the IdfObject changes if watcher enabled
 
virtual void onObjectAdd (const WorkspaceObject &addedObject)
 called immediately when a new object is added to the workspace if watcher enabled the object may not be fully constructed this may be called when an object is restored after a failed remove
 
virtual void onObjectRemove (const WorkspaceObject &removedObject)
 called immediately before an object is removed from the workspace if watcher enabled the object is still valid when this method is called
 
 WorkspaceWatcher (const Workspace &workspace)
 
virtual ~WorkspaceWatcher ()=default
 

Detailed Description

WorkspaceWatcher watches a Workspace for signals emitted on changes.

This signals will cause the watcher to mark the Workspace as dirty. The dirty flag will persist until reset by the user. A virtual method onChangeWorkspace is also available to override, it is called everytime the Workspace changes. 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.

WorkspaceWatcher 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

◆ WorkspaceWatcher()

openstudio::WorkspaceWatcher::WorkspaceWatcher ( const Workspace & workspace)

◆ ~WorkspaceWatcher()

virtual openstudio::WorkspaceWatcher::~WorkspaceWatcher ( )
virtualdefault

Member Function Documentation

◆ change()

void openstudio::WorkspaceWatcher::change ( )

◆ clearState()

virtual void openstudio::WorkspaceWatcher::clearState ( )
virtual

resets dirty, objectAdded, and objectRemoved

◆ dirty()

bool openstudio::WorkspaceWatcher::dirty ( ) const

true if workspace has changed

◆ disable()

bool openstudio::WorkspaceWatcher::disable ( )

◆ enable()

void openstudio::WorkspaceWatcher::enable ( )

enable the watcher

◆ enabled()

bool openstudio::WorkspaceWatcher::enabled ( ) const

is the watcher currently enabled

◆ objectAdd()

void openstudio::WorkspaceWatcher::objectAdd ( const WorkspaceObject & addedObject,
const openstudio::IddObjectType & type,
const openstudio::UUID & uuid )

◆ objectAdded()

bool openstudio::WorkspaceWatcher::objectAdded ( ) const

true if an object has been added

◆ objectRemove()

void openstudio::WorkspaceWatcher::objectRemove ( const WorkspaceObject & removedObject,
const openstudio::IddObjectType & type,
const openstudio::UUID & uuid )

◆ objectRemoved()

bool openstudio::WorkspaceWatcher::objectRemoved ( ) const

true if an object has been removed

◆ onBecomeClean()

virtual void openstudio::WorkspaceWatcher::onBecomeClean ( )
virtual

called after dirty transitions from true to false if watcher enabled

◆ onBecomeDirty()

virtual void openstudio::WorkspaceWatcher::onBecomeDirty ( )
virtual

called after dirty transitions from false to true if watcher enabled

◆ onChangeWorkspace()

virtual void openstudio::WorkspaceWatcher::onChangeWorkspace ( )
virtual

called each time the IdfObject changes if watcher enabled

◆ onObjectAdd()

virtual void openstudio::WorkspaceWatcher::onObjectAdd ( const WorkspaceObject & addedObject)
virtual

called immediately when a new object is added to the workspace if watcher enabled the object may not be fully constructed this may be called when an object is restored after a failed remove

◆ onObjectRemove()

virtual void openstudio::WorkspaceWatcher::onObjectRemove ( const WorkspaceObject & removedObject)
virtual

called immediately before an object is removed from the workspace if watcher enabled the object is still valid when this method is called