diego1996 / gamekit

Automatically exported from code.google.com/p/gamekit
0 stars 0 forks source link

Changing gkLogicTree::createNode method as a template will allow create new nodes without changing the core. #40

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It will be nice to define gkLogicTree::createNode as a template method.
This will avoid to update the big switch (in the cpp) every time we create 
a new node.

This is my proposal. Change gkLogicTree::createNode in the header file for 
the following code (and remove cpp implementation):

    template<class T>
    T* createNode()
    {
        T* pNode = new T(this, m_uniqueHandle);

        GK_ASSERT(pNode);

        if(m_object) pNode->attachObject(m_object);

        m_nodes.push_back(pNode);

        m_uniqueHandle ++;

        return pNode;
    }

Original issue reported on code.google.com by silveira.nestor@gmail.com on 16 Feb 2010 at 10:49

GoogleCodeExporter commented 9 years ago
Good Idea, Thanks.

Original comment by snailr...@gmail.com on 16 Feb 2010 at 2:31

GoogleCodeExporter commented 9 years ago
Added and tested, thanks.

Original comment by snailr...@gmail.com on 16 Feb 2010 at 4:16