当前位置: 首页>>代码示例>>C++>>正文


C++ NodeRefPtr::GetTail方法代码示例

本文整理汇总了C++中NodeRefPtr::GetTail方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::GetTail方法的具体用法?C++ NodeRefPtr::GetTail怎么用?C++ NodeRefPtr::GetTail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeRefPtr的用法示例。


在下文中一共展示了NodeRefPtr::GetTail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: baseNode

static bool
Test_TfRefPtr()
{
    TestConversions();
    TestNullptrComparisons();
    
    NodeRefPtr chain1 = MakeChain(10);
    NodeRefPtr chain2 = MakeChain(5);

    NodePtr gChain1 = chain1;
    NodePtr gChain2 = chain2;

    TF_AXIOM(chain1->GetLength() == 10);
    TF_AXIOM(chain2->GetLength() == 5);
    TF_AXIOM(gChain1->GetLength() == 10);
    TF_AXIOM(gChain2->GetLength() == 5);

    std::cout
        << "total nodes (should be 15): "
        << Node::GetTotalNodeCount() << std::endl;

    NodeRefPtr start = Node::New();
    start->SetChild(chain1);
    chain1 = TfNullPtr;

    TF_AXIOM(gChain1->GetLength() == 10);
    TF_AXIOM(start->GetLength() == 11);

    std::cout
        << "total nodes (should be one more than previous): "
        << Node::GetTotalNodeCount() << std::endl;

    start->SetChild(gChain2);
    chain2 = TfNullPtr;
    TF_AXIOM(start->GetLength() == 6);
    TF_AXIOM(!gChain1);
    TF_AXIOM(gChain2);

    TF_AXIOM(start->GetLength() == start->GetTail()->GetRevLength());

    std::cout
        << "total nodes (should be 10 less than last): "
        << Node::GetTotalNodeCount() << std::endl;

    start = TfNullPtr;

    TF_AXIOM(!gChain1);
    TF_AXIOM(!gChain2);

    std::cout
        << "total nodes (should be zero): "
        << Node::GetTotalNodeCount() << std::endl;

    TF_AXIOM(Node::GetTotalNodeCount() == 0);

    chain1 = MakeChain(5);
    gChain2 = chain2 = MakeChain(5);
    chain1->GetTail()->SetChild(chain2);

    TF_AXIOM(gChain2->GetRevLength() == 6);
    chain1 = TfNullPtr;
    TF_AXIOM(gChain2->GetRevLength() == 1);
    chain2 = TfNullPtr;
    TF_AXIOM(!gChain2);
    TF_AXIOM(Node::GetTotalNodeCount() == 0);

    SuperNodeRefPtr superPtr = SuperNode::New();
    NodeRefPtr basePtr = superPtr;
    NodePtr baseBackPtr = basePtr;
    
    TF_AXIOM(TfDynamic_cast<SuperNodeRefPtr>(basePtr) == superPtr);
    TF_AXIOM(TfSafeDynamic_cast<SuperNodeRefPtr>(basePtr) == superPtr);

    TF_AXIOM(TfDynamic_cast<SuperNodePtr>(baseBackPtr) == superPtr);
    TF_AXIOM(TfSafeDynamic_cast<SuperNodePtr>(baseBackPtr) == superPtr);

    // Test swap
    {
        const NodeRefPtr n1 = Node::New();
        const NodeRefPtr n2 = Node::New();

        NodeRefPtr a = n1;
        NodeRefPtr b = n2;
        TF_AXIOM(a);
        TF_AXIOM(b);
        TF_AXIOM(a != b);

        TF_AXIOM(a == n1);
        TF_AXIOM(b == n2);
        a.swap(b);
        TF_AXIOM(a == n2);
        TF_AXIOM(b == n1);

        // Test self-swap
        a.swap(a);
        TF_AXIOM(a == n2);
        b.swap(b);
        TF_AXIOM(b == n1);
    }

//.........这里部分代码省略.........
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:101,代码来源:refPtr.cpp


注:本文中的NodeRefPtr::GetTail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。