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


C++ TokenPtr::getTokenData方法代码示例

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


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

示例1: paramCb

 void paramCb(const TokenPtr& msg)
 {
     if (std::dynamic_pointer_cast<EndOfSequenceMessage const>(msg->getTokenData())) {
         return;
     }
     params_.push_back(msg->getTokenData());
 }
开发者ID:cogsys-tuebingen,项目名称:csapex_core_plugins,代码行数:7,代码来源:get_best_optimization_result.cpp

示例2: fitnessCb

    void fitnessCb(const TokenPtr& data)
    {
        if (auto val = std::dynamic_pointer_cast<GenericValueMessage<double> const>(data->getTokenData())) {
            //            std::unique_lock<std::mutex> lock(data_available_mutex_);
            fitness_.push_back(val->value);

        } else if (std::dynamic_pointer_cast<EndOfSequenceMessage const>(data->getTokenData())) {
        } else {
            throw std::runtime_error("unkown message recieved: " + data->getTokenData()->typeName());
        }
    }
开发者ID:cogsys-tuebingen,项目名称:csapex_core_plugins,代码行数:11,代码来源:get_best_optimization_result.cpp

示例3: a

TEST_F(AutoGenerateTest, ExplicitTypesAreDetected)
{
    factory.registerNodeType(GenericNodeFactory::createConstructorFromFunction(f1, "f1"));

    UUID node_id = UUIDProvider::makeUUID_without_parent("foobarbaz");
    NodeFacadeImplementationPtr node = factory.makeNode("f1", node_id, uuid_provider);

    ASSERT_TRUE(node != nullptr);
    ASSERT_EQ(node_id, node->getUUID());

    ASSERT_EQ(node->getParameters().size(), 1);

    ASSERT_EQ(node->getInputs().size(), 2 + node->getParameters().size());
    ASSERT_EQ(node->getOutputs().size(), 1 + node->getParameters().size());

    GenericValueMessage<int>::Ptr a(new GenericValueMessage<int>);
    GenericValueMessage<int>::Ptr b(new GenericValueMessage<int>);

    a->value = 23;
    b->value = 42;

    InputPtr i1 = node->getNodeHandle()->getInput(UUIDProvider::makeDerivedUUID_forced(node_id, "in_0"));
    ASSERT_TRUE(i1 != nullptr);

    InputPtr i2 = node->getNodeHandle()->getInput(UUIDProvider::makeDerivedUUID_forced(node_id, "in_1"));
    ASSERT_TRUE(i2 != nullptr);

    TokenPtr ta = std::make_shared<Token>(a);
    TokenPtr tb = std::make_shared<Token>(b);

    param::ParameterPtr p = node->getParameter("param 2");
    ASSERT_TRUE(p != nullptr);

    p->set<int>(1337);

    param::ValueParameter::Ptr vp = std::dynamic_pointer_cast<param::ValueParameter>(p);
    ASSERT_TRUE(vp != nullptr);

    i1->setToken(ta);
    i2->setToken(tb);

    NodePtr n = node->getNode();
    n->process(*node->getNodeHandle(), *n);

    OutputPtr o = node->getNodeHandle()->getOutput(UUIDProvider::makeDerivedUUID_forced(node_id, "out_0"));
    ASSERT_TRUE(o != nullptr);

    o->commitMessages(false);

    TokenPtr to = o->getToken();
    ASSERT_TRUE(to != nullptr);
    ASSERT_TRUE(to->getTokenData() != nullptr);

    GenericValueMessage<int>::ConstPtr result = std::dynamic_pointer_cast<GenericValueMessage<int> const>(to->getTokenData());
    ASSERT_TRUE(result != nullptr);

    ASSERT_EQ((a->value + b->value + vp->as<int>()), result->value);
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:58,代码来源:auto_generate_test.cpp

示例4: addForwardingOutput

UUID SubgraphNode::addForwardingOutput(const UUID& internal_uuid, const TokenDataConstPtr& type, const std::string& label)
{
    graph_->registerUUID(internal_uuid);

    Output* external_output = VariadicOutputs::createVariadicOutput(type, label);

    InputPtr relay = createInternalInput(type, internal_uuid, label, true);

    crossConnectLabelChange(external_output, relay.get());

    std::weak_ptr<Output> external_output_weak = std::dynamic_pointer_cast<Output>(external_output->shared_from_this());
    relay->message_set.connect([this, external_output_weak, relay](Connectable*) {
        if (auto external_output = external_output_weak.lock()) {
            TokenPtr token = relay->getToken();
            if (is_iterating_) {
                connection_types::GenericVectorMessage::Ptr vector;
                if (!external_output->hasMessage()) {
                    vector = connection_types::GenericVectorMessage::make(token->getTokenData());
                } else {
                    auto collected = external_output->getAddedToken()->getTokenData()->cloneAs<TokenData>();
                    vector = std::dynamic_pointer_cast<connection_types::GenericVectorMessage>(collected);
                }
                apex_assert(vector);
                vector->addNestedValue(token->getTokenData());
                msg::publish(external_output.get(), vector);

                external_output->setType(vector);

            } else {
                msg::publish(external_output.get(), token->getTokenData());
            }
        }
    });

    external_to_internal_inputs_[external_output->getUUID()] = relay;

    relay_to_external_output_[internal_uuid] = external_output->getUUID();

    forwarding_connector_added(relay);

    return external_output->getUUID();
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:42,代码来源:subgraph_node.cpp


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