THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/11/2002 at 01:27, xxxxxxxx wrote:
Breakthrough. Here are functions for getting and setting arbitrary value types:
>
\>
\>
\> GeData GvGetPortGeData(GvNode* node, GvPort* port, GvRun* run)
\> > {
\> > if (!node || !port) return GeData();
\>
\>
\>
\>
\> GvDataInfo* info = GvGetWorld()->GetDataTypeInfo(port->GetValueType());
\> > if (!info) return GeData();
\>
\>
\>
\>
\> GvDynamicData data;
\> > GvAllocDynamicData(node, data, info);
\>
\>
\>
\>
\> if (!port->GetData(data.data, data.info->value_handler->value_id, run)) return GeData();
\>
\>
\>
\>
\> CUSTOMDATATYPEPLUGIN* pl =
\> > FindCustomDataTypePlugin(data.info->value_handler->value_id);
\> > if (!pl) return GeData();
\>
\>
\>
\>
\> GeData ge_data;
\> > if (!CallCustomDataType(pl, ConvertGvToGeData)(data.data, 0, ge_data)) return GeData();
\>
\>
\>
\>
\> return ge_data;
\> > }
\>
\>
\>
\>
\> Bool GvSetPortGeData(const GeData& ge_data, GvNode* node, GvPort* port, GvRun* run)
\> > {
\> > if (!node || !port || !run) return FALSE;
\>
\>
\>
\>
\> GvDataInfo* info = GvGetWorld()->GetDataTypeInfo(port->GetValueType());
\> > if (!info) return FALSE;
\>
\>
\>
\>
\> GvDynamicData data;
\> > GvAllocDynamicData(node, data, info);
\>
\>
\>
\>
\> CUSTOMDATATYPEPLUGIN* pl =
\> > FindCustomDataTypePlugin(data.info->value_handler->value_id);
\> > if (!pl) return FALSE;
\>
\>
\>
\>
\> if (!CallCustomDataType(pl, ConvertGeDataToGv)(ge_data, data.data, 0)) return FALSE;
\>
\>
\>
\>
\> if (!port->SetData(data.data, data.info->value_handler->value_id, run)) return FALSE;
\>
\>
\>
\>
\> return TRUE;
\> > }
\>
\>
Usage for the former function:
>
\>
\>
\> GvValue* vlink = NULL;
\> >
\> > vlink = ports.in_values[GVTEST_LINK_INDEX];
\>
\>
\>
\>
\> GvPort* linkport = vlink->GetPort();
\> > GeData linkdata = GvGetPortGeData(bn, linkport, run);
\>
\>
\>
\>
\> BaseLink* test = linkdata.GetBaseLink();
\> > if (test && test->GetLink(bn->GetNodeMaster()->GetDocument()))
\> > GePrint(test->GetLink(bn->GetNodeMaster()->GetDocument())->GetName());
\>
\>
Usage for the latter function:
>
\>
\>
\> BaseDocument* doc = bn->GetNodeMaster()->GetDocument();
\> > if (!doc) return FALSE;
\>
\>
\>
\>
\> BaseObject* obj = doc->GetFirstObject();
\> > if (!obj) return FALSE;
\>
\>
\>
\>
\> AutoAlloc<BaseLink> bl;
\> > bl->SetLink(obj);
\>
\>
\>
\>
\> return GvSetPortGeData(GeData(bl), bn, port, run);
\>
\>