use dbChannel* in builder

This commit is contained in:
Michael Davidsaver
2020-05-31 12:22:37 -07:00
parent c68c0038e6
commit 1682c991d2
6 changed files with 50 additions and 58 deletions

View File

@ -450,9 +450,9 @@ PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_poin
std::tr1::shared_ptr<PVIFBuilder> pvifbuilder(PVIFBuilder::create(mem.type, chan.chan)); std::tr1::shared_ptr<PVIFBuilder> pvifbuilder(PVIFBuilder::create(mem.type, chan.chan));
if(!parts.empty()) if(!parts.empty())
builder = pvifbuilder->dtype(builder, parts.back().name, chan); builder = pvifbuilder->dtype(builder, parts.back().name);
else else
builder = pvifbuilder->dtype(builder, "", chan); builder = pvifbuilder->dtype(builder, "");
if(!parts.empty()) { if(!parts.empty()) {
for(size_t j=0; j<parts.size()-1; j++) for(size_t j=0; j<parts.size()-1; j++)
@ -561,7 +561,7 @@ PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_poin
info.evt_VALUE.self = info.evt_PROPERTY.self = pv; info.evt_VALUE.self = info.evt_PROPERTY.self = pv;
assert(info.chan); assert(info.chan);
info.pvif.reset(info.builder->attach(info.chan, pv->complete, info.attachment)); info.pvif.reset(info.builder->attach(pv->complete, info.attachment));
// TODO: don't need evt_PROPERTY for PVIF plain // TODO: don't need evt_PROPERTY for PVIF plain
dbChannel *pchan = info.chan2.chan ? info.chan2.chan : info.chan.chan; dbChannel *pchan = info.chan2.chan ? info.chan2.chan : info.chan.chan;

View File

@ -334,7 +334,7 @@ PDBGroupPut::PDBGroupPut(const PDBGroupChannel::shared_pointer& channel,
{ {
PDBGroupPV::Info& info = channel->pv->members[i]; PDBGroupPV::Info& info = channel->pv->members[i];
pvif[i].reset(info.builder->attach(info.chan, pvf, info.attachment)); pvif[i].reset(info.builder->attach(pvf, info.attachment));
} }
} }
@ -355,7 +355,7 @@ void PDBGroupPut::put(pvd::PVStructure::shared_pointer const & value,
PDBGroupPV::Info& info = channel->pv->members[i]; PDBGroupPV::Info& info = channel->pv->members[i];
if(!info.allowProc) continue; if(!info.allowProc) continue;
putpvif[i].reset(info.builder->attach(info.chan, value, info.attachment)); putpvif[i].reset(info.builder->attach(value, info.attachment));
} }
pvd::Status ret; pvd::Status ret;

View File

@ -108,11 +108,11 @@ PDBSinglePV::PDBSinglePV(DBCH& chan,
this->chan2.swap(temp); this->chan2.swap(temp);
} }
this->chan.swap(chan); this->chan.swap(chan);
fielddesc = std::tr1::static_pointer_cast<const pvd::Structure>(builder->dtype(this->chan)); fielddesc = std::tr1::static_pointer_cast<const pvd::Structure>(builder->dtype());
complete = pvd::getPVDataCreate()->createPVStructure(fielddesc); complete = pvd::getPVDataCreate()->createPVStructure(fielddesc);
FieldName temp; FieldName temp;
pvif.reset(builder->attach(this->chan, complete, temp)); pvif.reset(builder->attach(complete, temp));
epics::atomic::increment(num_instances); epics::atomic::increment(num_instances);
} }
@ -308,7 +308,7 @@ PDBSinglePut::PDBSinglePut(const PDBSingleChannel::shared_pointer &channel,
,requester(requester) ,requester(requester)
,changed(new pvd::BitSet(channel->fielddesc->getNumberFields())) ,changed(new pvd::BitSet(channel->fielddesc->getNumberFields()))
,pvf(pvd::getPVDataCreate()->createPVStructure(channel->fielddesc)) ,pvf(pvd::getPVDataCreate()->createPVStructure(channel->fielddesc))
,pvif(channel->pv->builder->attach(channel->pv->chan, pvf, FieldName())) ,pvif(channel->pv->builder->attach(pvf, FieldName()))
,notifyBusy(0) ,notifyBusy(0)
,doProc(PVIF::ProcPassive) ,doProc(PVIF::ProcPassive)
,doWait(false) ,doWait(false)
@ -375,7 +375,7 @@ void PDBSinglePut::put(pvd::PVStructure::shared_pointer const & value,
// TODO: dbNotify doesn't allow us for force processing // TODO: dbNotify doesn't allow us for force processing
// assume value may be a different struct each time // assume value may be a different struct each time
p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName())); p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(value, FieldName()));
unsigned mask = putpvif->dbe(*changed); unsigned mask = putpvif->dbe(*changed);
if(mask!=DBE_VALUE) { if(mask!=DBE_VALUE) {
@ -397,7 +397,7 @@ void PDBSinglePut::put(pvd::PVStructure::shared_pointer const & value,
return; // skip notification return; // skip notification
} else { } else {
// assume value may be a different struct each time // assume value may be a different struct each time
p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName())); p2p::auto_ptr<PVIF> putpvif(channel->pv->builder->attach(value, FieldName()));
try{ try{
DBScanLocker L(chan); DBScanLocker L(chan);
ret = putpvif->get(*changed, doProc); ret = putpvif->get(*changed, doProc);

View File

@ -775,7 +775,7 @@ short PVD2DBR(pvd::ScalarType pvt)
} }
epics::pvData::FieldConstPtr epics::pvData::FieldConstPtr
ScalarBuilder::dtype(dbChannel *channel) ScalarBuilder::dtype()
{ {
short dbr = dbChannelFinalFieldType(channel); short dbr = dbChannelFinalFieldType(channel);
const long maxelem = dbChannelFinalElements(channel); const long maxelem = dbChannelFinalElements(channel);
@ -830,7 +830,7 @@ ScalarBuilder::dtype(dbChannel *channel)
} }
PVIF* PVIF*
ScalarBuilder::attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fldname) ScalarBuilder::attach(const epics::pvData::PVStructurePtr& root, const FieldName& fldname)
{ {
if(!channel) if(!channel)
throw std::runtime_error("+type:\"scalar\" requires +channel:"); throw std::runtime_error("+type:\"scalar\" requires +channel:");
@ -954,7 +954,7 @@ struct PlainBuilder : public PVIFBuilder
virtual ~PlainBuilder() {} virtual ~PlainBuilder() {}
// fetch the structure description // fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL { virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
const short dbr = dbChannelFinalFieldType(channel); const short dbr = dbChannelFinalFieldType(channel);
const long maxelem = dbChannelFinalElements(channel); const long maxelem = dbChannelFinalElements(channel);
const pvd::ScalarType pvt = DBR2PVD(dbr); const pvd::ScalarType pvt = DBR2PVD(dbr);
@ -971,8 +971,7 @@ struct PlainBuilder : public PVIFBuilder
// Attach to a structure instance. // Attach to a structure instance.
// must be of the type returned by dtype(). // must be of the type returned by dtype().
// need not be the root structure // need not be the root structure
virtual PVIF* attach(dbChannel *channel, virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL const FieldName& fldname) OVERRIDE FINAL
{ {
if(!channel) if(!channel)
@ -995,7 +994,7 @@ struct AnyScalarBuilder : public PVIFBuilder
virtual ~AnyScalarBuilder() {} virtual ~AnyScalarBuilder() {}
// fetch the structure description // fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL { virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
(void)channel; //ignored (void)channel; //ignored
return pvd::getFieldCreate()->createVariantUnion(); return pvd::getFieldCreate()->createVariantUnion();
} }
@ -1003,8 +1002,7 @@ struct AnyScalarBuilder : public PVIFBuilder
// Attach to a structure instance. // Attach to a structure instance.
// must be of the type returned by dtype(). // must be of the type returned by dtype().
// need not be the root structure // need not be the root structure
virtual PVIF* attach(dbChannel *channel, virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL const FieldName& fldname) OVERRIDE FINAL
{ {
if(!channel) if(!channel)
@ -1094,13 +1092,12 @@ struct MetaBuilder : public PVIFBuilder
virtual ~MetaBuilder() {} virtual ~MetaBuilder() {}
// fetch the structure description // fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL { virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
throw std::logic_error("Don't call me"); throw std::logic_error("Don't call me");
} }
virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder, virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string& fld, const std::string& fld) OVERRIDE FINAL
dbChannel *channel)
{ {
pvd::StandardFieldPtr std(pvd::getStandardField()); pvd::StandardFieldPtr std(pvd::getStandardField());
if(fld.empty()) { if(fld.empty()) {
@ -1117,8 +1114,7 @@ struct MetaBuilder : public PVIFBuilder
// Attach to a structure instance. // Attach to a structure instance.
// must be of the type returned by dtype(). // must be of the type returned by dtype().
// need not be the root structure // need not be the root structure
virtual PVIF* attach(dbChannel *channel, virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL const FieldName& fldname) OVERRIDE FINAL
{ {
if(!channel) if(!channel)
@ -1159,19 +1155,17 @@ struct ProcBuilder : public PVIFBuilder
virtual ~ProcBuilder() {} virtual ~ProcBuilder() {}
// fetch the structure description // fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL { virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL {
throw std::logic_error("Don't call me"); throw std::logic_error("Don't call me");
} }
virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder, virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string& fld, const std::string& fld) OVERRIDE FINAL
dbChannel *channel) OVERRIDE FINAL
{ {
// invisible // invisible
return builder; return builder;
} }
virtual PVIF* attach(dbChannel *channel, virtual PVIF* attach(const epics::pvData::PVStructurePtr& root,
const epics::pvData::PVStructurePtr& root,
const FieldName& fldname) OVERRIDE FINAL const FieldName& fldname) OVERRIDE FINAL
{ {
if(!channel) if(!channel)
@ -1222,13 +1216,12 @@ pvd::Status PVIF::get(const epics::pvData::BitSet& mask, proc_t proc, bool permi
epics::pvData::FieldBuilderPtr epics::pvData::FieldBuilderPtr
PVIFBuilder::dtype(epics::pvData::FieldBuilderPtr& builder, PVIFBuilder::dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string &fld, const std::string &fld)
dbChannel *channel)
{ {
if(fld.empty()) if(fld.empty())
throw std::runtime_error("Can't attach this +type to root"); throw std::runtime_error(SB()<<"Can't attach +type "<<typeid(*this).name()<<" to root");
epics::pvData::FieldConstPtr ftype(this->dtype(channel)); epics::pvData::FieldConstPtr ftype(this->dtype());
if(ftype) if(ftype)
builder = builder->add(fld, ftype); builder = builder->add(fld, ftype);

View File

@ -397,16 +397,15 @@ struct QSRV_API PVIFBuilder
virtual ~PVIFBuilder() {} virtual ~PVIFBuilder() {}
// fetch the structure description // fetch the structure description
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) =0; virtual epics::pvData::FieldConstPtr dtype() =0;
virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder, virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder,
const std::string& fld, const std::string& fld);
dbChannel *channel);
// Attach to a structure instance. // Attach to a structure instance.
// must be of the type returned by dtype(). // must be of the type returned by dtype().
// must be the root structure // must be the root structure
virtual PVIF* attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fld) =0; virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fld) =0;
// entry point for Builder // entry point for Builder
static PVIFBuilder* create(const std::string& mapname, dbChannel* chan); static PVIFBuilder* create(const std::string& mapname, dbChannel* chan);
@ -422,8 +421,8 @@ struct QSRV_API ScalarBuilder : public PVIFBuilder
explicit ScalarBuilder(dbChannel* chan) :PVIFBuilder(chan) {} explicit ScalarBuilder(dbChannel* chan) :PVIFBuilder(chan) {}
virtual ~ScalarBuilder() {} virtual ~ScalarBuilder() {}
virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL; virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL;
virtual PVIF* attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fld) OVERRIDE FINAL; virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fld) OVERRIDE FINAL;
}; };

View File

@ -93,14 +93,14 @@ void testScalar()
ScalarBuilder builder_ai_rval(chan_ai_rval); ScalarBuilder builder_ai_rval(chan_ai_rval);
ScalarBuilder builder_mbbi(chan_mbbi); ScalarBuilder builder_mbbi(chan_mbbi);
pvd::FieldConstPtr dtype_li(builder_li.dtype(chan_li)); pvd::FieldConstPtr dtype_li(builder_li.dtype());
#ifdef USE_INT64 #ifdef USE_INT64
pvd::FieldConstPtr dtype_i64(builder_i64.dtype(chan_i64)); pvd::FieldConstPtr dtype_i64(builder_i64.dtype());
#endif #endif
pvd::FieldConstPtr dtype_si(builder_si.dtype(chan_si)); pvd::FieldConstPtr dtype_si(builder_si.dtype());
pvd::FieldConstPtr dtype_ai(builder_ai.dtype(chan_ai)); pvd::FieldConstPtr dtype_ai(builder_ai.dtype());
pvd::FieldConstPtr dtype_ai_rval(builder_ai_rval.dtype(chan_ai_rval)); pvd::FieldConstPtr dtype_ai_rval(builder_ai_rval.dtype());
pvd::FieldConstPtr dtype_mbbi(builder_mbbi.dtype(chan_mbbi)); pvd::FieldConstPtr dtype_mbbi(builder_mbbi.dtype());
pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder() pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("li", dtype_li) ->add("li", dtype_li)
@ -115,14 +115,14 @@ void testScalar()
root = pvd::getPVDataCreate()->createPVStructure(dtype_root); root = pvd::getPVDataCreate()->createPVStructure(dtype_root);
pvif_li.reset(builder_li.attach(chan_li, root, FieldName("li"))); pvif_li.reset(builder_li.attach(root, FieldName("li")));
#ifdef USE_INT64 #ifdef USE_INT64
pvif_i64.reset(builder_i64.attach(chan_i64, root, FieldName("i64"))); pvif_i64.reset(builder_i64.attach(root, FieldName("i64")));
#endif #endif
pvif_si.reset(builder_si.attach(chan_si, root, FieldName("si"))); pvif_si.reset(builder_si.attach(root, FieldName("si")));
pvif_ai.reset(builder_ai.attach(chan_ai, root, FieldName("ai"))); pvif_ai.reset(builder_ai.attach(root, FieldName("ai")));
pvif_ai_rval.reset(builder_ai_rval.attach(chan_ai_rval, root, FieldName("ai_rval"))); pvif_ai_rval.reset(builder_ai_rval.attach(root, FieldName("ai_rval")));
pvif_mbbi.reset(builder_mbbi.attach(chan_mbbi, root, FieldName("mbbi"))); pvif_mbbi.reset(builder_mbbi.attach(root, FieldName("mbbi")));
} }
testShow()<<"Entire structure\n"<<root; testShow()<<"Entire structure\n"<<root;
@ -453,10 +453,10 @@ void testPlain()
p2p::auto_ptr<PVIFBuilder> builder_ai(PVIFBuilder::create("plain", chan_ai)); p2p::auto_ptr<PVIFBuilder> builder_ai(PVIFBuilder::create("plain", chan_ai));
p2p::auto_ptr<PVIFBuilder> builder_mbbi(PVIFBuilder::create("plain", chan_mbbi)); p2p::auto_ptr<PVIFBuilder> builder_mbbi(PVIFBuilder::create("plain", chan_mbbi));
pvd::FieldConstPtr dtype_li(builder_li->dtype(chan_li)); pvd::FieldConstPtr dtype_li(builder_li->dtype());
pvd::FieldConstPtr dtype_si(builder_si->dtype(chan_si)); pvd::FieldConstPtr dtype_si(builder_si->dtype());
pvd::FieldConstPtr dtype_ai(builder_ai->dtype(chan_ai)); pvd::FieldConstPtr dtype_ai(builder_ai->dtype());
pvd::FieldConstPtr dtype_mbbi(builder_mbbi->dtype(chan_mbbi)); pvd::FieldConstPtr dtype_mbbi(builder_mbbi->dtype());
pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder() pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("li", dtype_li) ->add("li", dtype_li)
@ -467,10 +467,10 @@ void testPlain()
root = pvd::getPVDataCreate()->createPVStructure(dtype_root); root = pvd::getPVDataCreate()->createPVStructure(dtype_root);
pvif_li.reset(builder_li->attach(chan_li, root, FieldName("li"))); pvif_li.reset(builder_li->attach(root, FieldName("li")));
pvif_si.reset(builder_si->attach(chan_si, root, FieldName("si"))); pvif_si.reset(builder_si->attach(root, FieldName("si")));
pvif_ai.reset(builder_ai->attach(chan_ai, root, FieldName("ai"))); pvif_ai.reset(builder_ai->attach(root, FieldName("ai")));
pvif_mbbi.reset(builder_mbbi->attach(chan_mbbi, root, FieldName("mbbi"))); pvif_mbbi.reset(builder_mbbi->attach(root, FieldName("mbbi")));
} }
pvd::BitSet mask; pvd::BitSet mask;