From 000dde04549ba7d77d6d10ddf27971d969e2472f Mon Sep 17 00:00:00 2001 From: Dave Hickin Date: Thu, 20 Aug 2015 17:23:59 +0100 Subject: [PATCH] Make attach* functions return bool in multi-channel types The attachAlarm and attachTimeStamps() return true if successful, false otherwise in other classes. In NTMultiChannel and NTScalarMultiChannel they returned void. Bring multi-channel behaviour in line. --- src/nt/ntmultiChannel.cpp | 16 ++++++++++------ src/nt/ntmultiChannel.h | 19 +++++++++++-------- src/nt/ntscalarMultiChannel.cpp | 16 ++++++++++------ src/nt/ntscalarMultiChannel.h | 18 ++++++++++-------- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/nt/ntmultiChannel.cpp b/src/nt/ntmultiChannel.cpp index 35dbfd7..0530d34 100644 --- a/src/nt/ntmultiChannel.cpp +++ b/src/nt/ntmultiChannel.cpp @@ -278,16 +278,20 @@ NTMultiChannel::NTMultiChannel(PVStructurePtr const & pvStructure) } -void NTMultiChannel::attachTimeStamp(PVTimeStamp &pv) const +bool NTMultiChannel::attachTimeStamp(PVTimeStamp &pv) const { - if(!pvTimeStamp) return; - pv.attach(pvTimeStamp); + if (pvTimeStamp) + return pv.attach(pvTimeStamp); + else + return false; } -void NTMultiChannel::attachAlarm(PVAlarm &pv) const +bool NTMultiChannel::attachAlarm(PVAlarm &pv) const { - if(!pvAlarm) return; - pv.attach(pvAlarm); + if (pvAlarm) + return pv.attach(pvAlarm); + else + return false; } }} diff --git a/src/nt/ntmultiChannel.h b/src/nt/ntmultiChannel.h index 0c59a57..8243651 100644 --- a/src/nt/ntmultiChannel.h +++ b/src/nt/ntmultiChannel.h @@ -212,18 +212,21 @@ public: * Destructor */ ~NTMultiChannel() {} - /** - * Attach a pvTimeStamp. - * @param pvTimeStamp The pvTimeStamp that will be attached. - * Does nothing if no timeStamp - */ - void attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const; + /** + * Attach a pvTimeStamp. + * @param pvTimeStamp The pvTimeStamp that will be attached. + * Does nothing if no timeStamp. + * @return true if the operation was successfull (i.e. this instance +has a timeStamp field), otherwise false. + */ + bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const; /** * Attach a pvAlarm. * @param pvAlarm The pvAlarm that will be attached. - * Does nothing if no alarm + * Does nothing if no alarm. + * @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false. */ - void attachAlarm(epics::pvData::PVAlarm &pvAlarm) const; + bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const; /** * Get the pvStructure. * @return PVStructurePtr. diff --git a/src/nt/ntscalarMultiChannel.cpp b/src/nt/ntscalarMultiChannel.cpp index 043e712..88af28b 100644 --- a/src/nt/ntscalarMultiChannel.cpp +++ b/src/nt/ntscalarMultiChannel.cpp @@ -275,16 +275,20 @@ NTScalarMultiChannel::NTScalarMultiChannel(PVStructurePtr const & pvStructure) } -void NTScalarMultiChannel::attachTimeStamp(PVTimeStamp &pv) const +bool NTScalarMultiChannel::attachTimeStamp(PVTimeStamp &pv) const { - if(!pvTimeStamp) return; - pv.attach(pvTimeStamp); + if (pvTimeStamp) + return pv.attach(pvTimeStamp); + else + return false; } -void NTScalarMultiChannel::attachAlarm(PVAlarm &pv) const +bool NTScalarMultiChannel::attachAlarm(PVAlarm &pv) const { - if(!pvAlarm) return; - pv.attach(pvAlarm); + if (pvAlarm) + return pv.attach(pvAlarm); + else + return false; } }} diff --git a/src/nt/ntscalarMultiChannel.h b/src/nt/ntscalarMultiChannel.h index 645147f..c202279 100644 --- a/src/nt/ntscalarMultiChannel.h +++ b/src/nt/ntscalarMultiChannel.h @@ -213,18 +213,20 @@ public: * Destructor */ ~NTScalarMultiChannel() {} - /** - * Attach a pvTimeStamp. - * @param pvTimeStamp The pvTimeStamp that will be attached. - * Does nothing if no timeStamp - */ - void attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const; + /** + * Attach a pvTimeStamp. + * @param pvTimeStamp The pvTimeStamp that will be attached. + * Does nothing if no timeStamp. + * @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false. + */ + bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const; /** * Attach a pvAlarm. * @param pvAlarm The pvAlarm that will be attached. - * Does nothing if no alarm + * Does nothing if no alarm. + * @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false. */ - void attachAlarm(epics::pvData::PVAlarm &pvAlarm) const; + bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const; /** * Get the pvStructure. * @return PVStructurePtr.