diff --git a/.gitignore b/.gitignore index 740e3abf2a6..f550ce9892f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ test_fails.txt /build-64/ /build_profile/ /build-profile/ + +*.sublime-workspace + +*.sublime-project diff --git a/openstudiocore/src/model/CMakeLists.txt b/openstudiocore/src/model/CMakeLists.txt index 628ef5f08ba..2323ab1401b 100644 --- a/openstudiocore/src/model/CMakeLists.txt +++ b/openstudiocore/src/model/CMakeLists.txt @@ -3,6 +3,7 @@ set(target_name openstudio_model) set(${target_name}_src mainpage.hpp + nano_signal_slot.hpp ModelAPI.hpp Model.hpp Model_Impl.hpp diff --git a/openstudiocore/src/model/ComponentWatcher.cpp b/openstudiocore/src/model/ComponentWatcher.cpp index 3cd8fdf2daa..49ca4cc08c8 100644 --- a/openstudiocore/src/model/ComponentWatcher.cpp +++ b/openstudiocore/src/model/ComponentWatcher.cpp @@ -21,12 +21,13 @@ #include "ComponentWatcher_Impl.hpp" #include "Model.hpp" -#include "Model_Impl.hpp" +#include "Model_Impl.hpp" #include "ModelObject.hpp" #include "ModelObject_Impl.hpp" #include "ComponentData_Impl.hpp" +#include "nano_signal_slot.hpp" #include "../utilities/core/Assert.hpp" #include "../utilities/core/Compare.hpp" @@ -55,24 +56,23 @@ namespace detail { // connect to object's signals implPtr = object.getImpl(); // data change - connect(implPtr.get(), &ModelObject_Impl::onDataChange, this, &ComponentWatcher_Impl::dataChange); + implPtr.get()->ModelObject_Impl::onDataChange.connect(this); // name change - connect(implPtr.get(), &ModelObject_Impl::onNameChange, this, &ComponentWatcher_Impl::nameChange); + implPtr.get()->ModelObject_Impl::onNameChange.connect(this); // relationship change - connect(implPtr.get(), &ModelObject_Impl::onRelationshipChange, this, &ComponentWatcher_Impl::relationshipChange); + implPtr.get()->ModelObject_Impl::onRelationshipChange.connect(this); // remove - connect(implPtr.get(), &ModelObject_Impl::onRemoveFromWorkspace, this, &ComponentWatcher_Impl::objectRemove); + implPtr.get()->ModelObject_Impl::onRemoveFromWorkspace.connect(this); } // connect signals for ComponentData, ComponentDataTags, and ComponentDataAttributes implPtr = componentData.getImpl(); // component data change - connect(implPtr.get(), &ModelObject_Impl::onDataChange, this, &ComponentWatcher_Impl::componentDataChange); + implPtr.get()->ModelObject_Impl::onDataChange.connect(this); // component data remove - connect(implPtr.get(), &ModelObject_Impl::onRemoveFromWorkspace, this, &ComponentWatcher_Impl::objectRemove); + implPtr.get()->ModelObject_Impl::onRemoveFromWorkspace.connect(this); // connect to addWorkspaceObject signal std::shared_ptr modelImplPtr = m_componentData.model().getImpl(); - connect(modelImplPtr.get(), static_cast(&Model_Impl::addWorkspaceObject), - this, &ComponentWatcher_Impl::objectAdd); + modelImplPtr.get()->Model_Impl::addWorkspaceObject.connect(this); } ComponentWatcher ComponentWatcher_Impl::componentWatcher() const { @@ -111,17 +111,20 @@ namespace detail { } void ComponentWatcher_Impl::objectRemove(const Handle& handleOfRemovedObject) { + // no ComponentData means no Component to watch if (handleOfRemovedObject == m_componentData.handle()) { - emit obsolete(componentWatcher()); + this->obsolete.nano_emit(componentWatcher()); return; } + // if removedObject is the primary componentObject, nullify the component. OS_ASSERT(m_componentObjects.size() > 0); if (handleOfRemovedObject == m_componentObjects[0].handle()) { mf_removeComponent(); return; } + // if removedObject is a componentObject, remove from the vector and refresh // component contents auto it = std::find_if(m_componentObjects.begin(), @@ -135,7 +138,7 @@ namespace detail { return; } - void ComponentWatcher_Impl::objectAdd(const WorkspaceObject& addedObject) { + void ComponentWatcher_Impl::objectAdd(const WorkspaceObject& addedObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { /*IddObjectType type =*/ addedObject.iddObject().type(); return; } @@ -143,19 +146,19 @@ namespace detail { void ComponentWatcher_Impl::mf_changeComponentVersion() { // disconnect componentDataChange slot to avoid endless loop std::shared_ptr implPtr = m_componentData.getImpl(); - disconnect(implPtr.get(), &ModelObject_Impl::onDataChange, this, &ComponentWatcher_Impl::componentDataChange); + implPtr.get()->ModelObject_Impl::onDataChange.disconnect(this); // change version UUID m_componentData.createVersionUUID(); // reconnect componentDataChange - connect(implPtr.get(), &ModelObject_Impl::onDataChange, this, &ComponentWatcher_Impl::componentDataChange); + implPtr.get()->ModelObject_Impl::onDataChange.connect(this); } void ComponentWatcher_Impl::mf_refreshComponentContents(bool logWarnings) { // disconnect componentDataChange slot to avoid endless loop std::shared_ptr implPtr = m_componentData.getImpl(); - disconnect(implPtr.get(), &ModelObject_Impl::onDataChange, this, &ComponentWatcher_Impl::componentDataChange); + implPtr.get()->ModelObject_Impl::onDataChange.disconnect(this); // \todo logWarnings m_componentData.clearExtensibleGroups(); @@ -164,7 +167,7 @@ namespace detail { } // reconnect componentDataChange - connect(implPtr.get(), &ModelObject_Impl::onDataChange, this, &ComponentWatcher_Impl::componentDataChange); + implPtr.get()->ModelObject_Impl::onDataChange.connect(this); } void ComponentWatcher_Impl::mf_removeComponent() { diff --git a/openstudiocore/src/model/ComponentWatcher_Impl.hpp b/openstudiocore/src/model/ComponentWatcher_Impl.hpp index e2284ef6d3b..b85058fb44f 100644 --- a/openstudiocore/src/model/ComponentWatcher_Impl.hpp +++ b/openstudiocore/src/model/ComponentWatcher_Impl.hpp @@ -26,6 +26,9 @@ #include "../utilities/core/Logger.hpp" +// Signals/Slots QT Replacement +#include "nano_signal_slot.hpp" + #include namespace openstudio { @@ -54,9 +57,10 @@ namespace detail { ComponentData componentData() const; //@} - signals: - - void obsolete(const ComponentWatcher& watcher); + /** @name Nano Signals */ + //@{ + + Nano::Signal obsolete; public slots: @@ -70,7 +74,7 @@ namespace detail { void objectRemove(const Handle& handleOfRemovedObject); - void objectAdd(const WorkspaceObject& addedObject); + void objectAdd(const WorkspaceObject& addedObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); private: ComponentData m_componentData; diff --git a/openstudiocore/src/model/Model.cpp b/openstudiocore/src/model/Model.cpp index 98c46f3842b..5ee6b54d3fe 100644 --- a/openstudiocore/src/model/Model.cpp +++ b/openstudiocore/src/model/Model.cpp @@ -1000,7 +1000,7 @@ if (_className::iddObjectType() == typeToCreate) { \ boost::optional result = this->model().getOptionalUniqueModelObject(); if (result){ m_cachedBuilding = result; - QObject::connect(result->getImpl().get(), &Building_Impl::onRemoveFromWorkspace, this, &Model_Impl::clearCachedBuilding); + result->getImpl().get()->Building_Impl::onRemoveFromWorkspace.connect(const_cast(this)); } return m_cachedBuilding; @@ -1015,8 +1015,7 @@ if (_className::iddObjectType() == typeToCreate) { \ boost::optional result = this->model().getOptionalUniqueModelObject(); if (result){ m_cachedLifeCycleCostParameters = result; - QObject::connect(result->getImpl().get(), &LifeCycleCostParameters_Impl::onRemoveFromWorkspace, - this, &Model_Impl::clearCachedLifeCycleCostParameters); + result->getImpl().get()->LifeCycleCostParameters_Impl::onRemoveFromWorkspace.connect(const_cast(this)); } return m_cachedLifeCycleCostParameters; @@ -1031,7 +1030,7 @@ if (_className::iddObjectType() == typeToCreate) { \ boost::optional result = this->model().getOptionalUniqueModelObject(); if (result){ m_cachedRunPeriod = result; - QObject::connect(result->getImpl().get(), &RunPeriod_Impl::onRemoveFromWorkspace, this, &Model_Impl::clearCachedRunPeriod); + result->getImpl().get()->RunPeriod_Impl::onRemoveFromWorkspace.connect(const_cast(this)); } return m_cachedRunPeriod; @@ -1046,8 +1045,7 @@ if (_className::iddObjectType() == typeToCreate) { \ boost::optional result = this->model().getOptionalUniqueModelObject(); if (result){ m_cachedYearDescription = result; - QObject::connect(result->getImpl().get(), &YearDescription_Impl::onRemoveFromWorkspace, - this, &Model_Impl::clearCachedYearDescription); + result->getImpl().get()->YearDescription_Impl::onRemoveFromWorkspace.connect(const_cast(this)); } return m_cachedYearDescription; @@ -1062,7 +1060,7 @@ if (_className::iddObjectType() == typeToCreate) { \ boost::optional result = this->model().getOptionalUniqueModelObject(); if (result){ m_cachedWeatherFile = result; - QObject::connect(result->getImpl().get(), &WeatherFile_Impl::onRemoveFromWorkspace, this, &Model_Impl::clearCachedWeatherFile); + result->getImpl().get()->WeatherFile_Impl::onRemoveFromWorkspace.connect(const_cast(this)); } return m_cachedWeatherFile; @@ -1472,15 +1470,15 @@ if (_className::iddObjectType() == typeToCreate) { \ void Model_Impl::reportInitialModelObjects() { for (const WorkspaceObject& workspaceObject : this->objects()) { - emit initialModelObject(workspaceObject.getImpl().get(), workspaceObject.iddObject().type(), workspaceObject.handle()); + this->initialModelObject.nano_emit(workspaceObject.getImpl().get(), workspaceObject.iddObject().type(), workspaceObject.handle()); } - emit initialReportComplete(); + this->initialReportComplete.nano_emit(); } void Model_Impl::mf_createComponentWatcher(ComponentData& componentData) { try { ComponentWatcher watcher(componentData); - QObject::connect(watcher.getImpl().get(), &ComponentWatcher_Impl::obsolete, this, &Model_Impl::obsoleteComponentWatcher); + watcher.getImpl().get()->ComponentWatcher_Impl::obsolete.connect(this); // #HASHTAG Problem? m_componentWatchers.push_back(watcher); } catch (...) { @@ -1489,27 +1487,27 @@ if (_className::iddObjectType() == typeToCreate) { \ } } - void Model_Impl::clearCachedBuilding() + void Model_Impl::clearCachedBuilding(const Handle &) { m_cachedBuilding.reset(); } - void Model_Impl::clearCachedLifeCycleCostParameters() + void Model_Impl::clearCachedLifeCycleCostParameters(const Handle &handle) { m_cachedLifeCycleCostParameters.reset(); } - void Model_Impl::clearCachedRunPeriod() + void Model_Impl::clearCachedRunPeriod(const Handle& handle) { m_cachedRunPeriod.reset(); } - void Model_Impl::clearCachedYearDescription() + void Model_Impl::clearCachedYearDescription(const Handle& handle) { m_cachedYearDescription.reset(); } - void Model_Impl::clearCachedWeatherFile() + void Model_Impl::clearCachedWeatherFile(const Handle& handle) { m_cachedWeatherFile.reset(); } diff --git a/openstudiocore/src/model/ModelObject.cpp b/openstudiocore/src/model/ModelObject.cpp index 729e49c47d8..d60f2cf1cab 100644 --- a/openstudiocore/src/model/ModelObject.cpp +++ b/openstudiocore/src/model/ModelObject.cpp @@ -800,7 +800,7 @@ namespace detail { } properties.insert(*it, value); } - emit reportProperties(properties); + this->reportProperties.nano_emit(properties); } void ModelObject_Impl::setProperties(const QVariantMap& properties) @@ -818,7 +818,7 @@ namespace detail { } if (anyFailures){ - emit onChange(); + this->onChange.nano_emit(); } } diff --git a/openstudiocore/src/model/ModelObject_Impl.hpp b/openstudiocore/src/model/ModelObject_Impl.hpp index 27217e6c424..56891bb286b 100644 --- a/openstudiocore/src/model/ModelObject_Impl.hpp +++ b/openstudiocore/src/model/ModelObject_Impl.hpp @@ -22,6 +22,7 @@ #include "ModelAPI.hpp" #include "ModelObject.hpp" // required for Q_PROPERTY +#include "nano_signal_slot.hpp" // Signal-Slot replacement #include "../utilities/idf/WorkspaceObject_Impl.hpp" @@ -229,16 +230,19 @@ namespace detail { boost::optional connectedObjectPort(unsigned port) const; //@} + /** @name Nano Signals */ + //@{ + + Nano::Signal reportProperties; + + //@} + public slots: void requestProperties(const QStringList& names); void setProperties(const QVariantMap& properties); - signals: - - void reportProperties(const QVariantMap& properties); - protected: ModelObject_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle); diff --git a/openstudiocore/src/model/Model_Impl.hpp b/openstudiocore/src/model/Model_Impl.hpp index 10a145ea874..e07abc66263 100644 --- a/openstudiocore/src/model/Model_Impl.hpp +++ b/openstudiocore/src/model/Model_Impl.hpp @@ -27,6 +27,8 @@ #include "YearDescription.hpp" #include "WeatherFile.hpp" +#include "nano_signal_slot.hpp" // Signal-Slot replacement + #include "../utilities/idf/Workspace.hpp" #include "../utilities/idf/Workspace_Impl.hpp" #include "../utilities/idf/WorkspaceObject.hpp" @@ -197,17 +199,23 @@ namespace detail { void disconnect(ModelObject object, unsigned port); - public slots : + //@} + /** @name Nano Signals */ + //@{ - virtual void obsoleteComponentWatcher(const ComponentWatcher& watcher); + Nano::Signal initialModelObject; - virtual void reportInitialModelObjects(); + Nano::Signal initialReportComplete; - signals: + //@} - void initialModelObject(openstudio::model::detail::ModelObject_Impl* modelObject, IddObjectType iddObjectType, const openstudio::UUID& handle); + // public slots : + + virtual void obsoleteComponentWatcher(const ComponentWatcher& watcher); + + virtual void reportInitialModelObjects(); - void initialReportComplete(); + private: // explicitly unimplemented copy constructor @@ -236,13 +244,13 @@ namespace detail { mutable boost::optional m_cachedYearDescription; mutable boost::optional m_cachedWeatherFile; - private slots: + // private slots: - void clearCachedBuilding(); - void clearCachedLifeCycleCostParameters(); - void clearCachedRunPeriod(); - void clearCachedYearDescription(); - void clearCachedWeatherFile(); + void clearCachedBuilding(const Handle& handle); + void clearCachedLifeCycleCostParameters(const Handle& handle); + void clearCachedRunPeriod(const Handle& handle); + void clearCachedYearDescription(const Handle& handle); + void clearCachedWeatherFile(const Handle& handle); }; diff --git a/openstudiocore/src/model/PlanarSurface.cpp b/openstudiocore/src/model/PlanarSurface.cpp index 74f31fa0104..4f7eb3aebe5 100644 --- a/openstudiocore/src/model/PlanarSurface.cpp +++ b/openstudiocore/src/model/PlanarSurface.cpp @@ -70,7 +70,7 @@ namespace model { : ParentObject_Impl(type, model) { // connect signals - connect(this, &PlanarSurface_Impl::onChange, this, &PlanarSurface_Impl::clearCachedVariables); + this->PlanarSurface_Impl::onChange.connect(this); } // constructor @@ -80,7 +80,7 @@ namespace model { : ParentObject_Impl(idfObject, model, keepHandle) { // connect signals - connect(this, &PlanarSurface_Impl::onChange, this, &PlanarSurface_Impl::clearCachedVariables); + this->PlanarSurface_Impl::onChange.connect(this); } PlanarSurface_Impl::PlanarSurface_Impl(const openstudio::detail::WorkspaceObject_Impl& other, @@ -89,7 +89,7 @@ namespace model { : ParentObject_Impl(other,model,keepHandle) { // connect signals - connect(this, &PlanarSurface_Impl::onChange, this, &PlanarSurface_Impl::clearCachedVariables); + this->PlanarSurface_Impl::onChange.connect(this); } PlanarSurface_Impl::PlanarSurface_Impl(const PlanarSurface_Impl& other, @@ -98,9 +98,9 @@ namespace model { : ParentObject_Impl(other,model,keepHandle) { // connect signals - connect(this, &PlanarSurface_Impl::onChange, this, &PlanarSurface_Impl::clearCachedVariables); + this->PlanarSurface_Impl::onChange.connect(this); } - + boost::optional PlanarSurface_Impl::construction() const { boost::optional > result = this->constructionWithSearchDistance(); diff --git a/openstudiocore/src/model/PlanarSurfaceGroup.cpp b/openstudiocore/src/model/PlanarSurfaceGroup.cpp index fc31645e00a..7067925f810 100644 --- a/openstudiocore/src/model/PlanarSurfaceGroup.cpp +++ b/openstudiocore/src/model/PlanarSurfaceGroup.cpp @@ -42,7 +42,7 @@ namespace detail { : ParentObject_Impl(idfObject, model, keepHandle) { // connect signals - connect(this, &PlanarSurfaceGroup_Impl::onChange, this, &PlanarSurfaceGroup_Impl::clearCachedVariables); + this->PlanarSurfaceGroup_Impl::onChange.connect(this); } PlanarSurfaceGroup_Impl::PlanarSurfaceGroup_Impl(const openstudio::detail::WorkspaceObject_Impl& other, @@ -51,7 +51,7 @@ namespace detail { : ParentObject_Impl(other,model,keepHandle) { // connect signals - connect(this, &PlanarSurfaceGroup_Impl::onChange, this, &PlanarSurfaceGroup_Impl::clearCachedVariables); + this->PlanarSurfaceGroup_Impl::onChange.connect(this); } PlanarSurfaceGroup_Impl::PlanarSurfaceGroup_Impl(const PlanarSurfaceGroup_Impl& other, @@ -60,7 +60,7 @@ namespace detail { : ParentObject_Impl(other,model,keepHandle) { // connect signals - connect(this, &PlanarSurfaceGroup_Impl::onChange, this, &PlanarSurfaceGroup_Impl::clearCachedVariables); + this->PlanarSurfaceGroup_Impl::onChange.connect(this); } openstudio::Transformation PlanarSurfaceGroup_Impl::transformation() const diff --git a/openstudiocore/src/model/PlanarSurfaceGroup_Impl.hpp b/openstudiocore/src/model/PlanarSurfaceGroup_Impl.hpp index ee469103ef4..4b4191b32c4 100644 --- a/openstudiocore/src/model/PlanarSurfaceGroup_Impl.hpp +++ b/openstudiocore/src/model/PlanarSurfaceGroup_Impl.hpp @@ -105,6 +105,8 @@ namespace detail { /** Get the BoundingBox in local coordinates. */ virtual openstudio::BoundingBox boundingBox() const = 0; + Nano::Signal onChange; + //@} private slots: diff --git a/openstudiocore/src/model/ScheduleDay.cpp b/openstudiocore/src/model/ScheduleDay.cpp index f8a4bc82880..b25e1f95717 100644 --- a/openstudiocore/src/model/ScheduleDay.cpp +++ b/openstudiocore/src/model/ScheduleDay.cpp @@ -54,7 +54,7 @@ namespace detail { OS_ASSERT(idfObject.iddObject().type() == ScheduleDay::iddObjectType()); // connect signals - connect(this, &ScheduleDay_Impl::onChange, this, &ScheduleDay_Impl::clearCachedVariables); + this->ScheduleDay_Impl::onChange.connect(this); } ScheduleDay_Impl::ScheduleDay_Impl(const openstudio::detail::WorkspaceObject_Impl& other, @@ -65,7 +65,7 @@ namespace detail { OS_ASSERT(other.iddObject().type() == ScheduleDay::iddObjectType()); // connect signals - connect(this, &ScheduleDay_Impl::onChange, this, &ScheduleDay_Impl::clearCachedVariables); + this->ScheduleDay_Impl::onChange.connect(this); } ScheduleDay_Impl::ScheduleDay_Impl(const ScheduleDay_Impl& other, @@ -74,7 +74,7 @@ namespace detail { : ScheduleBase_Impl(other,model,keepHandle) { // connect signals - connect(this, &ScheduleDay_Impl::onChange, this, &ScheduleDay_Impl::clearCachedVariables); + this->ScheduleDay_Impl::onChange.connect(this); } std::vector ScheduleDay_Impl::remove() { diff --git a/openstudiocore/src/model/nano_function.hpp b/openstudiocore/src/model/nano_function.hpp new file mode 100644 index 00000000000..3ba5bfe1496 --- /dev/null +++ b/openstudiocore/src/model/nano_function.hpp @@ -0,0 +1,73 @@ +#ifndef NANO_FUNCTION_HPP +#define NANO_FUNCTION_HPP + +#include +#include + +namespace Nano +{ + +using DelegateKey = std::array; + +template class Function; +template +class Function +{ + using Thunk = RT (*)(void*, Args...); + + friend class Observer; + + void* m_this_ptr; // instance pointer + Thunk m_stub_ptr; // free function pointer + + Function(void* this_ptr, Thunk stub_ptr) : + m_this_ptr(this_ptr), m_stub_ptr(stub_ptr) {} + + Function(DelegateKey delegate_key) : + m_this_ptr(reinterpret_cast(delegate_key[0])), + m_stub_ptr(reinterpret_cast(delegate_key[1])) {} + + public: + + template + static inline Function bind() + { + return { nullptr, [](void* /*NULL*/, Args... args) + { return (*fun_ptr)(std::forward(args)...); } }; + } + template + static inline Function bind(T* pointer) + { + return { pointer, [](void* this_ptr, Args... args) + { return (static_cast(this_ptr)->*mem_ptr) (std::forward(args)...); } }; + } + template + static inline Function bind(T* pointer) + { + return { pointer, [](void* this_ptr, Args... args) + { return (static_cast(this_ptr)->*mem_ptr) (std::forward(args)...); } }; + } + template + static inline Function bind(L* pointer) + { + return { pointer, [](void *this_ptr, Args... args) + { return (static_cast(this_ptr)->operator()(std::forward(args)...)); }}; + } + inline operator DelegateKey() const + { + return + {{ + reinterpret_cast(m_this_ptr), + reinterpret_cast(m_stub_ptr) + }}; + } + template + inline RT operator() (Uref&&... args) + { + return (*m_stub_ptr)(m_this_ptr, std::forward(args)...); + } +}; + +} // namespace Nano ------------------------------------------------------------ + +#endif // NANO_FUNCTION_HPP diff --git a/openstudiocore/src/model/nano_observer.hpp b/openstudiocore/src/model/nano_observer.hpp new file mode 100644 index 00000000000..0a8eb4a26a7 --- /dev/null +++ b/openstudiocore/src/model/nano_observer.hpp @@ -0,0 +1,117 @@ +#ifndef NANO_OBSERVER_HPP +#define NANO_OBSERVER_HPP + +#include "nano_function.hpp" + +namespace Nano +{ + +class Observer +{ + + template friend class Signal; + + struct DelegateKeyObserver { DelegateKey delegate; Observer* observer; }; + struct Node { DelegateKeyObserver data; Node* next; } *head = nullptr; + + //-----------------------------------------------------------PRIVATE METHODS + + void insert(DelegateKey const& key, Observer* ptr) + { + head = new Node { { key, ptr }, head }; + } + + void insert(DelegateKey const& key) + { + this->insert(key, this); + } + + void remove(DelegateKey const& key) + { + Node* node = head; + Node* prev = nullptr; + // Only delete the first occurrence + for ( ; node; prev = node, node = node->next) + { + if (node->data.delegate == key) + { + if (prev) + { + prev->next = node->next; + } + else + { + head = head->next; + } + delete node; + break; + } + } + } + + void removeAll() + { + for (auto node = head; node;) + { + auto temp = node; + // If this is us we only need to delete + if (this != node->data.observer) + { + // Remove this slot from this listening Observer + node->data.observer->remove(node->data.delegate); + } + node = node->next; + delete temp; + } + head = nullptr; + } + + bool isEmpty() const + { + return head == nullptr; + } + + template + void onEach(Uref&&... args) + { + for (auto node = head, next = head; node; node = next) + { + next = node->next; + // Perfect forward and emit + Delegate(node->data.delegate)(std::forward(args)...); + } + } + + template + void onEach_Accumulate(Accumulate&& accumulate, Uref&&... args) + { + for (auto node = head, next = head; node; node = next) + { + next = node->next; + // Perfect forward, emit, and accumulate the return value + accumulate(Delegate(node->data.delegate)(std::forward(args)...)); + } + } + + //-----------------------------------------------------------------PROTECTED + + protected: + + ~Observer() + { + removeAll(); + } + + //--------------------------------------------------------------------PUBLIC + + public: + + Observer() = default; + Observer(const Observer& other) = delete; // non construction-copyable + Observer& operator=(const Observer&) = delete; // non copyable + +}; + +} // namespace Nano ------------------------------------------------------------ + +#endif // NANO_OBSERVER_HPP diff --git a/openstudiocore/src/model/nano_signal_slot.hpp b/openstudiocore/src/model/nano_signal_slot.hpp new file mode 100644 index 00000000000..4ee728fb0c1 --- /dev/null +++ b/openstudiocore/src/model/nano_signal_slot.hpp @@ -0,0 +1,172 @@ +#ifndef NANO_SIGNAL_SLOT_HPP +#define NANO_SIGNAL_SLOT_HPP + +#include "nano_function.hpp" +#include "nano_observer.hpp" + +namespace Nano +{ + +template class Signal; +template +class Signal : private Observer +{ + template + void insert_sfinae(DelegateKey const& key, typename T::Observer* instance) + { + Observer::insert(key, instance); + instance->insert(key, this); + } + template + void remove_sfinae(DelegateKey const& key, typename T::Observer* instance) + { + Observer::remove(key); + instance->remove(key); + } + template + void insert_sfinae(DelegateKey const& key, ...) + { + Observer::insert(key); + } + template + void remove_sfinae(DelegateKey const& key, ...) + { + Observer::remove(key); + } + + public: + + using Delegate = Function; + + //-------------------------------------------------------------------CONNECT + + template + void connect(L* instance) + { + Observer::insert(Delegate::template bind (instance)); + } + template + void connect(L& instance) + { + connect(std::addressof(instance)); + } + + template + void connect() + { + Observer::insert(Delegate::template bind()); + } + + template + void connect(T* instance) + { + insert_sfinae(Delegate::template bind(instance), instance); + } + template + void connect(T* instance) + { + insert_sfinae(Delegate::template bind(instance), instance); + } + + template + void connect(T& instance) + { + connect(std::addressof(instance)); + } + template + void connect(T& instance) + { + connect(std::addressof(instance)); + } + + //----------------------------------------------------------------DISCONNECT + + template + void disconnect(L* instance) + { + Observer::remove(Delegate::template bind (instance)); + } + template + void disconnect(L& instance) + { + disconnect(std::addressof(instance)); + } + + template + void disconnect() + { + Observer::remove(Delegate::template bind()); + } + + template + void disconnect(T* instance) + { + remove_sfinae(Delegate::template bind(instance), instance); + } + template + void disconnect(T* instance) + { + remove_sfinae(Delegate::template bind(instance), instance); + } + + template + void disconnect(T& instance) + { + disconnect(std::addressof(instance)); + } + template + void disconnect(T& instance) + { + disconnect(std::addressof(instance)); + } + + //----------------------------------------------------EMIT / EMIT ACCUMULATE + + #ifdef NANO_USE_DEPRECATED + + /// Will not benefit from perfect forwarding + /// TODO [[deprecated]] when c++14 is comfortably supported + + void operator() (Args... args) + { + emit(std::forward(args)...); + } + template + void operator() (Args... args, Accumulate&& accumulate) + { + emit_accumulate + (std::forward(accumulate), std::forward(args)...); + } + + #endif + + template + void nano_emit(Uref&&... args) + { + Observer::onEach(std::forward(args)...); + } + + template + void emit_accumulate(Accumulate&& accumulate, Uref&&... args) + { + Observer::onEach_Accumulate + (std::forward(accumulate), std::forward(args)...); + } + + //-------------------------------------------------------------------UTILITY + + bool empty() const + { + return Observer::isEmpty(); + } + + void removeAll() + { + Observer::removeAll(); + } + +}; + +} // namespace Nano ------------------------------------------------------------ + +#endif // NANO_SIGNAL_SLOT_HPP diff --git a/openstudiocore/src/model_editor/InspectorDialog.cpp b/openstudiocore/src/model_editor/InspectorDialog.cpp index ca500e1cefb..4beaa7771cf 100644 --- a/openstudiocore/src/model_editor/InspectorDialog.cpp +++ b/openstudiocore/src/model_editor/InspectorDialog.cpp @@ -433,7 +433,7 @@ void InspectorDialog::onTableWidgetSelectionChanged() setSelectedObjectHandles(selectedObjectHandles, true); } -void InspectorDialog::onAddWorkspaceObject(std::shared_ptr impl) +void InspectorDialog::onAddWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { m_workspaceObjectAdded = true; m_workspaceChanged = true; @@ -483,7 +483,7 @@ void InspectorDialog::onTimeout() } } -void InspectorDialog::onRemoveWorkspaceObject(std::shared_ptr impl) +void InspectorDialog::onRemoveWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { m_workspaceObjectRemoved = true; m_workspaceChanged = true; @@ -942,17 +942,11 @@ void InspectorDialog::connectSelfSignalsAndSlots() void InspectorDialog::connectModelSignalsAndSlots() { - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &InspectorDialog::onAddWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(m_model.getImpl().get(), &model::detail::Model_Impl::onChange, this, &InspectorDialog::onWorkspaceChange); + m_model.getImpl().get()->model::detail::Model_Impl::onChange.connect(this); - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &InspectorDialog::onRemoveWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); } void InspectorDialog::hideSelectionWidget(bool hideSelectionWidget) diff --git a/openstudiocore/src/model_editor/InspectorDialog.hpp b/openstudiocore/src/model_editor/InspectorDialog.hpp index b847abeaa8f..49b608d90b5 100644 --- a/openstudiocore/src/model_editor/InspectorDialog.hpp +++ b/openstudiocore/src/model_editor/InspectorDialog.hpp @@ -148,10 +148,10 @@ private slots: //void onCheckBox(bool checked); void onListWidgetSelectionChanged(); void onTableWidgetSelectionChanged(); - void onAddWorkspaceObject(std::shared_ptr impl); + void onAddWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); void onWorkspaceChange(); void onTimeout(); - void onRemoveWorkspaceObject(std::shared_ptr impl); + void onRemoveWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); private: diff --git a/openstudiocore/src/model_editor/InspectorGadget.cpp b/openstudiocore/src/model_editor/InspectorGadget.cpp index 3577ed26552..f33fb0a24fb 100644 --- a/openstudiocore/src/model_editor/InspectorGadget.cpp +++ b/openstudiocore/src/model_editor/InspectorGadget.cpp @@ -1228,7 +1228,7 @@ void InspectorGadget::onTimeout() } } -void InspectorGadget::onWorkspaceObjectRemoved() +void InspectorGadget::onWorkspaceObjectRemoved(const openstudio::Handle &) { m_workspaceObjectChanged = true; clear(true); @@ -1236,16 +1236,27 @@ void InspectorGadget::onWorkspaceObjectRemoved() QTimer::singleShot(0,this,SLOT(onTimeout())); } +void InspectorGadget::workspaceObjectRemoved(const openstudio::Handle& handle) +{ + if (m_workspaceObj){ + openstudio::detail::WorkspaceObject_Impl* impl = m_workspaceObj->getImpl().get(); + if (impl){ + impl->openstudio::detail::WorkspaceObject_Impl::workspaceObjectRemovedSignal.nano_emit(handle); + } + } +} + void InspectorGadget::connectWorkspaceObjectSignals() const { if (m_workspaceObj){ openstudio::detail::WorkspaceObject_Impl* impl = m_workspaceObj->getImpl().get(); if (impl){ - connect(impl, &openstudio::detail::WorkspaceObject_Impl::onChange, this, &InspectorGadget::onWorkspaceObjectChanged); + impl->openstudio::detail::WorkspaceObject_Impl::onChange.connect(const_cast(this)); - connect(impl, &openstudio::detail::WorkspaceObject_Impl::onRemoveFromWorkspace, this, &InspectorGadget::workspaceObjectRemoved); + impl->openstudio::detail::WorkspaceObject_Impl::onRemoveFromWorkspace.connect(const_cast(this)); + // impl->openstudio::detail::WorkspaceObject_Impl::onRemoveFromWorkspace.connect(const_cast(this)); // Remove issue of chaining. - connect(this, &InspectorGadget::workspaceObjectRemoved, this, &InspectorGadget::onWorkspaceObjectRemoved); + impl->openstudio::detail::WorkspaceObject_Impl::workspaceObjectRemovedSignal.connect(const_cast(this)); } } } diff --git a/openstudiocore/src/model_editor/InspectorGadget.hpp b/openstudiocore/src/model_editor/InspectorGadget.hpp index 6c669f42a63..2726dd1a127 100644 --- a/openstudiocore/src/model_editor/InspectorGadget.hpp +++ b/openstudiocore/src/model_editor/InspectorGadget.hpp @@ -164,6 +164,10 @@ class MODELEDITOR_API InspectorGadget : public QWidget void setUnitSystem(const UNIT_SYSTEM unitSystem); + void onWorkspaceObjectRemoved(const openstudio::Handle &); + + void workspaceObjectRemoved(const openstudio::Handle &); + public slots: void toggleUnits(bool displayIP); @@ -227,6 +231,11 @@ public slots: void setRecursive( bool recursive); + // void workspaceObjectRemoved(const openstudio::Handle &); + + + // void workspaceObjectRemoved(const openstudio::Handle &); // Slot function of same name -- evaluating + signals: void nameChanged(QString); @@ -240,7 +249,8 @@ public slots: */ void dirty(); - void workspaceObjectRemoved(); + + protected slots: @@ -248,7 +258,7 @@ protected slots: void onTimeout(); - void onWorkspaceObjectRemoved(); + // void onWorkspaceObjectRemoved(const openstudio::Handle &); protected: diff --git a/openstudiocore/src/model_editor/ModalDialogs.cpp b/openstudiocore/src/model_editor/ModalDialogs.cpp index 087d39b2a7b..973e3be8c16 100644 --- a/openstudiocore/src/model_editor/ModalDialogs.cpp +++ b/openstudiocore/src/model_editor/ModalDialogs.cpp @@ -146,7 +146,7 @@ void ModelObjectSelectorDialog::onPushButtonCancel(bool) emit closed(modelObject); } -void ModelObjectSelectorDialog::onAddWorkspaceObject(std::shared_ptr impl) +void ModelObjectSelectorDialog::onAddWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { std::vector::const_iterator it = std::find(m_typesToDisplay.begin(), m_typesToDisplay.end(), impl->iddObject().type()); if (it != m_typesToDisplay.end()){ @@ -154,7 +154,7 @@ void ModelObjectSelectorDialog::onAddWorkspaceObject(std::shared_ptr impl) +void ModelObjectSelectorDialog::onRemoveWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { std::vector::const_iterator it = std::find(m_typesToDisplay.begin(), m_typesToDisplay.end(), impl->iddObject().type()); if (it != m_typesToDisplay.end()){ @@ -227,15 +227,9 @@ void ModelObjectSelectorDialog::connectSignalsAndSlots() connect(m_cancelButton, &QPushButton::clicked, this, &ModelObjectSelectorDialog::onPushButtonCancel); - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &ModelObjectSelectorDialog::onAddWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &ModelObjectSelectorDialog::onRemoveWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); } void ModelObjectSelectorDialog::loadStyleSheet() diff --git a/openstudiocore/src/model_editor/ModalDialogs.hpp b/openstudiocore/src/model_editor/ModalDialogs.hpp index d1121cca750..6dc5e4f56ab 100644 --- a/openstudiocore/src/model_editor/ModalDialogs.hpp +++ b/openstudiocore/src/model_editor/ModalDialogs.hpp @@ -83,8 +83,8 @@ class MODELEDITOR_API ModelObjectSelectorDialog : public QDialog private slots: - void onAddWorkspaceObject(std::shared_ptr impl); - void onRemoveWorkspaceObject(std::shared_ptr impl); + void onAddWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); + void onRemoveWorkspaceObject(std::shared_ptr impl, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); private: diff --git a/openstudiocore/src/openstudio_lib/GridItem.cpp b/openstudiocore/src/openstudio_lib/GridItem.cpp index b45d9127aa5..07b983f99ef 100644 --- a/openstudiocore/src/openstudio_lib/GridItem.cpp +++ b/openstudiocore/src/openstudio_lib/GridItem.cpp @@ -238,8 +238,7 @@ void ModelObjectGraphicsItem::setModelObject( model::OptionalModelObject modelOb if( m_modelObject ) { - connect(m_modelObject->getImpl().get(), &detail::IdfObject_Impl::onNameChange, - this, &ModelObjectGraphicsItem::onNameChange); + m_modelObject->getImpl().get()->detail::IdfObject_Impl::onNameChange.connect(this); setFlag(QGraphicsItem::ItemIsSelectable); diff --git a/openstudiocore/src/openstudio_lib/HVACSystemsController.cpp b/openstudiocore/src/openstudio_lib/HVACSystemsController.cpp index 008843d609b..c85f2bef38b 100644 --- a/openstudiocore/src/openstudio_lib/HVACSystemsController.cpp +++ b/openstudiocore/src/openstudio_lib/HVACSystemsController.cpp @@ -127,17 +127,11 @@ HVACSystemsController::HVACSystemsController(bool isIP, const model::Model & mod m_hvacControlsController = std::shared_ptr(new HVACControlsController(this)); - connect(m_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::addWorkspaceObject), - this, - &HVACSystemsController::onObjectAdded); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObject.connect(this); - connect(m_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &HVACSystemsController::onObjectRemoved); + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObject.connect(this); - connect(m_hvacSystemsView->hvacToolbarView->addButton, &QPushButton::clicked, this, &HVACSystemsController::onAddSystemClicked); + connect(m_hvacSystemsView->hvacToolbarView->deleteButton, &QPushButton::clicked, this, &HVACSystemsController::onRemoveLoopClicked); @@ -408,7 +402,7 @@ std::vector HVACSystemsController::systemComboBoxTypes() const return types; } -void HVACSystemsController::onObjectAdded(const WorkspaceObject & workspaceObject) +void HVACSystemsController::onObjectAdded(const WorkspaceObject& workspaceObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { std::vector types = systemComboBoxTypes(); @@ -418,7 +412,7 @@ void HVACSystemsController::onObjectAdded(const WorkspaceObject & workspaceObjec } } -void HVACSystemsController::onObjectRemoved(const WorkspaceObject & workspaceObject) +void HVACSystemsController::onObjectRemoved(const WorkspaceObject& workspaceObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { std::vector types = systemComboBoxTypes(); @@ -1493,7 +1487,7 @@ void SystemAvailabilityVectorController::attach(const model::ModelObject& modelO { m_model = m_modelObject->model(); - connect(m_model->getImpl().get(), &model::detail::Model_Impl::onChange, this, &SystemAvailabilityVectorController::reportItemsLater); + m_model->getImpl().get()->model::detail::Model_Impl::onChange.connect(this); } reportItemsLater(); @@ -1508,8 +1502,7 @@ void SystemAvailabilityVectorController::detach() if( m_model ) { - disconnect(m_model->getImpl().get(), &model::detail::Model_Impl::onChange, - this, &SystemAvailabilityVectorController::reportItemsLater); + m_model->getImpl().get()->model::detail::Model_Impl::onChange.connect(this); m_model.reset(); } @@ -1596,7 +1589,7 @@ void SupplyAirTempScheduleVectorController::attach(const model::ModelObject& mod { m_model = m_modelObject->model(); - connect(m_model->getImpl().get(), &model::detail::Model_Impl::onChange, this, &SupplyAirTempScheduleVectorController::reportItemsLater); + m_model->getImpl().get()->model::detail::Model_Impl::onChange.connect(this); } reportItemsLater(); @@ -1611,8 +1604,7 @@ void SupplyAirTempScheduleVectorController::detach() if( m_model ) { - disconnect(m_model->getImpl().get(), &model::detail::Model_Impl::onChange, - this, &SupplyAirTempScheduleVectorController::reportItemsLater); + m_model->getImpl().get()->model::detail::Model_Impl::onChange.connect(this); m_model.reset(); } diff --git a/openstudiocore/src/openstudio_lib/HVACSystemsController.hpp b/openstudiocore/src/openstudio_lib/HVACSystemsController.hpp index 4cdf7417ea6..bd081eea1f8 100644 --- a/openstudiocore/src/openstudio_lib/HVACSystemsController.hpp +++ b/openstudiocore/src/openstudio_lib/HVACSystemsController.hpp @@ -118,9 +118,9 @@ class HVACSystemsController : public QObject void onShowGridClicked(); - void onObjectAdded(const WorkspaceObject&); + void onObjectAdded(const WorkspaceObject&, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); - void onObjectRemoved(const WorkspaceObject&); + void onObjectRemoved(const WorkspaceObject&, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); void onObjectChanged(); diff --git a/openstudiocore/src/openstudio_lib/InspectorView.cpp b/openstudiocore/src/openstudio_lib/InspectorView.cpp index 59d259627a3..7f0ce09958b 100644 --- a/openstudiocore/src/openstudio_lib/InspectorView.cpp +++ b/openstudiocore/src/openstudio_lib/InspectorView.cpp @@ -1316,7 +1316,7 @@ void WaterToAirInspectorView::layoutModelObject( model::ModelObject & modelObjec model::detail::ModelObject_Impl * impl = modelObject.getImpl().get(); - connect(impl, &model::detail::ModelObject_Impl::onChange, this, &WaterToAirInspectorView::onWorkspaceObjectChanged); + impl->model::detail::ModelObject_Impl::onChange.connect(this); } void WaterToAirInspectorView::onWorkspaceObjectChanged() diff --git a/openstudiocore/src/openstudio_lib/LoopScene.cpp b/openstudiocore/src/openstudio_lib/LoopScene.cpp index c9b358ee2fe..d656d65273c 100644 --- a/openstudiocore/src/openstudio_lib/LoopScene.cpp +++ b/openstudiocore/src/openstudio_lib/LoopScene.cpp @@ -54,15 +54,9 @@ LoopScene::LoopScene( model::Loop loop, m_loop(loop), m_dirty(true) { - connect(loop.model().getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &LoopScene::addedWorkspaceObject); + loop.model().getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(loop.model().getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &LoopScene::removedWorkspaceObject); + loop.model().getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); layout(); } @@ -126,7 +120,7 @@ model::Loop LoopScene::loop() return m_loop; } -void LoopScene::addedWorkspaceObject(std::shared_ptr wPtr ) +void LoopScene::addedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid ) { model::detail::HVACComponent_Impl* hvac_impl = dynamic_cast(wPtr.get()); if(hvac_impl) @@ -137,7 +131,7 @@ void LoopScene::addedWorkspaceObject(std::shared_ptr ) +void LoopScene::removedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid ) { m_dirty = true; diff --git a/openstudiocore/src/openstudio_lib/LoopScene.hpp b/openstudiocore/src/openstudio_lib/LoopScene.hpp index e22a89a1827..a7af546af77 100644 --- a/openstudiocore/src/openstudio_lib/LoopScene.hpp +++ b/openstudiocore/src/openstudio_lib/LoopScene.hpp @@ -69,9 +69,9 @@ class LoopScene : public GridScene public slots: - void addedWorkspaceObject(std::shared_ptr wPtr ); + void addedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); - void removedWorkspaceObject(std::shared_ptr wPtr ); + void removedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); void layout(); diff --git a/openstudiocore/src/openstudio_lib/ModelObjectInspectorView.cpp b/openstudiocore/src/openstudio_lib/ModelObjectInspectorView.cpp index f6cefd60073..28527e243b4 100644 --- a/openstudiocore/src/openstudio_lib/ModelObjectInspectorView.cpp +++ b/openstudiocore/src/openstudio_lib/ModelObjectInspectorView.cpp @@ -61,7 +61,7 @@ void ModelObjectInspectorView::selectModelObject(const openstudio::model::ModelO m_modelObject = modelObject; - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onChange, this, &ModelObjectInspectorView::update); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); onSelectModelObject(*m_modelObject); } diff --git a/openstudiocore/src/openstudio_lib/ModelObjectItem.cpp b/openstudiocore/src/openstudio_lib/ModelObjectItem.cpp index 698005f026f..b1f550a12d7 100644 --- a/openstudiocore/src/openstudio_lib/ModelObjectItem.cpp +++ b/openstudiocore/src/openstudio_lib/ModelObjectItem.cpp @@ -59,8 +59,7 @@ ModelObjectItem::ModelObjectItem(const openstudio::model::ModelObject& modelObje { this->setText(QString::fromStdString(m_modelObject.name().get())); - connect(m_modelObject.getImpl().get(), &model::detail::ModelObject_Impl::onChange, - this, &ModelObjectItem::onObjectChanged); + m_modelObject.getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); if (!modelObject.getModelObjectSources().empty()){ m_measureBadge->setMeasureBadgeType(MeasureBadgeType::BCLMeasure); diff --git a/openstudiocore/src/openstudio_lib/ModelObjectListView.cpp b/openstudiocore/src/openstudio_lib/ModelObjectListView.cpp index f8710e42fdc..a82c072bbe7 100644 --- a/openstudiocore/src/openstudio_lib/ModelObjectListView.cpp +++ b/openstudiocore/src/openstudio_lib/ModelObjectListView.cpp @@ -42,17 +42,10 @@ ModelObjectListController::ModelObjectListController(const openstudio::IddObject bool showLocalBCL) : m_iddObjectType(iddObjectType), m_model(model), m_showLocalBCL(showLocalBCL) { - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &ModelObjectListController::objectAdded, - Qt::QueuedConnection); - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &ModelObjectListController::objectRemoved, - Qt::QueuedConnection); + model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); + + model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); } diff --git a/openstudiocore/src/openstudio_lib/ModelObjectTreeItems.cpp b/openstudiocore/src/openstudio_lib/ModelObjectTreeItems.cpp index b8180dd0aef..ad3aa9a52ea 100644 --- a/openstudiocore/src/openstudio_lib/ModelObjectTreeItems.cpp +++ b/openstudiocore/src/openstudio_lib/ModelObjectTreeItems.cpp @@ -150,11 +150,11 @@ ModelObjectTreeItem::ModelObjectTreeItem(const openstudio::model::ModelObject& m this->setText(0, toQString(modelObject.name().get())); this->setStyle(0, ""); - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onNameChange, this, &ModelObjectTreeItem::changeName); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onNameChange.connect(this); - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onChange, this, &ModelObjectTreeItem::change); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, this, &ModelObjectTreeItem::changeRelationship); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); } ModelObjectTreeItem::ModelObjectTreeItem(const std::string& name, const openstudio::model::Model& model, QTreeWidgetItem* parent) diff --git a/openstudiocore/src/openstudio_lib/ModelObjectTreeWidget.cpp b/openstudiocore/src/openstudio_lib/ModelObjectTreeWidget.cpp index db396a126bb..5aaaccbd92b 100644 --- a/openstudiocore/src/openstudio_lib/ModelObjectTreeWidget.cpp +++ b/openstudiocore/src/openstudio_lib/ModelObjectTreeWidget.cpp @@ -48,17 +48,9 @@ ModelObjectTreeWidget::ModelObjectTreeWidget(const model::Model& model, QWidget* m_vLayout->addWidget(m_treeWidget); - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &ModelObjectTreeWidget::objectAdded, - Qt::QueuedConnection); + model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &ModelObjectTreeWidget::objectRemoved, - Qt::QueuedConnection); + model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); } OSItem* ModelObjectTreeWidget::selectedItem() const diff --git a/openstudiocore/src/openstudio_lib/ModelObjectVectorController.cpp b/openstudiocore/src/openstudio_lib/ModelObjectVectorController.cpp index 2a60439e83a..a587d357678 100644 --- a/openstudiocore/src/openstudio_lib/ModelObjectVectorController.cpp +++ b/openstudiocore/src/openstudio_lib/ModelObjectVectorController.cpp @@ -39,26 +39,15 @@ void ModelObjectVectorController::attach(const model::ModelObject& modelObject) attachModel(modelObject.model()); - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &ModelObjectVectorController::objectAdded, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &ModelObjectVectorController::objectRemoved, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, - this, &ModelObjectVectorController::changeRelationship); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onDataChange, - this, &ModelObjectVectorController::dataChange); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onDataChange.connect(this); - connect(m_modelObject->getImpl().get(), &model::detail::ModelObject_Impl::onChange, - this, &ModelObjectVectorController::change); + m_modelObject->getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); } void ModelObjectVectorController::attachModel(const model::Model& model) @@ -70,17 +59,9 @@ void ModelObjectVectorController::attachModel(const model::Model& model) m_model = model; - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &ModelObjectVectorController::objectAdded, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &ModelObjectVectorController::objectRemoved, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); } void ModelObjectVectorController::attachOtherModelObject(const model::ModelObject& modelObject) @@ -94,8 +75,7 @@ void ModelObjectVectorController::attachOtherModelObject(const model::ModelObjec m_otherModelObjects.push_back(modelObject); - connect(modelObject.getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, - this, &ModelObjectVectorController::changeRelationship); + modelObject.getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); } void ModelObjectVectorController::detach() diff --git a/openstudiocore/src/openstudio_lib/OSDocument.cpp b/openstudiocore/src/openstudio_lib/OSDocument.cpp index d322dc715b3..cf97c3d259f 100644 --- a/openstudiocore/src/openstudio_lib/OSDocument.cpp +++ b/openstudiocore/src/openstudio_lib/OSDocument.cpp @@ -457,7 +457,7 @@ namespace openstudio { QTimer::singleShot(0, this, SLOT(weatherFileReset())); } - connect(m_model.getImpl().get(), &model::detail::Model_Impl::onChange, this, &OSDocument::markAsModified); + m_model.getImpl().get()->model::detail::Model_Impl::onChange.connect(this); // Main Right Column diff --git a/openstudiocore/src/openstudio_lib/OSDropZone.cpp b/openstudiocore/src/openstudio_lib/OSDropZone.cpp index 018649c3e00..cd4e35f689b 100644 --- a/openstudiocore/src/openstudio_lib/OSDropZone.cpp +++ b/openstudiocore/src/openstudio_lib/OSDropZone.cpp @@ -680,7 +680,7 @@ void OSDropZone2::dropEvent(QDropEvent *event) connect(m_item, &OSItem::itemRemoveClicked, this, &OSDropZone2::onItemRemoveClicked); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSDropZone2::refresh); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); if(modelObject){ if(OSAppBase::instance()->currentDocument()->fromComponentLibrary(itemId)){ @@ -789,7 +789,7 @@ void OSDropZone2::makeItem() m_item->setParent(this); connect(m_item, &OSItem::itemRemoveClicked, this, &OSDropZone2::onItemRemoveClicked); - connect(modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSDropZone2::refresh); + modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); } } } diff --git a/openstudiocore/src/openstudio_lib/PlanarSurfaceWidget.cpp b/openstudiocore/src/openstudio_lib/PlanarSurfaceWidget.cpp index b8f520b9f81..acffaad713b 100644 --- a/openstudiocore/src/openstudio_lib/PlanarSurfaceWidget.cpp +++ b/openstudiocore/src/openstudio_lib/PlanarSurfaceWidget.cpp @@ -51,8 +51,7 @@ void PlanarSurfaceWidget::attach(const openstudio::model::PlanarSurface& planarS m_planarSurface = planarSurface; - connect(m_planarSurface->getImpl().get(), &model::detail::ModelObject_Impl::onChange, - this, &PlanarSurfaceWidget::refresh); + m_planarSurface->getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); refresh(); } diff --git a/openstudiocore/src/openstudio_lib/RefrigerationController.cpp b/openstudiocore/src/openstudio_lib/RefrigerationController.cpp index cbd56576ab5..a682b132997 100644 --- a/openstudiocore/src/openstudio_lib/RefrigerationController.cpp +++ b/openstudiocore/src/openstudio_lib/RefrigerationController.cpp @@ -756,10 +756,7 @@ RefrigerationSystemListController::RefrigerationSystemListController(Refrigerati { std::shared_ptr doc = OSAppBase::instance()->currentDocument(); model::Model t_model = doc->model(); - connect(t_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::addWorkspaceObject), - this, - &RefrigerationSystemListController::onModelObjectAdd); + t_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObject.connect(this); connect(this, &RefrigerationSystemListController::itemInsertedPrivate, this, &RefrigerationSystemListController::itemInserted, Qt::QueuedConnection); } diff --git a/openstudiocore/src/openstudio_lib/RenderingColorWidget.cpp b/openstudiocore/src/openstudio_lib/RenderingColorWidget.cpp index 669a5f6e162..9b683198a1b 100644 --- a/openstudiocore/src/openstudio_lib/RenderingColorWidget.cpp +++ b/openstudiocore/src/openstudio_lib/RenderingColorWidget.cpp @@ -281,8 +281,7 @@ void RenderingColorWidget::attach(const openstudio::model::RenderingColor& rende m_renderingColor = renderingColor; - connect(m_renderingColor->getImpl().get(), - &model::detail::ModelObject_Impl::onChange, this, &RenderingColorWidget::refresh); + m_renderingColor->getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); refresh(); } diff --git a/openstudiocore/src/openstudio_lib/ScheduleDayView.cpp b/openstudiocore/src/openstudio_lib/ScheduleDayView.cpp index 1697727d67d..ae75f20c11b 100644 --- a/openstudiocore/src/openstudio_lib/ScheduleDayView.cpp +++ b/openstudiocore/src/openstudio_lib/ScheduleDayView.cpp @@ -1951,7 +1951,7 @@ DayScheduleScene::DayScheduleScene(ScheduleDayView * scheduleDayView, const mode { setSceneRect(0,0,SCENEWIDTH,SCENEHEIGHT); - connect(m_scheduleDay.getImpl().get(), &model::detail::ScheduleDay_Impl::onChange, this, &DayScheduleScene::scheduleRefresh); + m_scheduleDay.getImpl().get()->model::detail::ScheduleDay_Impl::onChange.connect(this); refresh(); //scheduleRefresh(); diff --git a/openstudiocore/src/openstudio_lib/SchedulesView.cpp b/openstudiocore/src/openstudio_lib/SchedulesView.cpp index 6f73ec2484b..0c3c65e74ca 100644 --- a/openstudiocore/src/openstudio_lib/SchedulesView.cpp +++ b/openstudiocore/src/openstudio_lib/SchedulesView.cpp @@ -164,17 +164,9 @@ SchedulesView::SchedulesView(bool isIP, const model::Model & model) m_contentLayout->setContentsMargins(0, 0, 0, 0); mainHLayout->addLayout(m_contentLayout, 100); - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &SchedulesView::onModelObjectAdded, - Qt::QueuedConnection); - - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &SchedulesView::onModelObjectRemoved, - Qt::QueuedConnection); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); + + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); // get all schedules std::vector schedules = m_model.getConcreteModelObjects(); @@ -280,10 +272,7 @@ void SchedulesView::addScheduleRule(model::ScheduleRule & rule) { tab->scheduleTabContent()->scheduleRefresh(); - connect(rule.getImpl().get(), - &model::detail::ScheduleRule_Impl::onRemoveFromWorkspace, - tab->scheduleTabContent(), - &ScheduleTabContent::scheduleRefresh); + rule.getImpl().get()->model::detail::ScheduleRule_Impl::onRemoveFromWorkspace.connect(tab->scheduleTabContent()); } } @@ -463,8 +452,7 @@ void SchedulesView::showScheduleRule(model::ScheduleRule scheduleRule) m_contentLayout->addWidget(scheduleView); - connect(scheduleRule.getImpl().get(), &detail::WorkspaceObject_Impl::onRemoveFromWorkspace, - this, &SchedulesView::onScheduleRuleRemoved); + scheduleRule.getImpl().get()->detail::WorkspaceObject_Impl::onRemoveFromWorkspace.connect(this); scheduleView->show(); @@ -474,7 +462,7 @@ void SchedulesView::showScheduleRule(model::ScheduleRule scheduleRule) emit modelObjectSelected(mo, true); } -void SchedulesView::onScheduleRuleRemoved(Handle handle) +void SchedulesView::onScheduleRuleRemoved(const Handle& handle) { // DLM: todo, show something else? showEmptyPage(); @@ -833,8 +821,7 @@ ScheduleTabHeader::ScheduleTabHeader(ScheduleTab * scheduleTab, QWidget * parent connect(this, &ScheduleTabHeader::scheduleClicked, m_scheduleTab, &ScheduleTab::scheduleClicked); - connect(m_scheduleTab->schedule().getImpl().get(), - &model::detail::ScheduleRuleset_Impl::onChange, this, &ScheduleTabHeader::refresh); + m_scheduleTab->schedule().getImpl().get()->model::detail::ScheduleRuleset_Impl::onChange.connect(this); } void ScheduleTabHeader::expand() @@ -1025,7 +1012,7 @@ void ScheduleTabContent::refresh() } } -void ScheduleTabContent::scheduleRefresh() +void ScheduleTabContent::scheduleRefresh(const Handle& handle) { m_dirty = true; @@ -1081,8 +1068,7 @@ ScheduleTabRule::ScheduleTabRule(ScheduleTab * scheduleTab, scheduleRefresh(); - connect(m_scheduleRule.getImpl().get(), &model::detail::ScheduleRule_Impl::onChange, - this, &ScheduleTabRule::scheduleRefresh); + m_scheduleRule.getImpl().get()->model::detail::ScheduleRule_Impl::onChange.connect(this); setMouseTracking(true); } @@ -1807,9 +1793,9 @@ ScheduleRuleView::ScheduleRuleView(bool isIP, // Connect - connect(m_scheduleRule.getImpl().get(), &model::detail::ScheduleRule_Impl::onChange, this, &ScheduleRuleView::scheduleRefresh); + m_scheduleRule.getImpl().get()->model::detail::ScheduleRule_Impl::onChange.connect(this); - connect(m_yearDescription->getImpl().get(), &model::detail::YearDescription_Impl::onChange, this, &ScheduleRuleView::scheduleRefresh); + m_yearDescription->getImpl().get()->model::detail::YearDescription_Impl::onChange.connect(this); connect(this, &ScheduleRuleView::startDateTimeChanged, m_schedulesView, &SchedulesView::startDateTimeChanged); @@ -2042,11 +2028,7 @@ YearOverview::YearOverview(const model::ScheduleRuleset & scheduleRuleset, QWidg mainLayout->addStretch(10); - connect(m_scheduleRuleset.model().getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &YearOverview::onModelAdd, - Qt::QueuedConnection); + m_scheduleRuleset.model().getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); std::vector scheduleRules = m_scheduleRuleset.scheduleRules(); @@ -2054,13 +2036,12 @@ YearOverview::YearOverview(const model::ScheduleRuleset & scheduleRuleset, QWidg it < scheduleRules.end(); ++it) { - connect(it->getImpl().get(), &model::detail::ScheduleRule_Impl::onChange, this, &YearOverview::scheduleRefresh); + it->getImpl().get()->model::detail::ScheduleRule_Impl::onChange.connect(this); } model::YearDescription yearDescription = m_scheduleRuleset.model().getUniqueModelObject(); - connect(yearDescription.getImpl().get(), &model::detail::YearDescription_Impl::onChange, - this, &YearOverview::scheduleRefresh); + yearDescription.getImpl().get()->model::detail::YearDescription_Impl::onChange.connect(this); refresh(); } @@ -2087,8 +2068,7 @@ void YearOverview::onModelAdd(std::shared_ptrscheduleRuleset().handle() == m_scheduleRuleset.handle()) { - connect(scheduleRule->getImpl().get(), &model::detail::ScheduleRule_Impl::onChange, - this, &YearOverview::scheduleRefresh); + scheduleRule->getImpl().get()->model::detail::ScheduleRule_Impl::onChange.connect(this); } } } diff --git a/openstudiocore/src/openstudio_lib/SchedulesView.hpp b/openstudiocore/src/openstudio_lib/SchedulesView.hpp index 75d8e00d61d..0280bc52049 100644 --- a/openstudiocore/src/openstudio_lib/SchedulesView.hpp +++ b/openstudiocore/src/openstudio_lib/SchedulesView.hpp @@ -203,7 +203,7 @@ class SchedulesView : public QWidget void onModelObjectRemoved(std::shared_ptr, const openstudio::IddObjectType&, const openstudio::UUID&); - void onScheduleRuleRemoved(Handle handle); + void onScheduleRuleRemoved(const Handle& handle); private: @@ -379,7 +379,7 @@ class ScheduleTabContent : public QWidget public slots: - void scheduleRefresh(); + void scheduleRefresh(const Handle& handle=NULL); private slots: diff --git a/openstudiocore/src/openstudio_lib/ServiceWaterScene.cpp b/openstudiocore/src/openstudio_lib/ServiceWaterScene.cpp index 3e8687f1c95..f1434b494d0 100644 --- a/openstudiocore/src/openstudio_lib/ServiceWaterScene.cpp +++ b/openstudiocore/src/openstudio_lib/ServiceWaterScene.cpp @@ -39,15 +39,9 @@ ServiceWaterScene::ServiceWaterScene(const model::Model & model) m_dirty(true), m_model(model) { - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &ServiceWaterScene::onAddedWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &ServiceWaterScene::onRemovedWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); layout(); } @@ -73,7 +67,7 @@ model::Model ServiceWaterScene::model() const return m_model; } -void ServiceWaterScene::onAddedWorkspaceObject(std::shared_ptr wPtr ) +void ServiceWaterScene::onAddedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { model::detail::WaterUseConnections_Impl* hvac_impl = dynamic_cast(wPtr.get()); if(hvac_impl) @@ -84,7 +78,7 @@ void ServiceWaterScene::onAddedWorkspaceObject(std::shared_ptr wPtr) +void ServiceWaterScene::onRemovedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { model::detail::WaterUseConnections_Impl* hvac_impl = dynamic_cast(wPtr.get()); if(hvac_impl) @@ -102,15 +96,9 @@ WaterUseConnectionsDetailScene::WaterUseConnectionsDetailScene(const model::Wate { model::Model model = m_waterUseConnections.model(); - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &WaterUseConnectionsDetailScene::onAddedWorkspaceObject); + model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &WaterUseConnectionsDetailScene::onRemovedWorkspaceObject); + model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); layout(); } @@ -136,7 +124,7 @@ void WaterUseConnectionsDetailScene::layout() Q_UNUSED(backgroundItem); } -void WaterUseConnectionsDetailScene::onAddedWorkspaceObject(std::shared_ptr wPtr ) +void WaterUseConnectionsDetailScene::onAddedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { model::detail::WaterUseEquipment_Impl * hvac_impl = dynamic_cast(wPtr.get()); if(hvac_impl) @@ -147,7 +135,7 @@ void WaterUseConnectionsDetailScene::onAddedWorkspaceObject(std::shared_ptr wPtr) +void WaterUseConnectionsDetailScene::onRemovedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { model::detail::WaterUseEquipment_Impl * hvac_impl = dynamic_cast(wPtr.get()); if(hvac_impl) diff --git a/openstudiocore/src/openstudio_lib/ServiceWaterScene.hpp b/openstudiocore/src/openstudio_lib/ServiceWaterScene.hpp index e951e9cc452..14860917c74 100644 --- a/openstudiocore/src/openstudio_lib/ServiceWaterScene.hpp +++ b/openstudiocore/src/openstudio_lib/ServiceWaterScene.hpp @@ -51,9 +51,9 @@ class ServiceWaterScene : public GridScene private slots: - void onAddedWorkspaceObject(std::shared_ptr wPtr ); + void onAddedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); - void onRemovedWorkspaceObject(std::shared_ptr ); + void onRemovedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); private: @@ -84,9 +84,9 @@ class WaterUseConnectionsDetailScene : public GridScene private slots: - void onAddedWorkspaceObject(std::shared_ptr wPtr ); + void onAddedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); - void onRemovedWorkspaceObject(std::shared_ptr ); + void onRemovedWorkspaceObject(std::shared_ptr wPtr, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); private: diff --git a/openstudiocore/src/openstudio_lib/SimSettingsView.cpp b/openstudiocore/src/openstudio_lib/SimSettingsView.cpp index 9c5a290e3b5..287d33a388a 100644 --- a/openstudiocore/src/openstudio_lib/SimSettingsView.cpp +++ b/openstudiocore/src/openstudio_lib/SimSettingsView.cpp @@ -194,8 +194,7 @@ SimSettingsView::SimSettingsView(bool isIP, // when the year settings object changes need to update the year in all child widgets model::YearDescription yearDescription = m_model.getUniqueModelObject(); - connect(yearDescription.getImpl().get(), &model::detail::YearDescription_Impl::onChange, - this, &SimSettingsView::updateYearDescription); + yearDescription.getImpl().get()->model::detail::YearDescription_Impl::onChange.connect(this); createWidgets(); attachAll(); diff --git a/openstudiocore/src/openstudio_lib/SpaceLoadInstancesWidget.cpp b/openstudiocore/src/openstudio_lib/SpaceLoadInstancesWidget.cpp index 0a6452d7e5d..b3c2d0dcde6 100644 --- a/openstudiocore/src/openstudio_lib/SpaceLoadInstancesWidget.cpp +++ b/openstudiocore/src/openstudio_lib/SpaceLoadInstancesWidget.cpp @@ -755,26 +755,18 @@ void SpaceLoadInstancesWidget::attach(const model::Space& space) m_space = space; m_model = space.model(); - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &SpaceLoadInstancesWidget::objectAdded, - Qt::QueuedConnection); - - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &SpaceLoadInstancesWidget::objectRemoved, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); + + m_model->getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); model::Building building = m_model->getUniqueModelObject(); - connect(building.getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, this, &SpaceLoadInstancesWidget::onBuildingRelationshipChange); + building.getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); for (model::SpaceType spaceType : m_model->getConcreteModelObjects()){ - connect(spaceType.getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, this, &SpaceLoadInstancesWidget::onSpaceTypeRelationshipChange); + spaceType.getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); } - connect(m_space->getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, this, &SpaceLoadInstancesWidget::onSpaceRelationshipChange); + m_space->getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); m_dirty = true; QTimer::singleShot(0, this, SLOT(refresh())); @@ -787,23 +779,15 @@ void SpaceLoadInstancesWidget::attach(const model::SpaceType& spaceType) m_spaceType = spaceType; m_model = spaceType.model(); - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &SpaceLoadInstancesWidget::objectAdded, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(m_model->getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &SpaceLoadInstancesWidget::objectRemoved, - Qt::QueuedConnection); + m_model->getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); model::Building building = m_model->getUniqueModelObject(); - connect(building.getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, this, &SpaceLoadInstancesWidget::onBuildingRelationshipChange); + building.getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); for (model::SpaceType spaceType : m_model->getConcreteModelObjects()){ - connect(spaceType.getImpl().get(), &model::detail::ModelObject_Impl::onRelationshipChange, this, &SpaceLoadInstancesWidget::onSpaceTypeRelationshipChange); + spaceType.getImpl().get()->model::detail::ModelObject_Impl::onRelationshipChange.connect(this); } m_dirty = true; @@ -849,7 +833,7 @@ void SpaceLoadInstancesWidget::onSpaceRelationshipChange(int index, Handle newHa void SpaceLoadInstancesWidget::objectAdded(std::shared_ptr impl, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) { if (iddObjectType == IddObjectType::OS_SpaceType){ - connect(impl.get(), &detail::WorkspaceObject_Impl::onRelationshipChange, this, &SpaceLoadInstancesWidget::onSpaceTypeRelationshipChange); + impl.get()->detail::WorkspaceObject_Impl::onRelationshipChange.connect(this); return; } diff --git a/openstudiocore/src/openstudio_lib/UtilityBillFuelTypeListView.cpp b/openstudiocore/src/openstudio_lib/UtilityBillFuelTypeListView.cpp index ca5a4c1860d..5cf4154ba3f 100644 --- a/openstudiocore/src/openstudio_lib/UtilityBillFuelTypeListView.cpp +++ b/openstudiocore/src/openstudio_lib/UtilityBillFuelTypeListView.cpp @@ -37,17 +37,9 @@ UtilityBillFuelTypeListController::UtilityBillFuelTypeListController(const model openstudio::FuelType fuelType) : m_iddObjectType(model::UtilityBill::iddObjectType()), m_fuelType(fuelType), m_model(model) { - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &UtilityBillFuelTypeListController::objectAdded, - Qt::QueuedConnection); + model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); - connect(model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &UtilityBillFuelTypeListController::objectRemoved, - Qt::QueuedConnection); + model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); } diff --git a/openstudiocore/src/openstudio_lib/UtilityBillsView.cpp b/openstudiocore/src/openstudio_lib/UtilityBillsView.cpp index 1541123bcff..b712a266c8b 100644 --- a/openstudiocore/src/openstudio_lib/UtilityBillsView.cpp +++ b/openstudiocore/src/openstudio_lib/UtilityBillsView.cpp @@ -195,7 +195,7 @@ void UtilityBillsInspectorView::createWidgets() yd = m_model.getUniqueModelObject(); } OS_ASSERT(yd); - connect(yd->getImpl().get(), &model::detail::YearDescription_Impl::onChange, this, &UtilityBillsInspectorView::updateRunPeriodDates); + yd->getImpl().get()->model::detail::YearDescription_Impl::onChange.connect(this); // Regular inspector body @@ -887,8 +887,7 @@ void BillingPeriodWidget::attach(openstudio::model::BillingPeriod & billingPerio } model::ModelObject modelObject = m_billingPeriod->getObject(); - connect(modelObject.getImpl().get(), &model::detail::ModelObject_Impl::onChange, - this, &BillingPeriodWidget::modelObjectChanged); + modelObject.getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); if(m_startDateEdit){ m_startDateEdit->setEnabled(true); diff --git a/openstudiocore/src/openstudio_lib/VariablesTabView.cpp b/openstudiocore/src/openstudio_lib/VariablesTabView.cpp index 91286b5fdda..629253e665c 100644 --- a/openstudiocore/src/openstudio_lib/VariablesTabView.cpp +++ b/openstudiocore/src/openstudio_lib/VariablesTabView.cpp @@ -135,15 +135,9 @@ namespace openstudio { VariablesList::VariablesList(openstudio::model::Model t_model) : m_model(t_model), m_dirty(true) { - connect(t_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::addWorkspaceObject), - this, - &VariablesList::onAdded); - - connect(t_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &VariablesList::onRemoved); + t_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObject.connect(this); + + t_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObject.connect(this); auto vbox = new QVBoxLayout(); vbox->setContentsMargins(10,10,10,10); vbox->setSpacing(10); diff --git a/openstudiocore/src/openstudio_lib/YearSettingsWidget.cpp b/openstudiocore/src/openstudio_lib/YearSettingsWidget.cpp index 75b79a16561..b40b69dd85e 100644 --- a/openstudiocore/src/openstudio_lib/YearSettingsWidget.cpp +++ b/openstudiocore/src/openstudio_lib/YearSettingsWidget.cpp @@ -245,17 +245,11 @@ YearSettingsWidget::YearSettingsWidget(const model::Model & model, QWidget * par // Connect - connect(m_yearDescription->getImpl().get(), &model::detail::YearDescription_Impl::onChange, - this, &YearSettingsWidget::scheduleRefresh); - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject), - this, - &YearSettingsWidget::onWorkspaceObjectAdd); - - connect(m_model.getImpl().get(), - static_cast, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &YearSettingsWidget::onWorkspaceObjectRemove); + m_yearDescription->getImpl().get()->model::detail::YearDescription_Impl::onChange.connect(this); + + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObjectPtr.connect(this); + + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObjectPtr.connect(this); connect(m_startWeekBox, static_cast(&OSComboBox::currentIndexChanged), this, &YearSettingsWidget::onDstStartDayWeekMonthChanged); @@ -283,20 +277,17 @@ bool YearSettingsWidget::calendarYearChecked() { } } -void YearSettingsWidget::onWorkspaceObjectAdd(std::shared_ptr wo) +void YearSettingsWidget::onWorkspaceObjectAdd(std::shared_ptr wo, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { if(wo->iddObject().type() == IddObjectType::OS_RunPeriodControl_DaylightSavingTime) { - connect(wo.get(), - &detail::WorkspaceObject_Impl::onChange, - this, - &YearSettingsWidget::scheduleRefresh); + wo.get()->detail::WorkspaceObject_Impl::onChange.connect(this); scheduleRefresh(); } } -void YearSettingsWidget::onWorkspaceObjectRemove(std::shared_ptr wo) +void YearSettingsWidget::onWorkspaceObjectRemove(std::shared_ptr wo, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { if(wo->iddObject().type() == IddObjectType::OS_RunPeriodControl_DaylightSavingTime) { diff --git a/openstudiocore/src/openstudio_lib/YearSettingsWidget.hpp b/openstudiocore/src/openstudio_lib/YearSettingsWidget.hpp index aa0a3e7d090..8e56c8ab0aa 100644 --- a/openstudiocore/src/openstudio_lib/YearSettingsWidget.hpp +++ b/openstudiocore/src/openstudio_lib/YearSettingsWidget.hpp @@ -93,9 +93,9 @@ class YearSettingsWidget : public QWidget void onFirstDayofYearClicked(); - void onWorkspaceObjectAdd(std::shared_ptr wo); + void onWorkspaceObjectAdd(std::shared_ptr wo, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); - void onWorkspaceObjectRemove(std::shared_ptr wo); + void onWorkspaceObjectRemove(std::shared_ptr wo, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); void onDstStartDayWeekMonthChanged(); diff --git a/openstudiocore/src/shared_gui_components/OSCheckBox.cpp b/openstudiocore/src/shared_gui_components/OSCheckBox.cpp index d9a565728ed..59ed532614a 100644 --- a/openstudiocore/src/shared_gui_components/OSCheckBox.cpp +++ b/openstudiocore/src/shared_gui_components/OSCheckBox.cpp @@ -50,9 +50,9 @@ namespace openstudio { setEnabled(true); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSCheckBox3::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSCheckBox3::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSCheckBox3::toggled, this, &OSCheckBox3::onToggled); bool checked = (*m_get)(); @@ -74,9 +74,9 @@ namespace openstudio { setEnabled(true); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSCheckBox3::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSCheckBox3::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSCheckBox3::toggled, this, &OSCheckBox3::onToggled); bool checked = (*m_get)(); @@ -122,7 +122,7 @@ namespace openstudio { } } - void OSCheckBox3::onModelObjectRemove(Handle handle) + void OSCheckBox3::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -152,9 +152,9 @@ void OSCheckBox2::bind(model::ModelObject & modelObject, setEnabled(true); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSCheckBox2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSCheckBox2::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSCheckBox2::toggled, this, &OSCheckBox2::onToggled); bool checked = (*m_get)(); @@ -190,7 +190,7 @@ void OSCheckBox2::onModelObjectChange() } } -void OSCheckBox2::onModelObjectRemove(Handle handle) +void OSCheckBox2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -214,9 +214,9 @@ void OSCheckBox::bind(model::ModelObject & modelObject, const char * property) setEnabled(true); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSCheckBox::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSCheckBox::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSCheckBox::toggled, this, &OSCheckBox::onToggled); bool checked = m_modelObject->getImpl()->property(m_property.c_str()).toBool(); @@ -252,7 +252,7 @@ void OSCheckBox::onModelObjectChange() } } -void OSCheckBox::onModelObjectRemove(Handle handle) +void OSCheckBox::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; diff --git a/openstudiocore/src/shared_gui_components/OSCheckBox.hpp b/openstudiocore/src/shared_gui_components/OSCheckBox.hpp index 4b0ee777598..73b30e48e86 100644 --- a/openstudiocore/src/shared_gui_components/OSCheckBox.hpp +++ b/openstudiocore/src/shared_gui_components/OSCheckBox.hpp @@ -58,7 +58,7 @@ namespace openstudio { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; @@ -92,7 +92,7 @@ namespace openstudio { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; @@ -121,7 +121,7 @@ class OSCheckBox : public QPushButton { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: diff --git a/openstudiocore/src/shared_gui_components/OSComboBox.cpp b/openstudiocore/src/shared_gui_components/OSComboBox.cpp index da0315647ce..7c78a8f22bf 100644 --- a/openstudiocore/src/shared_gui_components/OSComboBox.cpp +++ b/openstudiocore/src/shared_gui_components/OSComboBox.cpp @@ -61,19 +61,13 @@ void OSObjectListCBDS::initialize() { m_workspaceObjects << modelObject; - connect(modelObject.getImpl().get(), &model::detail::ModelObject_Impl::onChange, this, &OSObjectListCBDS::onObjectChanged); + modelObject.getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); } } - connect(m_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::addWorkspaceObject), - this, - &OSObjectListCBDS::onObjectAdded); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObject.connect(this); - connect(m_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &OSObjectListCBDS::onObjectWillBeRemoved); + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObject.connect(this); } int OSObjectListCBDS::numberOfItems() @@ -107,13 +101,13 @@ QString OSObjectListCBDS::valueAt(int i) } } -void OSObjectListCBDS::onObjectAdded(const WorkspaceObject & workspaceObject) +void OSObjectListCBDS::onObjectAdded(const WorkspaceObject & workspaceObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { if(std::find(m_types.begin(),m_types.end(),workspaceObject.cast().iddObjectType()) != m_types.end()) { m_workspaceObjects << workspaceObject; - connect(workspaceObject.getImpl().get(), &model::detail::ModelObject_Impl::onChange, this, &OSObjectListCBDS::onObjectChanged); + workspaceObject.getImpl().get()->model::detail::ModelObject_Impl::onChange.connect(this); if( m_allowEmptySelection ) { emit itemAdded(m_workspaceObjects.size()); @@ -125,7 +119,7 @@ void OSObjectListCBDS::onObjectAdded(const WorkspaceObject & workspaceObject) } } -void OSObjectListCBDS::onObjectWillBeRemoved(const WorkspaceObject & workspaceObject) +void OSObjectListCBDS::onObjectWillBeRemoved(const WorkspaceObject & workspaceObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { if(std::find(m_types.begin(),m_types.end(),workspaceObject.cast().iddObjectType()) != m_types.end()) { @@ -258,7 +252,7 @@ void OSComboBox2::onModelObjectChanged() { } } -void OSComboBox2::onModelObjectRemoved(Handle handle) +void OSComboBox2::onModelObjectRemoved(const Handle& handle) { unbind(); } @@ -345,9 +339,9 @@ void OSComboBox2::onDataSourceRemove(int i) void OSComboBox2::completeBind() { if (m_modelObject) { // connections - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSComboBox2::onModelObjectChanged); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSComboBox2::onModelObjectRemoved); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, static_cast(&OSComboBox2::currentIndexChanged), this, &OSComboBox2::onCurrentIndexChanged); @@ -373,7 +367,7 @@ void OSComboBox2::completeBind() { // if this is too burdensome, implement Workspace_Impl onNameChange() signal and uncomment the above two connections. // (IdfObject_Impl already has onNameChange(); Workspace_Impl::onChange() includes object addition and removal.) - connect(m_modelObject->model().getImpl().get(), &openstudio::model::detail::Model_Impl::onChange, this, &OSComboBox2::onChoicesRefreshTrigger); + m_modelObject->model().getImpl().get()->openstudio::model::detail::Model_Impl::onChange.connect(this); // populate choices // ETH@20140228 - With extension of this class to choices of ModelObjects, and beyond, @@ -451,9 +445,9 @@ void OSComboBox::bind(model::ModelObject & modelObject, const char * property) // Connections - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSComboBox::onModelObjectChanged); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSComboBox::onModelObjectRemoved); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, static_cast(&OSComboBox::currentIndexChanged), this, &OSComboBox::onCurrentIndexChanged); @@ -509,7 +503,7 @@ void OSComboBox::onModelObjectChanged() } } -void OSComboBox::onModelObjectRemoved(Handle handle) +void OSComboBox::onModelObjectRemoved(const Handle& handle) { unbind(); } diff --git a/openstudiocore/src/shared_gui_components/OSComboBox.hpp b/openstudiocore/src/shared_gui_components/OSComboBox.hpp index 644c78af382..22985a8d28c 100644 --- a/openstudiocore/src/shared_gui_components/OSComboBox.hpp +++ b/openstudiocore/src/shared_gui_components/OSComboBox.hpp @@ -78,9 +78,9 @@ class OSObjectListCBDS : public OSComboBoxDataSource private slots: - void onObjectAdded(const WorkspaceObject&); + void onObjectAdded(const WorkspaceObject&, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); - void onObjectWillBeRemoved(const WorkspaceObject&); + void onObjectWillBeRemoved(const WorkspaceObject&, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); void onObjectChanged(); @@ -176,7 +176,7 @@ class OSComboBox2 : public QComboBox { void onModelObjectChanged(); - void onModelObjectRemoved(Handle handle); + void onModelObjectRemoved(const Handle& handle); void onCurrentIndexChanged(const QString & text); @@ -235,7 +235,7 @@ class OSComboBox : public QComboBox { void onModelObjectChanged(); - void onModelObjectRemoved(Handle handle); + void onModelObjectRemoved(const Handle& handle); void onCurrentIndexChanged(const QString & text); diff --git a/openstudiocore/src/shared_gui_components/OSDoubleEdit.cpp b/openstudiocore/src/shared_gui_components/OSDoubleEdit.cpp index 82eb54a8709..ff78b4b9fda 100644 --- a/openstudiocore/src/shared_gui_components/OSDoubleEdit.cpp +++ b/openstudiocore/src/shared_gui_components/OSDoubleEdit.cpp @@ -203,9 +203,9 @@ void OSDoubleEdit2::completeBind() { connect(this, &OSDoubleEdit2::editingFinished, this, &OSDoubleEdit2::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSDoubleEdit2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSDoubleEdit2::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -302,7 +302,7 @@ void OSDoubleEdit2::onModelObjectChange() { refreshTextAndLabel(); } -void OSDoubleEdit2::onModelObjectRemove(Handle handle) { +void OSDoubleEdit2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -488,9 +488,9 @@ void OSDoubleEdit::bind(model::ModelObject& modelObject, connect(this, &OSDoubleEdit::editingFinished, this, &OSDoubleEdit::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSDoubleEdit::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSDoubleEdit::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -546,7 +546,7 @@ void OSDoubleEdit::onModelObjectChange() { refreshTextAndLabel(); } -void OSDoubleEdit::onModelObjectRemove(Handle handle) { +void OSDoubleEdit::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; setEnabled(false); diff --git a/openstudiocore/src/shared_gui_components/OSDoubleEdit.hpp b/openstudiocore/src/shared_gui_components/OSDoubleEdit.hpp index e787acc167b..9d77c573874 100644 --- a/openstudiocore/src/shared_gui_components/OSDoubleEdit.hpp +++ b/openstudiocore/src/shared_gui_components/OSDoubleEdit.hpp @@ -129,7 +129,7 @@ class OSDoubleEdit2: public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; // will be set if attached to ModelObject or ModelExtensibleGroup @@ -187,7 +187,7 @@ class OSDoubleEdit: public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; diff --git a/openstudiocore/src/shared_gui_components/OSGridController.cpp b/openstudiocore/src/shared_gui_components/OSGridController.cpp index 0bfe84c09fd..182997b3c71 100644 --- a/openstudiocore/src/shared_gui_components/OSGridController.cpp +++ b/openstudiocore/src/shared_gui_components/OSGridController.cpp @@ -1712,15 +1712,9 @@ namespace openstudio { void OSGridController::connectToModel() { - connect(m_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::addWorkspaceObject), - this, - &OSGridController::onAddWorkspaceObject); - - connect(m_model.getImpl().get(), - static_cast(&model::detail::Model_Impl::removeWorkspaceObject), - this, - &OSGridController::onRemoveWorkspaceObject); + m_model.getImpl().get()->model::detail::Model_Impl::addWorkspaceObject.connect(this); + + m_model.getImpl().get()->model::detail::Model_Impl::removeWorkspaceObject.connect(this); } void OSGridController::disconnectFromModel() diff --git a/openstudiocore/src/shared_gui_components/OSIntegerEdit.cpp b/openstudiocore/src/shared_gui_components/OSIntegerEdit.cpp index 32d9d6da177..b6aac6042f8 100644 --- a/openstudiocore/src/shared_gui_components/OSIntegerEdit.cpp +++ b/openstudiocore/src/shared_gui_components/OSIntegerEdit.cpp @@ -157,9 +157,9 @@ void OSIntegerEdit2::completeBind() { connect(this, &OSIntegerEdit2::editingFinished, this, &OSIntegerEdit2::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSIntegerEdit2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSIntegerEdit2::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -251,7 +251,7 @@ void OSIntegerEdit2::onModelObjectChange() { refreshTextAndLabel(); } -void OSIntegerEdit2::onModelObjectRemove(Handle handle) { +void OSIntegerEdit2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -422,9 +422,9 @@ void OSIntegerEdit::bind(model::ModelObject& modelObject, connect(this, &OSIntegerEdit::editingFinished, this, &OSIntegerEdit::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSIntegerEdit::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSIntegerEdit::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -480,7 +480,7 @@ void OSIntegerEdit::onModelObjectChange() { refreshTextAndLabel(); } -void OSIntegerEdit::onModelObjectRemove(Handle handle) { +void OSIntegerEdit::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; setEnabled(false); diff --git a/openstudiocore/src/shared_gui_components/OSIntegerEdit.hpp b/openstudiocore/src/shared_gui_components/OSIntegerEdit.hpp index 61531c45012..c534e95119f 100644 --- a/openstudiocore/src/shared_gui_components/OSIntegerEdit.hpp +++ b/openstudiocore/src/shared_gui_components/OSIntegerEdit.hpp @@ -109,7 +109,7 @@ class OSIntegerEdit2: public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; // will be set if attached to ModelObject or ModelExtensibleGroup @@ -164,7 +164,7 @@ class OSIntegerEdit: public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; diff --git a/openstudiocore/src/shared_gui_components/OSLineEdit.cpp b/openstudiocore/src/shared_gui_components/OSLineEdit.cpp index 979552eed14..f6cce857af2 100644 --- a/openstudiocore/src/shared_gui_components/OSLineEdit.cpp +++ b/openstudiocore/src/shared_gui_components/OSLineEdit.cpp @@ -125,9 +125,9 @@ void OSLineEdit2::completeBind() { setReadOnly(true); } - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSLineEdit2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSLineEdit2::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSLineEdit2::editingFinished, this, &OSLineEdit2::onEditingFinished); @@ -252,7 +252,7 @@ void OSLineEdit2::emitItemClicked() #endif } -void OSLineEdit2::onModelObjectRemove(Handle handle) +void OSLineEdit2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -333,9 +333,9 @@ void OSLineEdit::bind(model::ModelObject & modelObject, const char * property) setEnabled(true); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSLineEdit::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSLineEdit::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSLineEdit::editingFinished, this, &OSLineEdit::onEditingFinished); @@ -400,7 +400,7 @@ void OSLineEdit::onModelObjectChange() } } -void OSLineEdit::onModelObjectRemove(Handle handle) +void OSLineEdit::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; diff --git a/openstudiocore/src/shared_gui_components/OSLineEdit.hpp b/openstudiocore/src/shared_gui_components/OSLineEdit.hpp index 99969e185a7..46fb73c8fd6 100644 --- a/openstudiocore/src/shared_gui_components/OSLineEdit.hpp +++ b/openstudiocore/src/shared_gui_components/OSLineEdit.hpp @@ -101,7 +101,7 @@ class OSLineEdit2 : public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); void emitItemClicked(); @@ -152,7 +152,7 @@ class OSLineEdit : public QLineEdit void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: diff --git a/openstudiocore/src/shared_gui_components/OSQuantityEdit.cpp b/openstudiocore/src/shared_gui_components/OSQuantityEdit.cpp index 6f0b990b314..3fb1c4d2192 100644 --- a/openstudiocore/src/shared_gui_components/OSQuantityEdit.cpp +++ b/openstudiocore/src/shared_gui_components/OSQuantityEdit.cpp @@ -191,9 +191,9 @@ void OSQuantityEdit2::completeBind(bool isIP, connect(m_lineEdit, &QLineEdit::editingFinished, this, &OSQuantityEdit2::onEditingFinished); // Evan note: would behaviors improve with "textChanged"? - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSQuantityEdit2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSQuantityEdit2::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -300,7 +300,7 @@ void OSQuantityEdit2::onUnitSystemChange(bool isIP) { refreshTextAndLabel(); } -void OSQuantityEdit2::onModelObjectRemove(Handle handle) { +void OSQuantityEdit2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -545,9 +545,9 @@ void OSQuantityEdit::bind(model::ModelObject& modelObject, connect(m_lineEdit, &QLineEdit::editingFinished, this, &OSQuantityEdit::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSQuantityEdit::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSQuantityEdit::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -617,7 +617,7 @@ void OSQuantityEdit::onUnitSystemChange(bool isIP) { refreshTextAndLabel(); } -void OSQuantityEdit::onModelObjectRemove(Handle handle) { +void OSQuantityEdit::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; setEnabled(false); diff --git a/openstudiocore/src/shared_gui_components/OSQuantityEdit.hpp b/openstudiocore/src/shared_gui_components/OSQuantityEdit.hpp index a5887ee83dc..e805a2c9d28 100644 --- a/openstudiocore/src/shared_gui_components/OSQuantityEdit.hpp +++ b/openstudiocore/src/shared_gui_components/OSQuantityEdit.hpp @@ -139,7 +139,7 @@ class OSQuantityEdit2: public QWidget { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); void onInFocus(bool inFocus); @@ -217,7 +217,7 @@ class OSQuantityEdit: public QWidget { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: diff --git a/openstudiocore/src/shared_gui_components/OSSwitch.cpp b/openstudiocore/src/shared_gui_components/OSSwitch.cpp index 09fb5d65951..0f82dd43fba 100644 --- a/openstudiocore/src/shared_gui_components/OSSwitch.cpp +++ b/openstudiocore/src/shared_gui_components/OSSwitch.cpp @@ -66,11 +66,10 @@ void OSSwitch2::bind(model::ModelObject & modelObject, m_reset = reset; m_isDefaulted = isDefaulted; - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSSwitch2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSSwitch2::onModelObjectRemove); - - connect(this, &OSSwitch2::clicked, this, &OSSwitch2::onClicked); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); + onModelObjectChange(); } @@ -107,7 +106,7 @@ void OSSwitch2::onModelObjectChange() } } -void OSSwitch2::onModelObjectRemove(Handle handle) { +void OSSwitch2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -129,9 +128,9 @@ void OSSwitch::bind(model::ModelObject & modelObject, const char * property) m_property = property; - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSSwitch::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSSwitch::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); connect(this, &OSSwitch::clicked, this, &OSSwitch::onClicked); @@ -168,7 +167,7 @@ void OSSwitch::onModelObjectChange() } } -void OSSwitch::onModelObjectRemove(Handle handle) +void OSSwitch::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; diff --git a/openstudiocore/src/shared_gui_components/OSSwitch.hpp b/openstudiocore/src/shared_gui_components/OSSwitch.hpp index 2317815ad76..f23a03c9996 100644 --- a/openstudiocore/src/shared_gui_components/OSSwitch.hpp +++ b/openstudiocore/src/shared_gui_components/OSSwitch.hpp @@ -54,7 +54,7 @@ class OSSwitch2 : public QPushButton { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; @@ -84,7 +84,7 @@ class OSSwitch : public QPushButton void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: diff --git a/openstudiocore/src/shared_gui_components/OSUnsignedEdit.cpp b/openstudiocore/src/shared_gui_components/OSUnsignedEdit.cpp index ada786c5989..762a91891c1 100644 --- a/openstudiocore/src/shared_gui_components/OSUnsignedEdit.cpp +++ b/openstudiocore/src/shared_gui_components/OSUnsignedEdit.cpp @@ -158,9 +158,9 @@ void OSUnsignedEdit2::completeBind() { connect(this, &OSUnsignedEdit2::editingFinished, this, &OSUnsignedEdit2::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSUnsignedEdit2::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSUnsignedEdit2::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -252,7 +252,7 @@ void OSUnsignedEdit2::onModelObjectChange() { refreshTextAndLabel(); } -void OSUnsignedEdit2::onModelObjectRemove(Handle handle) { +void OSUnsignedEdit2::onModelObjectRemove(const Handle& handle) { unbind(); } @@ -423,9 +423,9 @@ void OSUnsignedEdit::bind(model::ModelObject& modelObject, connect(this, &OSUnsignedEdit::editingFinished, this, &OSUnsignedEdit::onEditingFinished); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSUnsignedEdit::onModelObjectChange); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onChange.connect(this); - connect(m_modelObject->getImpl().get(), &openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace, this, &OSUnsignedEdit::onModelObjectRemove); + m_modelObject->getImpl().get()->openstudio::model::detail::ModelObject_Impl::onRemoveFromWorkspace.connect(this); refreshTextAndLabel(); } @@ -481,7 +481,7 @@ void OSUnsignedEdit::onModelObjectChange() { refreshTextAndLabel(); } -void OSUnsignedEdit::onModelObjectRemove(Handle handle) { +void OSUnsignedEdit::onModelObjectRemove(const Handle& handle) { m_modelObject.reset(); m_property = ""; setEnabled(false); diff --git a/openstudiocore/src/shared_gui_components/OSUnsignedEdit.hpp b/openstudiocore/src/shared_gui_components/OSUnsignedEdit.hpp index e35e2ae9431..64a443ebc10 100644 --- a/openstudiocore/src/shared_gui_components/OSUnsignedEdit.hpp +++ b/openstudiocore/src/shared_gui_components/OSUnsignedEdit.hpp @@ -108,7 +108,7 @@ class OSUnsignedEdit2: public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; // will be set if attached to ModelObject or ModelExtensibleGroup @@ -163,7 +163,7 @@ class OSUnsignedEdit: public QLineEdit { void onModelObjectChange(); - void onModelObjectRemove(Handle handle); + void onModelObjectRemove(const Handle& handle); private: boost::optional m_modelObject; diff --git a/openstudiocore/src/utilities/idf/IdfObject.cpp b/openstudiocore/src/utilities/idf/IdfObject.cpp index 39a5f1162c5..0af33e196ef 100644 --- a/openstudiocore/src/utilities/idf/IdfObject.cpp +++ b/openstudiocore/src/utilities/idf/IdfObject.cpp @@ -1392,14 +1392,14 @@ namespace detail { } if (nameChange){ - emit onNameChange(); + this->onNameChange.nano_emit(); } if (dataChange){ - emit onDataChange(); + this->onDataChange.nano_emit(); } - emit onChange(); + this->onChange.nano_emit(); m_diffs.clear(); } diff --git a/openstudiocore/src/utilities/idf/IdfObjectWatcher.cpp b/openstudiocore/src/utilities/idf/IdfObjectWatcher.cpp index 24bb3e778b0..34265218733 100644 --- a/openstudiocore/src/utilities/idf/IdfObjectWatcher.cpp +++ b/openstudiocore/src/utilities/idf/IdfObjectWatcher.cpp @@ -31,9 +31,9 @@ IdfObjectWatcher::IdfObjectWatcher(const IdfObject& idfObject) openstudio::Application::instance().application(false); detail::IdfObject_ImplPtr objectImpl = idfObject.getImpl(); - connect(objectImpl.get(), &detail::IdfObject_Impl::onChange, this, &IdfObjectWatcher::change); - connect(objectImpl.get(), &detail::IdfObject_Impl::onDataChange, this, &IdfObjectWatcher::dataChange); - connect(objectImpl.get(), &detail::IdfObject_Impl::onNameChange, this, &IdfObjectWatcher::nameChange); + objectImpl.get()->detail::IdfObject_Impl::onChange.connect(this); + objectImpl.get()->detail::IdfObject_Impl::onDataChange.connect(this); + objectImpl.get()->detail::IdfObject_Impl::onNameChange.connect(this); } IdfObjectWatcher::~IdfObjectWatcher() diff --git a/openstudiocore/src/utilities/idf/IdfObject_Impl.hpp b/openstudiocore/src/utilities/idf/IdfObject_Impl.hpp index ce55cf61620..c6c52a9c28f 100644 --- a/openstudiocore/src/utilities/idf/IdfObject_Impl.hpp +++ b/openstudiocore/src/utilities/idf/IdfObject_Impl.hpp @@ -27,6 +27,7 @@ #include #include + #include // Signal-Slot replacement #include @@ -368,17 +369,19 @@ namespace detail { //@} - signals: + //@} + /** @name Nano Signals */ + //@{ - /** Emitted on any change--any field, any comment. */ - void onChange(); + // Emitted on any change--any field, any comment. + Nano::Signal onChange; - /** Emitted if name field changed. */ - void onNameChange(); + // Emitted if name field changed. + Nano::Signal onNameChange; - /** Emitted when any dataFields() are changed (WorkspaceObject and higher), or when any field - * data is changed in Idf mode. */ - void onDataChange(); + // Emitted when any dataFields() are changed (WorkspaceObject and higher), or when any field + // data is changed in Idf mode. + Nano::Signal onDataChange; protected: diff --git a/openstudiocore/src/utilities/idf/Workspace.cpp b/openstudiocore/src/utilities/idf/Workspace.cpp index 769340a1c24..a0021b03054 100644 --- a/openstudiocore/src/utilities/idf/Workspace.cpp +++ b/openstudiocore/src/utilities/idf/Workspace.cpp @@ -494,9 +494,9 @@ namespace detail { int i = 0; int N = objectImplPtrs.size(); - emit progressRange(0, 3*N); - emit progressValue(0); - emit progressCaption("Adding Objects"); + this->progressRange.nano_emit(0, 3*N); + this->progressValue.nano_emit(0); + this->progressCaption.nano_emit("Adding Objects"); // step 1: add to maps bool ok = true; @@ -509,14 +509,14 @@ namespace detail { else { LOG(Error,"Tried to add two objects with the same handle: " << ptr->handle()); } - emit progressValue(++i); + this->progressValue.nano_emit(++i); } // step 2: replace string pointers if (ok){ for (WorkspaceObject_ImplPtr& ptr : objectImplPtrs) { ptr->initializeOnAdd(expectToLosePointers); - emit progressValue(++i); + this->progressValue.nano_emit(++i); } } @@ -530,7 +530,7 @@ namespace detail { for (WorkspaceObject_ImplPtr& ptr : objectImplPtrs) { ptr->setInitialized(); newObjects.push_back(WorkspaceObject(ptr)); - emit progressValue(++i); + this->progressValue.nano_emit(++i); } } @@ -585,13 +585,13 @@ namespace detail { int i = 0; int N = objectImplPtrs.size(); if (oldNewHandleMap.empty()) { - emit progressRange(0, 2*N); + this->progressRange.nano_emit(0, 2*N); } else { - emit progressRange(0, 3*N); + this->progressRange.nano_emit(0, 3*N); } - emit progressValue(0); - emit progressCaption("Cloning Objects"); + this->progressValue.nano_emit(0); + this->progressCaption.nano_emit("Cloning Objects"); // step 1: add objects to maps HandleVector newHandles; @@ -600,14 +600,14 @@ namespace detail { m_workspaceObjectMap.insert(WorkspaceObjectMap::value_type(newHandles.back(),ptr)); insertIntoIddObjectTypeMap(ptr); insertIntoIdfReferencesMap(ptr); - emit progressValue(++i); + this->progressValue.nano_emit(++i); } // step 2: apply handle map to pointers if (!oldNewHandleMap.empty()) { for (const WorkspaceObject_ImplPtr& ptr : objectImplPtrs) { ptr->initializeOnClone(oldNewHandleMap); - emit progressValue(++i); + this->progressValue.nano_emit(++i); } } @@ -638,7 +638,7 @@ namespace detail { for (WorkspaceObject_ImplPtr& ptr : objectImplPtrs) { ptr->setInitialized(); newObjects.push_back(WorkspaceObject(ptr)); - emit progressValue(++i); + this->progressValue.nano_emit(++i); } // step 6: check validity @@ -1484,8 +1484,8 @@ namespace detail { return true; } // trivially satisfied - emit removeWorkspaceObject(WorkspaceObject(objectData->objectImplPtr), objectData->objectImplPtr->iddObject().type(), objectData->handle); - emit removeWorkspaceObject(objectData->objectImplPtr, objectData->objectImplPtr->iddObject().type(), objectData->handle); + this->removeWorkspaceObject.nano_emit(WorkspaceObject(objectData->objectImplPtr), objectData->objectImplPtr->iddObject().type(), objectData->handle); + this->removeWorkspaceObjectPtr.nano_emit(objectData->objectImplPtr, objectData->objectImplPtr->iddObject().type(), objectData->handle); // actual work of removing from maps--is always successful WorkspaceObjectVector sources = nominallyRemoveObject(handle); @@ -1495,7 +1495,7 @@ namespace detail { if ((m_strictnessLevel < StrictnessLevel::Final) || isValid()) { std::vector removedHandles(1, handle); registerRemovalOfObject(objectData->objectImplPtr,sources,removedHandles); - emit onChange(); + this->onChange.nano_emit(); return true; } else { @@ -1518,8 +1518,8 @@ namespace detail { } for (SavedWorkspaceObject savedObject : objectData) { - emit removeWorkspaceObject(WorkspaceObject(savedObject.objectImplPtr), savedObject.objectImplPtr->iddObject().type(), savedObject.handle); - emit removeWorkspaceObject(savedObject.objectImplPtr, savedObject.objectImplPtr->iddObject().type(), savedObject.handle); + this->removeWorkspaceObject.nano_emit(WorkspaceObject(savedObject.objectImplPtr), savedObject.objectImplPtr->iddObject().type(), savedObject.handle); + this->removeWorkspaceObjectPtr.nano_emit(savedObject.objectImplPtr, savedObject.objectImplPtr->iddObject().type(), savedObject.handle); } // actual work of removing from maps--is always successful @@ -1527,7 +1527,7 @@ namespace detail { if ((m_strictnessLevel < StrictnessLevel::Final) || isValid()) { registerRemovalOfObjects(objectData,sources,handles); - emit onChange(); + this->onChange.nano_emit(); return true; } else { @@ -1717,9 +1717,9 @@ namespace detail { ValidityReport report(level); int i = 0; - emit progressRange(0, static_cast(numObjects())); - emit progressValue(i); - emit progressCaption("Checking Validity"); + this->progressRange.nano_emit(0, static_cast(numObjects())); + this->progressValue.nano_emit(i); + this->progressCaption.nano_emit("Checking Validity"); // StrictnessLevel::None // DataErrorType::NoIdd @@ -1789,7 +1789,7 @@ namespace detail { } } // StrictnessLevel::Draft - emit progressValue(++i); + this->progressValue.nano_emit(++i); } // StrictnessLevel::Draft @@ -2289,7 +2289,7 @@ namespace detail { } } ptr->disconnect(); - disconnect(ptr.get(), &WorkspaceObject_Impl::onChange, this, &Workspace_Impl::change); + ptr.get()->WorkspaceObject_Impl::onChange.disconnect(this); } void Workspace_Impl::registerRemovalOfObjects(std::vector& savedObjects, @@ -2302,10 +2302,10 @@ namespace detail { } void Workspace_Impl::registerAdditionOfObject(const WorkspaceObject& object) { - connect(object.getImpl().get(), &WorkspaceObject_Impl::onChange, this, &Workspace_Impl::change); - emit addWorkspaceObject(object, object.iddObject().type(), object.handle()); - emit addWorkspaceObject(object.getImpl(), object.iddObject().type(), object.handle()); - emit onChange(); + object.getImpl().get()->WorkspaceObject_Impl::onChange.connect(this); + this->addWorkspaceObject.nano_emit(object, object.iddObject().type(), object.handle()); + this->addWorkspaceObjectPtr.nano_emit(object.getImpl(), object.iddObject().type(), object.handle()); + this->onChange.nano_emit(); } void Workspace_Impl::restoreObject(SavedWorkspaceObject& savedObject) { @@ -2605,7 +2605,7 @@ namespace detail { } void Workspace_Impl::change() { - emit onChange(); + this->onChange.nano_emit(); } void Workspace_Impl::createAndAddClonedObjects( diff --git a/openstudiocore/src/utilities/idf/WorkspaceObject.cpp b/openstudiocore/src/utilities/idf/WorkspaceObject.cpp index 1d3959bcecb..23c6fb90533 100644 --- a/openstudiocore/src/utilities/idf/WorkspaceObject.cpp +++ b/openstudiocore/src/utilities/idf/WorkspaceObject.cpp @@ -935,7 +935,7 @@ namespace detail { oldHandle = workspaceObjectDiff.oldHandle().get(); } - emit onRelationshipChange(*index, newHandle, oldHandle); + this->onRelationshipChange.nano_emit(*index, newHandle, oldHandle); } else if (oIddField && oIddField->isNameField()) { nameChange = true; @@ -946,14 +946,14 @@ namespace detail { } if (nameChange){ - emit onNameChange(); + this->onNameChange.nano_emit(); } if (dataChange){ - emit onDataChange(); - } + this->onDataChange.nano_emit(); + } - emit onChange(); + this->onChange.nano_emit(); m_diffs.clear(); } @@ -965,7 +965,7 @@ namespace detail { } void WorkspaceObject_Impl::disconnect() { - emit onRemoveFromWorkspace(m_handle); + this->onRemoveFromWorkspace.nano_emit(m_handle); m_handle = Handle(); m_workspace = nullptr; } diff --git a/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.cpp b/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.cpp index c3237c71877..50f63b76730 100644 --- a/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.cpp +++ b/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.cpp @@ -30,9 +30,9 @@ WorkspaceObjectWatcher::WorkspaceObjectWatcher(const openstudio::WorkspaceObject { detail::WorkspaceObject_ImplPtr objectImpl = workspaceObject.getImpl(); - connect(objectImpl.get(), &detail::WorkspaceObject_Impl::onRelationshipChange, this, &WorkspaceObjectWatcher::relationshipChange); + objectImpl.get()->detail::WorkspaceObject_Impl::onRelationshipChange.connect(this); - connect(objectImpl.get(), &detail::WorkspaceObject_Impl::onRemoveFromWorkspace, this, static_cast(&WorkspaceObjectWatcher::removedFromWorkspace)); + objectImpl.get()->detail::WorkspaceObject_Impl::onRemoveFromWorkspace.connect(this); } WorkspaceObjectWatcher::~WorkspaceObjectWatcher() {} @@ -73,7 +73,7 @@ void WorkspaceObjectWatcher::relationshipChange(int index,Handle newHandle,Handl } } -void WorkspaceObjectWatcher::removedFromWorkspace(Handle handle) +void WorkspaceObjectWatcher::removedFromWorkspace(const Handle &handle) { m_removedFromWorkspace = true; diff --git a/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.hpp b/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.hpp index 596b5669e05..15fdcb585de 100644 --- a/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.hpp +++ b/openstudiocore/src/utilities/idf/WorkspaceObjectWatcher.hpp @@ -45,7 +45,7 @@ class UTILITIES_API WorkspaceObjectWatcher : public IdfObjectWatcher { virtual void clearState() override; /// called each time a pointer field changes if watcher enabled - virtual void onRelationshipChange(int index,Handle newHandle,Handle oldHandle); + virtual void onRelationshipChange(int index, Handle newHandle, Handle oldHandle); /// called when the object is removed from its workspace if watcher enabled virtual void onRemoveFromWorkspace(Handle handle); @@ -54,7 +54,7 @@ class UTILITIES_API WorkspaceObjectWatcher : public IdfObjectWatcher { void relationshipChange(int index,Handle newHandle,Handle oldHandle); - void removedFromWorkspace(Handle handle); + void removedFromWorkspace(const Handle & handle); protected: bool m_relationshipChanged; diff --git a/openstudiocore/src/utilities/idf/WorkspaceObject_Impl.hpp b/openstudiocore/src/utilities/idf/WorkspaceObject_Impl.hpp index 511f6d36726..ea720a53306 100644 --- a/openstudiocore/src/utilities/idf/WorkspaceObject_Impl.hpp +++ b/openstudiocore/src/utilities/idf/WorkspaceObject_Impl.hpp @@ -21,6 +21,7 @@ #define UTILITIES_IDF_WORKSPACEOBJECT_IMPL_HPP #include +#include // Signal-Slot replacement #include #include @@ -278,14 +279,19 @@ namespace detail { //@} - signals: + //@} + /** @name Nano Signal */ + //@{ /** Emitted when a pointer field is changed. */ - void onRelationshipChange(int index, Handle newHandle, Handle oldHandle) const; + Nano::Signal onRelationshipChange; /** Emitted when this object is disconnected from the workspace. Do not * access any methods of this object as it is invalid. */ - void onRemoveFromWorkspace(Handle handle) const; + Nano::Signal onRemoveFromWorkspace; + // Nano::Signal onRemoveFromWorkspaceRef; + + Nano::Signal workspaceObjectRemovedSignal; protected: diff --git a/openstudiocore/src/utilities/idf/WorkspaceWatcher.cpp b/openstudiocore/src/utilities/idf/WorkspaceWatcher.cpp index 2aa4343780a..2117c0779fe 100644 --- a/openstudiocore/src/utilities/idf/WorkspaceWatcher.cpp +++ b/openstudiocore/src/utilities/idf/WorkspaceWatcher.cpp @@ -34,20 +34,14 @@ WorkspaceWatcher::WorkspaceWatcher(const Workspace& work) openstudio::Application::instance().application(false); detail::Workspace_ImplPtr wsImpl = work.getImpl(); - connect(wsImpl.get(), &detail::Workspace_Impl::onChange, this, &WorkspaceWatcher::change); + wsImpl.get()->detail::Workspace_Impl::onChange.connect(this); // ideally this would be a queued connection so objects can be initialized before signal is processed // However, WorkspaceObject is not a QObject. Instead we use QTimer to give a delay. - connect(wsImpl.get(), - static_cast(&detail::Workspace_Impl::addWorkspaceObject), - this, - &WorkspaceWatcher::objectAdd); + wsImpl.get()->detail::Workspace_Impl::addWorkspaceObject.connect(this); // this signal happens immediately - connect(wsImpl.get(), - static_cast(&detail::Workspace_Impl::removeWorkspaceObject), - this, - &WorkspaceWatcher::objectRemove); + wsImpl.get()->detail::Workspace_Impl::removeWorkspaceObject.connect(this); } WorkspaceWatcher::~WorkspaceWatcher() @@ -137,8 +131,10 @@ void WorkspaceWatcher::change() } } -void WorkspaceWatcher::objectAdd(const WorkspaceObject& addedObject) + +void WorkspaceWatcher::objectAdd(const WorkspaceObject& addedObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { + // Note: Args 2 & 3 are simply to comply with Nano::Signal template parameters // let change() handle m_dirty and onChangeWorkspace(); m_objectAdded = true; @@ -163,8 +159,9 @@ void WorkspaceWatcher::processAddedObjects() } -void WorkspaceWatcher::objectRemove(const WorkspaceObject& removedObject) +void WorkspaceWatcher::objectRemove(const WorkspaceObject& removedObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid) { + // Note: Args 2 & 3 are simply to comply with Nano::Signal template parameters // let change() handle m_dirty and onChangeWorkspace(); m_objectRemoved = true; diff --git a/openstudiocore/src/utilities/idf/WorkspaceWatcher.hpp b/openstudiocore/src/utilities/idf/WorkspaceWatcher.hpp index 55ccb37ebca..e5aa16c4807 100644 --- a/openstudiocore/src/utilities/idf/WorkspaceWatcher.hpp +++ b/openstudiocore/src/utilities/idf/WorkspaceWatcher.hpp @@ -87,11 +87,13 @@ class UTILITIES_API WorkspaceWatcher : public QObject { void change(); - void objectAdd(const WorkspaceObject& addedObject); + // Note: Args 2 & 3 are simply to comply with Nano::Signal template parameters + void objectAdd(const WorkspaceObject& addedObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); void processAddedObjects(); - void objectRemove(const WorkspaceObject& removedObject); + // Note: Args 2 & 3 are simply to comply with Nano::Signal template parameters + void objectRemove(const WorkspaceObject& removedObject, const openstudio::IddObjectType& type, const openstudio::UUID& uuid); private: diff --git a/openstudiocore/src/utilities/idf/Workspace_Impl.hpp b/openstudiocore/src/utilities/idf/Workspace_Impl.hpp index d78744e9236..af3f9e4beb8 100644 --- a/openstudiocore/src/utilities/idf/Workspace_Impl.hpp +++ b/openstudiocore/src/utilities/idf/Workspace_Impl.hpp @@ -28,6 +28,7 @@ #include #include +#include // Signal-Slot replacement #include @@ -432,32 +433,44 @@ namespace detail { //@} - signals: + //@} + /** @name Nano Signals */ + //@{ /// range for progress to take - void progressRange(int min, int max) const; + // void progressRange(int min, int max) const; + mutable Nano::Signal progressRange; /// report on progress when loading workspace, creating objects, etc - void progressValue(int value) const; + // void progressValue(int value) const; + mutable Nano::Signal progressValue; /// report caption describing what we are currently doing - void progressCaption(const QString& caption) const; + // void progressCaption(const QString& caption) const; + mutable Nano::Signal progressCaption; /** Emitted on any change to this Workspace and its contents. */ - void onChange() const; + // void onChange() const; + mutable Nano::Signal onChange; /** Send an object being deleted from the workspace. OS_ASSERT(!object.initialized()) * should pass, as should OS_ASSERT(object.handle().isNull()). */ - void removeWorkspaceObject(const WorkspaceObject& object, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + // void removeWorkspaceObject(const WorkspaceObject& object, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + mutable Nano::Signal removeWorkspaceObject; // DLM: deprecate this version - void removeWorkspaceObject(std::shared_ptr, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + // void removeWorkspaceObjectPtr(std::shared_ptr, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + mutable Nano::Signal, const openstudio::IddObjectType&, const openstudio::UUID&)> removeWorkspaceObjectPtr; /** Sends an object just added to the Workspace. */ - void addWorkspaceObject(const WorkspaceObject& object, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + // void addWorkspaceObject(const WorkspaceObject& object, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + mutable Nano::Signal addWorkspaceObject; // DLM: deprecate this version - void addWorkspaceObject(std::shared_ptr, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + // void addWorkspaceObjectPtr(std::shared_ptr, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle) const; + mutable Nano::Signal, const openstudio::IddObjectType&, const openstudio::UUID&)> addWorkspaceObjectPtr; + //@} + public slots: