//
// Generated by dtk
// Translation Unit: c_tag.cpp
//

#include "SSystem/SComponent/c_tag.h"
#include "SSystem/SComponent/c_list.h"
#include "SSystem/SComponent/c_tree.h"
#include "dolphin/types.h"

/* 80245410-8024541C       .text cTg_IsUse__FP16create_tag_class */
int cTg_IsUse(create_tag_class* pTag) {
    return pTag->mbIsUse;
}

/* 8024541C-8024545C       .text cTg_SingleCutFromTree__FP16create_tag_class */
int cTg_SingleCutFromTree(create_tag_class* pTag) {
    if (pTag->mbIsUse == true) {
        pTag->mbIsUse = false;
        cTr_SingleCut(&pTag->mpNode);
        return true;
    } else {
        return false;
    }
}

/* 8024545C-802454AC       .text cTg_AdditionToTree__FP21node_lists_tree_classiP16create_tag_class */
int cTg_AdditionToTree(node_lists_tree_class* pTree, int listIdx, create_tag_class* pTag) {
    if (!pTag->mbIsUse) {
        int ret = cTr_Addition(pTree, listIdx, &pTag->mpNode);
        if (ret) {
            pTag->mbIsUse = true;
            return ret;
        }
    }

    return 0;
}

/* 802454AC-802454FC       .text cTg_InsertToTree__FP21node_lists_tree_classiP16create_tag_classi */
int cTg_InsertToTree(node_lists_tree_class* pTree, int listIdx, create_tag_class* pTag, int idx) {
    if (!pTag->mbIsUse) {
        int ret = cTr_Insert(pTree, listIdx, &pTag->mpNode, idx);
        if (ret) {
            pTag->mbIsUse = true;
            return ret;
        }
    }

    return 0;
}

/* 802454FC-80245534       .text cTg_GetFirst__FP15node_list_class */
node_class* cTg_GetFirst(node_list_class* pList) {
    create_tag_class* pTag = (create_tag_class*)cLs_GetFirst(pList);
    if (pTag != NULL) {
        pTag->mbIsUse = false;
    } else {
        pTag = NULL;
    }
    return &pTag->mpNode;
}

/* 80245534-80245574       .text cTg_SingleCut__FP16create_tag_class */
int cTg_SingleCut(create_tag_class* pTag) {
    if (pTag->mbIsUse == 1) {
        pTag->mbIsUse = false;
        cLs_SingleCut(&pTag->mpNode);
        return 1;
    }

    return 0;
}

/* 80245574-802455C4       .text cTg_Addition__FP15node_list_classP16create_tag_class */
int cTg_Addition(node_list_class* pList, create_tag_class* pTag) {
    if (!pTag->mbIsUse) {
        int ret = cLs_Addition(pList, &pTag->mpNode);
        if (ret) {
            pTag->mbIsUse = true;
            return ret;
        }
    }

    return 0;
}

/* 802455C4-8024560C       .text cTg_Create__FP16create_tag_classPv */
void cTg_Create(create_tag_class* pTag, void* pData) {
    cNd_Create(&pTag->mpNode, NULL);
    pTag->mpTagData = pData;
    pTag->mbIsUse = false;
}
