// ------------------------------------------------------------------------------------------------ void Signal::DisconnectFunc(Function & func) { // Don't attempt to search anything if there's no head if (m_Head == nullptr) { return; } const SQHash hash = Slot{NullObject(), func}.mFuncHash; // Walk down the chain and remove the matching nodes for (Slot * node = m_Head, * next = nullptr; node != nullptr; node = next) { // Grab the next node upfront next = node->mNext; // Is this our node? if (node->mFuncHash == hash) { // Is this the head? if (node == m_Head) { m_Head = next; // Move the head to the next one } // Detach it from the chain node->Detach(); // Delete the node instance delete node; } } }
//------------------------------------------------------------------------------------------------- const Class& UserObject::getClass() const { if (m_class) { return *m_class; } else { CAMP_ERROR(NullObject(m_class)); } }
IShape *IShape::getShape(std::string choice) { if ("Line" == choice) { return new Line(); } else if ("Curve" == choice) { return new Curve(); } else { return NullObject(); } }
//------------------------------------------------------------------------------------------------- void UserObject::set(const Property& property, const Value& value) const { if (m_holder) { // Just forward to the property, no extra processing required property.setValue(*this, value); } else if (m_parent) { // Find the root object const UserObject* root = this; while (root->m_parent->object.m_parent) root = &root->m_parent->object; // Launch the recursive process root->cascadeSet(root->m_parent->object, property, value); } else { // Error, null object CAMP_ERROR(NullObject(m_class)); } }
// ------------------------------------------------------------------------------------------------ Uint32 Signal::CountFunc(Function & func) const { // Don't attempt to count anything if there's no head if (m_Head == nullptr) { return 0; } const SQHash hash = Slot{NullObject(), func}.mFuncHash; // Final count Uint32 count = 0; // Walk down the chain and count the matching nodes for (Slot * node = m_Head; node != nullptr; node = node->mNext) { // Is this our node? if (node->mFuncHash == hash) { ++count; } } // Return the count return count; }