#include "xpathnodetree.h"

XPathNodeTree::XPathNodeTree()
    : XAsset()
    , mAxis(0)
    , mDist(0.0f)
    , mInfo(new XPathNodeTreeInfo())
{
    SetName("Path Nod Treee");
}

XPathNodeTree::~XPathNodeTree()
{
    delete mInfo;
}

void XPathNodeTree::ParseData(XDataStream *aStream) {
    if (GetPtr() == -1) {
        *aStream
            >> mAxis
            >> mDist;

        // Skip reading the union directly from the stream
        // We'll assume we're parsing as children by default
        for (int i = 0; i < 2; ++i) {
            qint32 treePtr;
            *aStream >> treePtr;
        }
    }
}

void XPathNodeTree::Clear()
{
    mAxis = 0;
    mDist = 0.0f;
    mInfo->Clear();
}

int XPathNodeTree::GetAxis() const {
    return mAxis;
}

void XPathNodeTree::SetAxis(int axis) {
    mAxis = axis;
}

float XPathNodeTree::GetDist() const {
    return mDist;
}

void XPathNodeTree::SetDist(float dist) {
    mDist = dist;
}

XPathNodeTreeInfo* XPathNodeTree::GetInfo() const {
    return mInfo;
}

void XPathNodeTree::SetInfo(XPathNodeTreeInfo *info) {
    if (mInfo != nullptr) {
        delete mInfo;
    }
    mInfo = new XPathNodeTreeInfo(*info);
}
