|
PVData C++
|
The epics::pvData namespace. See pv/pvData.h header.
#include <pv/pvData.h> #include <pv/createRequest.h>
Define a structure type and create a container with default values.
epics::pvData::StructureConstPtr stype; // aka std::tr1::shared_ptr<const epics::pvData::Structure> stype = epics::pvData::getFieldCreate()->createFieldBuilder() ->add("fld1", epics::pvData::pvInt) ->addNestedStructure("sub") ->add("fld2", epics::pvData::pvString) ->endNested() ->createStructure(); epics::pvData::PVStructuretPtr value; // aka std::tr1::shared_ptr<epics::pvData::PVStructure> value = epics::pvData::getPVDataCreate()->createPVStructure(stype); value->getSubField<epics::pvData::PVInt>("fld1")->put(4); // store integer 4 value->getSubField<epics::pvData::PVScalar>("sub.fld2")->putFrom(4.2); // convert and store string "4.2"
is equivalent to the following pseudo-code.
struct stype { epics::pvData::int32 fld1; struct { std::string fld2; } sub; }; stype value; value.fld1 = 4; value.fld2 = epics::pvData::castUnsafe<std::string>(4.2);
1.7.4