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


C++ StructureConstPtr类代码示例

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


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

示例1: isCompatible

bool NTHistogram::isCompatible(StructureConstPtr const &structure)
{
    if(!structure.get()) return false;

    ScalarArrayConstPtr rangesField = structure->getField<ScalarArray>("ranges");
    if(!rangesField.get() || rangesField->getElementType() != pvDouble) return false;

    ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
    if(!valueField.get()) return false;

    ScalarType scalarType = valueField->getElementType();
    if (scalarType != pvShort &&
        scalarType != pvInt &&
        scalarType != pvLong)
        return false;

    FieldConstPtr field = structure->getField("descriptor");
    if(field)
    {
       ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
       if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
           return false;
    }

    field = structure->getField("alarm");
    if (field.get() && !ntField->isAlarm(field))
        return false;

    field = structure->getField("timeStamp");
    if (field.get() && !ntField->isTimeStamp(field))
        return false;

    return true;
}
开发者ID:mdavidsaver,项目名称:normativeTypesCPP,代码行数:34,代码来源:nthistogram.cpp

示例2: test_extra

void test_extra()
{
    testDiag("test_extra");

    NTContinuumBuilderPtr builder = NTContinuum::createBuilder();
    testOk(builder.get() != 0, "Got builder");

    StructureConstPtr structure = builder->
            addTimeStamp()->
            add("function", getFieldCreate()->createScalar(pvString))->
            createStructure();
    testOk1(structure.get() != 0);
    if (!structure)
        return;

    testOk1(NTContinuum::is_a(structure));
    testOk1(structure->getID() == NTContinuum::URI);
    testOk1(structure->getNumberFields() == 5);
    testOk1(structure->getField("base").get() != 0);
    testOk1(structure->getField("value").get() != 0);
    testOk1(structure->getField("units").get() != 0);
    testOk1(structure->getField("timeStamp").get() != 0);
    testOk1(structure->getField("function").get() != 0);

    testOk(dynamic_pointer_cast<const Scalar>(structure->getField("function")).get() != 0 &&
            dynamic_pointer_cast<const Scalar>(structure->getField("function"))->getScalarType() == pvString, "function type");

    std::cout << *structure << std::endl;
}
开发者ID:mdavidsaver,项目名称:normativeTypesCPP,代码行数:29,代码来源:ntcontinuumTest.cpp

示例3: isCompatible

    static bool isCompatible(StructureConstPtr const &structure)
    {
        if(!structure.get()) return false;

        if (structure->getID() != "dimension_t") return false;

        ScalarConstPtr scalarField = structure->getField<Scalar>("size");
        if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
            return false;

        scalarField = structure->getField<Scalar>("offset");
        if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
            return false;

        scalarField = structure->getField<Scalar>("fullSize");
        if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
            return false;

        scalarField = structure->getField<Scalar>("binning");
        if (scalarField.get() == 0 || scalarField->getScalarType() != pvInt)
            return false;

        scalarField = structure->getField<Scalar>("reverse");
        if (scalarField.get() == 0 || scalarField->getScalarType() != pvBoolean)
            return false;

        return true;
    }
开发者ID:mdavidsaver,项目名称:normativeTypesCPP,代码行数:28,代码来源:ntndarray.cpp

示例4: isCompatible

bool NTNameValue::isCompatible(StructureConstPtr const & structure)
{
    if (structure.get() == 0) return false;

    ScalarArrayConstPtr nameField = structure->getField<ScalarArray>("name");
    if (nameField.get() == 0 || nameField->getElementType() != pvString)
        return false;

    ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
    if (valueField.get() == 0)
        return false;

    FieldConstPtr field = structure->getField("descriptor");
    if (field.get())
    {
        ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
        if (!descriptorField || descriptorField->getScalarType() != pvString)
            return false;
    }

    NTFieldPtr ntField = NTField::get();

    field = structure->getField("alarm");
    if (field && !ntField->isAlarm(field))
        return false;

    field = structure->getField("timeStamp");
    if (field && !ntField->isTimeStamp(field))
        return false;

    return true;
}
开发者ID:mdavidsaver,项目名称:normativeTypesCPP,代码行数:32,代码来源:ntnameValue.cpp

示例5: test_builder

void test_builder()
{
    testDiag("test_builder");

    NTEnumBuilderPtr builder = NTEnum::createBuilder();
    testOk(builder.get() != 0, "Got builder");

    StructureConstPtr structure = builder->
            addDescriptor()->
            addAlarm()->
            addTimeStamp()->
            add("valueAlarm",standardField->doubleAlarm()) ->
            add("extra",fieldCreate->createScalarArray(pvString)) ->
            createStructure();
    testOk1(structure.get() != 0);
    if (!structure)
        return;

    testOk1(NTEnum::is_a(structure));
    testOk1(structure->getID() == NTEnum::URI);
    testOk1(structure->getNumberFields() == 6);
    testOk1(structure->getField("value").get() != 0);
    testOk1(structure->getField("descriptor").get() != 0);
    testOk1(structure->getField("alarm").get() != 0);
    testOk1(structure->getField("timeStamp").get() != 0);

    FieldConstPtr valueField = structure->getField("value");
    testOk(valueField.get() != 0 &&
           ntField->isEnumerated(valueField), "value is enum");

    std::cout << *structure << std::endl;

}
开发者ID:epicsdeb,项目名称:epics-nt,代码行数:33,代码来源:ntenumTest.cpp

示例6: test_nestedStructureArray

void test_nestedStructureArray()
{
    testDiag("Test test_nestedStructureArray()");

    FieldCreatePtr fieldCreate = getFieldCreate();
    
    string NESTED_ID = "nestedID";
    StructureConstPtr s = fieldCreate->createFieldBuilder()->
                            add("double", pvDouble)->
                            addNestedStructureArray("nested")->
                                setId(NESTED_ID)->
                                add("short", pvShort)->
                                add("long", pvLong)->
                                endNested()->
                            addArray("intArray", pvInt)->
                            createStructure();
    testOk1(s.get() != 0);
    testOk1(Structure::DEFAULT_ID == s->getID());
    testOk1(3 == s->getFields().size());

    FieldConstPtr f0 = s->getField(0);
    testOk1(scalar == f0->getType());
    testOk1("double" == s->getFieldName(0));
    testOk(pvDouble == static_pointer_cast<const Scalar>(f0)->getScalarType(), "f0 scalar type == double");

    FieldConstPtr f1 = s->getField(1);
    testOk1(structureArray == f1->getType());
    testOk1("nested" == s->getFieldName(1));

    {
        StructureConstPtr s2 = static_pointer_cast<const StructureArray>(f1)->getStructure();
        
        testOk1(s2.get() != 0);
        testOk1(NESTED_ID == s2->getID());
        testOk1(2 == s2->getFields().size());
        
        FieldConstPtr f20 = s2->getField(0);
        testOk1(scalar == f20->getType());
        testOk1("short" == s2->getFieldName(0));
        testOk(pvShort == static_pointer_cast<const Scalar>(f20)->getScalarType(), "f20 scalar type == short");
    
        FieldConstPtr f21 = s2->getField(1);
        testOk1(scalar == f21->getType());
        testOk1("long" == s2->getFieldName(1));
        testOk(pvLong == static_pointer_cast<const Scalar>(f21)->getScalarType(), "f21 element type == long");
        
    }

    FieldConstPtr f2 = s->getField(2);
    testOk1(scalarArray == f2->getType());
    testOk1("intArray" == s->getFieldName(2));
    testOk(pvInt == static_pointer_cast<const ScalarArray>(f2)->getElementType(), "f2 element type == int");

}	
开发者ID:epicsdeb,项目名称:epics-pvd,代码行数:54,代码来源:testFieldBuilder.cpp

示例7: test_arraySizeTypes

void test_arraySizeTypes()
{
    testDiag("Test test_arraySizeTypes()");

    FieldCreatePtr fieldCreate = getFieldCreate();

    StructureConstPtr s = fieldCreate->createFieldBuilder()->
                            addArray("variableArray", pvDouble)->
                            addFixedArray("fixedArray", pvDouble, 10)->
                            addBoundedArray("boundedArray", pvDouble, 1024)->
                            createStructure();
    testOk1(s.get() != 0);
    testOk1(Structure::DEFAULT_ID == s->getID());
    testOk1(3 == s->getFields().size());
}
开发者ID:epicsdeb,项目名称:epics-pvd,代码行数:15,代码来源:testFieldBuilder.cpp

示例8: PVField

PVStructure::PVStructure(StructureConstPtr const & structurePtr,
    PVFieldPtrArray const & pvs
)
: PVField(structurePtr),
  structurePtr(structurePtr),
  extendsStructureName("")
{
    size_t numberFields = structurePtr->getNumberFields();
    StringArray fieldNames = structurePtr->getFieldNames();
    pvFields.reserve(numberFields);
    for(size_t i=0; i<numberFields; i++) {
        pvFields.push_back(pvs[i]);
    }
    for(size_t i=0; i<numberFields; i++) {
        pvFields[i]->setParentAndName(this,fieldNames[i]);
    }
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例9: appendField

StructureConstPtr FieldCreate::appendField(
    StructureConstPtr const & structure,
    string const & fieldName,
    FieldConstPtr const & field) const
{
    StringArray oldNames = structure->getFieldNames();
    FieldConstPtrArray oldFields = structure->getFields();
    size_t oldLen = oldNames.size();
    StringArray newNames(oldLen+1);
    FieldConstPtrArray newFields(oldLen+1);
    for(size_t i = 0; i<oldLen; i++) {
        newNames[i] = oldNames[i];
        newFields[i] = oldFields[i];
    }
    newNames[oldLen] = fieldName;
    newFields[oldLen] = field;
    return createStructure(structure->getID(),newNames,newFields);
}
开发者ID:ncanestrari,项目名称:EPICS-EPICS_V4,代码行数:18,代码来源:FieldCreateFactory.cpp

示例10: THROW_EXCEPTION2

PVStructure::shared_pointer ValueBuilder::buildPVStructure() const
{
    if(parent)
        THROW_EXCEPTION2(std::logic_error, "Only top level structure may be built.  Missing endNested() ?");

    StructureConstPtr type;
    {
        FieldBuilderPtr tbuild(getFieldCreate()->createFieldBuilder());

        child_struct::buildStruct(*this, tbuild);

        type = tbuild->createStructure();
    }

    PVStructure::shared_pointer root(type->build());

    child_struct::storeStruct(*this, root);

    return root;
}
开发者ID:mdavidsaver,项目名称:pvDataCPP,代码行数:20,代码来源:valueBuilder.cpp

示例11: appendFields

StructureConstPtr FieldCreate::appendFields(
    StructureConstPtr const & structure,
    StringArray const & fieldNames,
    FieldConstPtrArray const & fields) const
{
    StringArray oldNames = structure->getFieldNames();
    FieldConstPtrArray oldFields = structure->getFields();
    size_t oldLen = oldNames.size();
    size_t extra = fieldNames.size();
    StringArray newNames(oldLen+extra);
    FieldConstPtrArray newFields(oldLen+extra);
    for(size_t i = 0; i<oldLen; i++) {
        newNames[i] = oldNames[i];
        newFields[i] = oldFields[i];
    }
    for(size_t i = 0; i<extra; i++) {
        newNames[oldLen +i] = fieldNames[i];
        newFields[oldLen +i] = fields[i];
    }
    return createStructure(structure->getID(),newNames,newFields);
}
开发者ID:ncanestrari,项目名称:EPICS-EPICS_V4,代码行数:21,代码来源:FieldCreateFactory.cpp

示例12: initialize

void RecordProcess::initialize()
{
    pvRecord.lock();
    try {
        if(trace) traceMessage(" initialize");
        PVRecordStructure &pvRecordStructure = pvRecord.getPVRecordStructure();
        PVStructure &pvStructure = pvRecordStructure.getPVStructure();
        fieldSupport = const_cast<Support *>(pvRecordStructure.getSupport());
        if(fieldSupport==0) {
            throw std::logic_error(pvRecord.getRecordName() + " has no support");
        }
        PVFieldPtrArray pvFields = pvStructure.getPVFields();
        PVRecordFieldPtrArray pvRecordFields =
            pvRecordStructure.getPVRecordFields();
        StructureConstPtr structure = pvStructure.getStructure();
        int index;
        index = structure->getFieldIndex("timeStamp");
        if(index>=0) {
            pvTimeStamp.attach(pvFields[index]);
        }
        index = structure->getFieldIndex("scan");
        if(index>=0) {
            scanSupport = pvRecordFields[index]->getSupport();
            scanField = ScanField::create(pvRecord);
            if(scanField.get()!=0) {
            	pvSingleProcessRequester = 
                     &scanField->getSingleProcessRequesterPV();
            	pvRecordFieldSingleProcessRequester =
                     &pvRecord.findPVRecordField(*pvSingleProcessRequester);
                pvProcessAfterStart = &scanField->getProcessAfterStartPV();
            }
        }
        fieldSupport->initialize();
        pvRecord.unlock();
    } catch(...) {
        pvRecord.unlock();
        throw;
    }
}
开发者ID:epics-base,项目名称:pvIOCCPP,代码行数:39,代码来源:recordProcess.cpp

示例13: getParent

void PVStructure::fixParentStructure()
{
    PVStructure *parent = getParent();
    if(parent==NULL) return;
    StructureConstPtr parentStructure = parent->structurePtr;
    String fieldName = getFieldName();
    size_t index = parentStructure->getFieldIndex(fieldName);
    StringArray const &fieldNames = parentStructure->getFieldNames();
    size_t num = fieldNames.size();
    FieldConstPtrArray fields(num);
    FieldConstPtrArray const & oldFields = parentStructure->getFields();
    for(size_t i=0; i< num; i++) {
        if(i==index) {
            fields[i] = structurePtr;
        } else {
            fields[i] = oldFields[i];
        }
    }
    FieldConstPtr field = getFieldCreate()->createStructure(
        parentStructure->getID(),fieldNames,fields);
    parent->replaceField(field);
    parent->fixParentStructure();
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例14: testDeserializeStructureAndCreatePVStructure

void testDeserializeStructureAndCreatePVStructure()
{
	buffer->clear();
	registry->reset();
	StructureConstPtr structureIn = getStructure("structure1");
	serialize(structureIn,registry);

	buffer->flip();
	PVStructurePtr pvStructureOut = registry->deserializeStructureAndCreatePVStructure(buffer,control);
	StructureConstPtr structureOut = pvStructureOut->getStructure();
	assert(structureIn->getFieldName() == structureOut->getFieldName());
	assert(structureIn->getType() == structureOut->getType());
	delete pvStructureOut;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例15: testSerializeFull

void testSerializeFull()
{
	buffer->clear();
	ScalarConstPtr scalarIn = getScalar("field1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarIn),buffer,flusher);
	buffer->flip();
        ScalarConstPtr scalarOut = static_pointer_cast<const Scalar>(IntrospectionRegistry::deserializeFull(buffer,control));
	PVField *pvField = pvDataCreate->createPVField(0,scalarOut);
	pvFieldArray.push_back(pvField);
	assert(scalarIn->getFieldName() == scalarOut->getFieldName());
	assert(scalarIn->getType() == scalarOut->getType());

	buffer->clear();
	ScalarArrayConstPtr scalarArrayIn = getScalarArray("fieldArray1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(scalarArrayIn),buffer,flusher);
	buffer->flip();
        ScalarArrayConstPtr scalarArrayOut = static_pointer_cast<const ScalarArray>(IntrospectionRegistry::deserializeFull(buffer,control));
	pvField = pvDataCreate->createPVField(0,scalarArrayOut);
	pvFieldArray.push_back(pvField);
	assert(scalarArrayIn->getFieldName() == scalarArrayOut->getFieldName());
	assert(scalarArrayIn->getType() == scalarArrayOut->getType());

	buffer->clear();
	StructureConstPtr structureIn = getStructure("struct1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureIn),buffer,flusher);
	buffer->flip();
        StructureConstPtr structureOut = static_pointer_cast<const Structure>(IntrospectionRegistry::deserializeFull(buffer,control));
	pvField = pvDataCreate->createPVField(0,structureOut);
	pvFieldArray.push_back(pvField);
	assert(structureIn->getFieldName() == structureOut->getFieldName());
	assert(structureIn->getType() == structureOut->getType());

	buffer->clear();
	StructureArrayConstPtr structureArrayIn = getStructureArray("struct1","structArray1");
        IntrospectionRegistry::serializeFull(static_pointer_cast<const Field>(structureArrayIn),buffer,flusher);
	buffer->flip();
        StructureArrayConstPtr structureArrayOut = static_pointer_cast<const StructureArray>(IntrospectionRegistry::deserializeFull(buffer,control));
	pvField = pvDataCreate->createPVField(0,structureArrayOut);
	pvFieldArray.push_back(pvField);
	assert(structureArrayIn->getFieldName() == structureArrayOut->getFieldName());
	assert(structureArrayIn->getType() == structureArrayOut->getType());
}
开发者ID:,项目名称:,代码行数:42,代码来源:


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