From 1682c991d22759653093a6065da6976665d6f048 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 31 May 2020 12:22:37 -0700 Subject: [PATCH] use dbChannel* in builder --- pdbApp/pdb.cpp | 6 +++--- pdbApp/pdbgroup.cpp | 4 ++-- pdbApp/pdbsingle.cpp | 10 +++++----- pdbApp/pvif.cpp | 37 +++++++++++++++---------------------- pdbApp/pvif.h | 11 +++++------ testApp/testpvif.cpp | 40 ++++++++++++++++++++-------------------- 6 files changed, 50 insertions(+), 58 deletions(-) diff --git a/pdbApp/pdb.cpp b/pdbApp/pdb.cpp index 3d21ae1..0f1f247 100644 --- a/pdbApp/pdb.cpp +++ b/pdbApp/pdb.cpp @@ -450,9 +450,9 @@ PDBProvider::PDBProvider(const epics::pvAccess::Configuration::const_shared_poin std::tr1::shared_ptr pvifbuilder(PVIFBuilder::create(mem.type, chan.chan)); if(!parts.empty()) - builder = pvifbuilder->dtype(builder, parts.back().name, chan); + builder = pvifbuilder->dtype(builder, parts.back().name); else - builder = pvifbuilder->dtype(builder, "", chan); + builder = pvifbuilder->dtype(builder, ""); if(!parts.empty()) { for(size_t j=0; jattach(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 dbChannel *pchan = info.chan2.chan ? info.chan2.chan : info.chan.chan; diff --git a/pdbApp/pdbgroup.cpp b/pdbApp/pdbgroup.cpp index 5f300c1..2e51772 100644 --- a/pdbApp/pdbgroup.cpp +++ b/pdbApp/pdbgroup.cpp @@ -334,7 +334,7 @@ PDBGroupPut::PDBGroupPut(const PDBGroupChannel::shared_pointer& channel, { 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]; 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; diff --git a/pdbApp/pdbsingle.cpp b/pdbApp/pdbsingle.cpp index 9f5d2c6..b04bda8 100644 --- a/pdbApp/pdbsingle.cpp +++ b/pdbApp/pdbsingle.cpp @@ -108,11 +108,11 @@ PDBSinglePV::PDBSinglePV(DBCH& chan, this->chan2.swap(temp); } this->chan.swap(chan); - fielddesc = std::tr1::static_pointer_cast(builder->dtype(this->chan)); + fielddesc = std::tr1::static_pointer_cast(builder->dtype()); complete = pvd::getPVDataCreate()->createPVStructure(fielddesc); FieldName temp; - pvif.reset(builder->attach(this->chan, complete, temp)); + pvif.reset(builder->attach(complete, temp)); epics::atomic::increment(num_instances); } @@ -308,7 +308,7 @@ PDBSinglePut::PDBSinglePut(const PDBSingleChannel::shared_pointer &channel, ,requester(requester) ,changed(new pvd::BitSet(channel->fielddesc->getNumberFields())) ,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) ,doProc(PVIF::ProcPassive) ,doWait(false) @@ -375,7 +375,7 @@ void PDBSinglePut::put(pvd::PVStructure::shared_pointer const & value, // TODO: dbNotify doesn't allow us for force processing // assume value may be a different struct each time - p2p::auto_ptr putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName())); + p2p::auto_ptr putpvif(channel->pv->builder->attach(value, FieldName())); unsigned mask = putpvif->dbe(*changed); if(mask!=DBE_VALUE) { @@ -397,7 +397,7 @@ void PDBSinglePut::put(pvd::PVStructure::shared_pointer const & value, return; // skip notification } else { // assume value may be a different struct each time - p2p::auto_ptr putpvif(channel->pv->builder->attach(channel->pv->chan, value, FieldName())); + p2p::auto_ptr putpvif(channel->pv->builder->attach(value, FieldName())); try{ DBScanLocker L(chan); ret = putpvif->get(*changed, doProc); diff --git a/pdbApp/pvif.cpp b/pdbApp/pvif.cpp index f9ad800..f3187d0 100644 --- a/pdbApp/pvif.cpp +++ b/pdbApp/pvif.cpp @@ -775,7 +775,7 @@ short PVD2DBR(pvd::ScalarType pvt) } epics::pvData::FieldConstPtr -ScalarBuilder::dtype(dbChannel *channel) +ScalarBuilder::dtype() { short dbr = dbChannelFinalFieldType(channel); const long maxelem = dbChannelFinalElements(channel); @@ -830,7 +830,7 @@ ScalarBuilder::dtype(dbChannel *channel) } 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) throw std::runtime_error("+type:\"scalar\" requires +channel:"); @@ -954,7 +954,7 @@ struct PlainBuilder : public PVIFBuilder virtual ~PlainBuilder() {} // 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 long maxelem = dbChannelFinalElements(channel); const pvd::ScalarType pvt = DBR2PVD(dbr); @@ -971,8 +971,7 @@ struct PlainBuilder : public PVIFBuilder // Attach to a structure instance. // must be of the type returned by dtype(). // need not be the root structure - virtual PVIF* attach(dbChannel *channel, - const epics::pvData::PVStructurePtr& root, + virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fldname) OVERRIDE FINAL { if(!channel) @@ -995,7 +994,7 @@ struct AnyScalarBuilder : public PVIFBuilder virtual ~AnyScalarBuilder() {} // fetch the structure description - virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL { + virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL { (void)channel; //ignored return pvd::getFieldCreate()->createVariantUnion(); } @@ -1003,8 +1002,7 @@ struct AnyScalarBuilder : public PVIFBuilder // Attach to a structure instance. // must be of the type returned by dtype(). // need not be the root structure - virtual PVIF* attach(dbChannel *channel, - const epics::pvData::PVStructurePtr& root, + virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fldname) OVERRIDE FINAL { if(!channel) @@ -1094,13 +1092,12 @@ struct MetaBuilder : public PVIFBuilder virtual ~MetaBuilder() {} // 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"); } virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder, - const std::string& fld, - dbChannel *channel) + const std::string& fld) OVERRIDE FINAL { pvd::StandardFieldPtr std(pvd::getStandardField()); if(fld.empty()) { @@ -1117,8 +1114,7 @@ struct MetaBuilder : public PVIFBuilder // Attach to a structure instance. // must be of the type returned by dtype(). // need not be the root structure - virtual PVIF* attach(dbChannel *channel, - const epics::pvData::PVStructurePtr& root, + virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fldname) OVERRIDE FINAL { if(!channel) @@ -1159,19 +1155,17 @@ struct ProcBuilder : public PVIFBuilder virtual ~ProcBuilder() {} // 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"); } virtual epics::pvData::FieldBuilderPtr dtype(epics::pvData::FieldBuilderPtr& builder, - const std::string& fld, - dbChannel *channel) OVERRIDE FINAL + const std::string& fld) OVERRIDE FINAL { // invisible return builder; } - virtual PVIF* attach(dbChannel *channel, - const epics::pvData::PVStructurePtr& root, + virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fldname) OVERRIDE FINAL { if(!channel) @@ -1222,13 +1216,12 @@ pvd::Status PVIF::get(const epics::pvData::BitSet& mask, proc_t proc, bool permi epics::pvData::FieldBuilderPtr PVIFBuilder::dtype(epics::pvData::FieldBuilderPtr& builder, - const std::string &fld, - dbChannel *channel) + const std::string &fld) { if(fld.empty()) - throw std::runtime_error("Can't attach this +type to root"); + throw std::runtime_error(SB()<<"Can't attach +type "<dtype(channel)); + epics::pvData::FieldConstPtr ftype(this->dtype()); if(ftype) builder = builder->add(fld, ftype); diff --git a/pdbApp/pvif.h b/pdbApp/pvif.h index 61e517e..f7f147f 100644 --- a/pdbApp/pvif.h +++ b/pdbApp/pvif.h @@ -397,16 +397,15 @@ struct QSRV_API PVIFBuilder virtual ~PVIFBuilder() {} // 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, - const std::string& fld, - dbChannel *channel); + const std::string& fld); // Attach to a structure instance. // must be of the type returned by dtype(). // 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 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) {} virtual ~ScalarBuilder() {} - virtual epics::pvData::FieldConstPtr dtype(dbChannel *channel) OVERRIDE FINAL; - virtual PVIF* attach(dbChannel *channel, const epics::pvData::PVStructurePtr& root, const FieldName& fld) OVERRIDE FINAL; + virtual epics::pvData::FieldConstPtr dtype() OVERRIDE FINAL; + virtual PVIF* attach(const epics::pvData::PVStructurePtr& root, const FieldName& fld) OVERRIDE FINAL; }; diff --git a/testApp/testpvif.cpp b/testApp/testpvif.cpp index 81bb42d..e6d4ef2 100644 --- a/testApp/testpvif.cpp +++ b/testApp/testpvif.cpp @@ -93,14 +93,14 @@ void testScalar() ScalarBuilder builder_ai_rval(chan_ai_rval); ScalarBuilder builder_mbbi(chan_mbbi); - pvd::FieldConstPtr dtype_li(builder_li.dtype(chan_li)); + pvd::FieldConstPtr dtype_li(builder_li.dtype()); #ifdef USE_INT64 - pvd::FieldConstPtr dtype_i64(builder_i64.dtype(chan_i64)); + pvd::FieldConstPtr dtype_i64(builder_i64.dtype()); #endif - pvd::FieldConstPtr dtype_si(builder_si.dtype(chan_si)); - pvd::FieldConstPtr dtype_ai(builder_ai.dtype(chan_ai)); - pvd::FieldConstPtr dtype_ai_rval(builder_ai_rval.dtype(chan_ai_rval)); - pvd::FieldConstPtr dtype_mbbi(builder_mbbi.dtype(chan_mbbi)); + pvd::FieldConstPtr dtype_si(builder_si.dtype()); + pvd::FieldConstPtr dtype_ai(builder_ai.dtype()); + pvd::FieldConstPtr dtype_ai_rval(builder_ai_rval.dtype()); + pvd::FieldConstPtr dtype_mbbi(builder_mbbi.dtype()); pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder() ->add("li", dtype_li) @@ -115,14 +115,14 @@ void testScalar() 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 - pvif_i64.reset(builder_i64.attach(chan_i64, root, FieldName("i64"))); + pvif_i64.reset(builder_i64.attach(root, FieldName("i64"))); #endif - pvif_si.reset(builder_si.attach(chan_si, root, FieldName("si"))); - pvif_ai.reset(builder_ai.attach(chan_ai, root, FieldName("ai"))); - pvif_ai_rval.reset(builder_ai_rval.attach(chan_ai_rval, root, FieldName("ai_rval"))); - pvif_mbbi.reset(builder_mbbi.attach(chan_mbbi, root, FieldName("mbbi"))); + pvif_si.reset(builder_si.attach(root, FieldName("si"))); + pvif_ai.reset(builder_ai.attach(root, FieldName("ai"))); + pvif_ai_rval.reset(builder_ai_rval.attach(root, FieldName("ai_rval"))); + pvif_mbbi.reset(builder_mbbi.attach(root, FieldName("mbbi"))); } testShow()<<"Entire structure\n"< builder_ai(PVIFBuilder::create("plain", chan_ai)); p2p::auto_ptr builder_mbbi(PVIFBuilder::create("plain", chan_mbbi)); - pvd::FieldConstPtr dtype_li(builder_li->dtype(chan_li)); - pvd::FieldConstPtr dtype_si(builder_si->dtype(chan_si)); - pvd::FieldConstPtr dtype_ai(builder_ai->dtype(chan_ai)); - pvd::FieldConstPtr dtype_mbbi(builder_mbbi->dtype(chan_mbbi)); + pvd::FieldConstPtr dtype_li(builder_li->dtype()); + pvd::FieldConstPtr dtype_si(builder_si->dtype()); + pvd::FieldConstPtr dtype_ai(builder_ai->dtype()); + pvd::FieldConstPtr dtype_mbbi(builder_mbbi->dtype()); pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder() ->add("li", dtype_li) @@ -467,10 +467,10 @@ void testPlain() root = pvd::getPVDataCreate()->createPVStructure(dtype_root); - pvif_li.reset(builder_li->attach(chan_li, root, FieldName("li"))); - pvif_si.reset(builder_si->attach(chan_si, root, FieldName("si"))); - pvif_ai.reset(builder_ai->attach(chan_ai, root, FieldName("ai"))); - pvif_mbbi.reset(builder_mbbi->attach(chan_mbbi, root, FieldName("mbbi"))); + pvif_li.reset(builder_li->attach(root, FieldName("li"))); + pvif_si.reset(builder_si->attach(root, FieldName("si"))); + pvif_ai.reset(builder_ai->attach(root, FieldName("ai"))); + pvif_mbbi.reset(builder_mbbi->attach(root, FieldName("mbbi"))); } pvd::BitSet mask;