Ejemplo n.º 1
0
// ------------------------------------------------------------------------------------------------
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;
        }
    }
}
Ejemplo n.º 2
0
//-------------------------------------------------------------------------------------------------
const Class& UserObject::getClass() const
{
    if (m_class)
    {
        return *m_class;
    }
    else
    {
        CAMP_ERROR(NullObject(m_class));
    }
}
Ejemplo n.º 3
0
IShape *IShape::getShape(std::string choice)
{
    if ("Line" == choice)
    {
        return new Line();
    }
    else if ("Curve" == choice)
    {
        return new Curve();
    }
    else
    {
        return NullObject();
    }
}
Ejemplo n.º 4
0
//-------------------------------------------------------------------------------------------------
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));
    }
}
Ejemplo n.º 5
0
// ------------------------------------------------------------------------------------------------
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;
}