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


C++ NodePtr::dynamicProperty方法代码示例

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


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

示例1: nodeDynamicProperties

void TestKernel::nodeDynamicProperties()
{
    GraphDocumentPtr document = GraphDocument::create();
    NodeTypePtr type = document->nodeTypes().first();
    NodePtr node = Node::create(document);

    type->addDynamicProperty("propertyA");
    type->addDynamicProperty("propertyB");
    type->addDynamicProperty("propertyC");

    // test nodes
    Kernel kernel;
    QString script;
    QScriptValue result;

    // property read-access from script
    node->setDynamicProperty("propertyA", "1");
    script = "Document.nodes()[0].propertyA;";
    result = kernel.execute(document, script);
    QCOMPARE(result.toString().toInt(), 1);

    // property local write/read-access in script
    script = "Document.nodes()[0].propertyB = 2; Document.nodes()[0].propertyB";
    kernel.execute(document, script);
    QCOMPARE(node->dynamicProperty("propertyB").toInt(), 2);

    // property write-access from script
    script = "Document.nodes()[0].propertyC = 3";
    kernel.execute(document, script);
    QCOMPARE(node->dynamicProperty("propertyC").toInt(), 3);

    // cleanup
    document->destroy();
}
开发者ID:KDE,项目名称:rocs,代码行数:34,代码来源:test_kernel.cpp

示例2: automaticScriptObjectPropertyGeneration

void TestKernel::automaticScriptObjectPropertyGeneration()
{
    GraphDocumentPtr document = GraphDocument::create();
    NodePtr nodeA = Node::create(document);
    NodePtr nodeB = Node::create(document);
    EdgePtr edge = Edge::create(nodeA, nodeB);

    Kernel kernel;
    QString script;
    QScriptValue result;

    // For edges/nodes we can assign arbitrary dynamic properties during
    // script execution. However, they exist only during execution and are removed
    // at the end of the execution.
    script = "Document.nodes()[0].nonRegProp=1; Document.nodes()[0].nonRegProp;";
    result = kernel.execute(document, script);
    QCOMPARE(result.toString().toInt(), 1);
    QCOMPARE(nodeA->dynamicProperty("nonRegProp").toInt(), 0);

    script = "Document.edges()[0].nonRegProp=1; Document.edges()[0].nonRegProp;";
    result = kernel.execute(document, script);
    QCOMPARE(result.toString().toInt(), 1);
    QCOMPARE(edge->dynamicProperty("nonRegProp").toInt(), 0);

    // cleanup
    document->destroy();
}
开发者ID:KDE,项目名称:rocs,代码行数:27,代码来源:test_kernel.cpp

示例3: foreach

 foreach(const NodePtr &node, nodes) {
     QString name = node->dynamicProperty("name").toString();
     int index = nodeNames.indexOf(name);
     if (index == -1) {
         qCDebug(GRAPHTHEORY_FILEFORMAT) << "Node "<< name << " was created unnecessarily.";
     }
     QVERIFY(index != -1);
     nodeNames.removeAt(index);
 }
开发者ID:KDE,项目名称:rocs,代码行数:9,代码来源:testdotfileformat.cpp


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