本文整理汇总了C++中PVFieldPtr::getFieldName方法的典型用法代码示例。如果您正苦于以下问题:C++ PVFieldPtr::getFieldName方法的具体用法?C++ PVFieldPtr::getFieldName怎么用?C++ PVFieldPtr::getFieldName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVFieldPtr
的用法示例。
在下文中一共展示了PVFieldPtr::getFieldName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRequest
static void testRequest()
{
StringArray nullNames;
FieldConstPtrArray nullFields;
StringArray optionNames(1);
FieldConstPtrArray optionFields(1);
optionNames[0] = "process";
optionFields[0] = fieldCreate->createScalar(pvString);
StringArray recordNames(1);
FieldConstPtrArray recordFields(1);
recordNames[0] = "_options";
recordFields[0] = fieldCreate->createStructure(optionNames,optionFields);
StringArray fieldNames(2);
FieldConstPtrArray fieldFields(2);
fieldNames[0] = "alarm";
fieldFields[0] = fieldCreate->createStructure(nullNames,nullFields);
fieldNames[1] = "timeStamp";
fieldFields[1] = fieldCreate->createStructure(nullNames,nullFields);
StringArray topNames(2);
FieldConstPtrArray topFields(2);
topNames[0] = "record";
topFields[0] = fieldCreate->createStructure(recordNames,recordFields);
topNames[1] = "field";
topFields[1] = fieldCreate->createStructure(fieldNames,fieldFields);
StructureConstPtr topStructure = fieldCreate->createStructure(
topNames,topFields);
cout << *topStructure << endl;
PVStructurePtr pvTop = pvDataCreate->createPVStructure(topStructure);
cout << *pvTop << endl;
cout << *pvTop->getStructure() << endl;
PVStructurePtr xxx = pvTop->getSubField<PVStructure>("record");
cout << *xxx << endl;
xxx = pvTop->getSubField<PVStructure>("field");
cout << *xxx << endl;
PVStringPtr pvString = pvTop->getSubField<PVString>("record._options.process");
pvString->put("true");
cout << *pvTop << endl;
string subName("record._options.process");
PVFieldPtr pvField = pvTop->getSubField<PVString>(subName);
string fieldName = pvField->getFieldName();
string fullName = pvField->getFullName();
cout << "fieldName " << fieldName << " fullName " << fullName << endl;
testOk1(fieldName.compare("process")==0);
testOk1(fullName.compare(subName)==0);
}
示例2: create
ChannelArrayLocalPtr ChannelArrayLocal::create(
ChannelLocalPtr const &channelLocal,
ChannelArrayRequester::shared_pointer const & channelArrayRequester,
PVStructurePtr const & pvRequest,
PVRecordPtr const &pvRecord)
{
PVFieldPtrArray const & pvFields = pvRequest->getPVFields();
if(pvFields.size()!=1) {
Status status(
Status::STATUSTYPE_ERROR,"invalid pvRequest");
ChannelArrayLocalPtr channelArray;
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(status,channelArray,array);
return channelArray;
}
PVFieldPtr pvField = pvFields[0];
string fieldName("");
while(true) {
string name = pvField->getFieldName();
if(fieldName.size()>0) fieldName += '.';
fieldName += name;
PVStructurePtr pvs = static_pointer_cast<PVStructure>(pvField);
PVFieldPtrArray const & pvfs = pvs->getPVFields();
if(pvfs.size()!=1) break;
pvField = pvfs[0];
}
size_t indfield = fieldName.find_first_of("field.");
if(indfield==0) {
fieldName = fieldName.substr(6);
}
pvField = pvRecord->getPVRecordStructure()->getPVStructure()->getSubField(fieldName);
if(!pvField) {
Status status(
Status::STATUSTYPE_ERROR,fieldName +" not found");
ChannelArrayLocalPtr channelArray;
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(
status,channelArray,array);
return channelArray;
}
if(pvField->getField()->getType()!=scalarArray
&& pvField->getField()->getType()!=structureArray
&& pvField->getField()->getType()!=unionArray)
{
Status status(
Status::STATUSTYPE_ERROR,fieldName +" not array");
ChannelArrayLocalPtr channelArray;
ArrayConstPtr array;
channelArrayRequester->channelArrayConnect(
status,channelArray,array);
return channelArray;
}
PVArrayPtr pvArray = static_pointer_cast<PVArray>(pvField);
PVArrayPtr pvCopy;
if(pvField->getField()->getType()==scalarArray) {
PVScalarArrayPtr xxx = static_pointer_cast<PVScalarArray>(pvField);
pvCopy = getPVDataCreate()->createPVScalarArray(
xxx->getScalarArray()->getElementType());
} else if(pvField->getField()->getType()==structureArray) {
PVStructureArrayPtr xxx = static_pointer_cast<PVStructureArray>(pvField);
pvCopy = getPVDataCreate()->createPVStructureArray(
xxx->getStructureArray()->getStructure());
} else {
PVUnionArrayPtr xxx = static_pointer_cast<PVUnionArray>(pvField);
pvCopy = getPVDataCreate()->createPVUnionArray(
xxx->getUnionArray()->getUnion());
}
ChannelArrayLocalPtr array(new ChannelArrayLocal(
channelLocal,
channelArrayRequester,
pvArray,
pvCopy,
pvRecord));
if(pvRecord->getTraceLevel()>0)
{
cout << "ChannelArrayLocal::create";
cout << " recordName " << pvRecord->getRecordName() << endl;
}
channelArrayRequester->channelArrayConnect(
Status::Ok, array, pvCopy->getArray());
return array;
}