本文整理汇总了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());
}
示例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());
}
}
示例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);
}
示例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();
}