From 84ba44a8e8374e43e8e6bb88ef5bad774688bd31 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 17 Sep 2002 17:54:59 +0000 Subject: [PATCH] only return enum strings if the primitive type is enum --- src/cas/example/simple/exPV.cc | 49 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/cas/example/simple/exPV.cc b/src/cas/example/simple/exPV.cc index f664aa776..944579f25 100644 --- a/src/cas/example/simple/exPV.cc +++ b/src/cas/example/simple/exPV.cc @@ -247,31 +247,36 @@ caStatus exPV::getUnits(gdd &units) // and therefore this isnt appropriate in an // analog context ... // -caStatus exPV::getEnums (gdd &enums) +caStatus exPV::getEnums ( gdd & enumsIn ) { - static const unsigned nStr = 2; - aitFixedString *str; - exFixedStringDestructor *pDes; + if ( this->info.getType () == aitEnumEnum16 ) { + static const unsigned nStr = 2; + aitFixedString *str; + exFixedStringDestructor *pDes; - enums.setDimension(1); - str = new aitFixedString[nStr]; - if (!str) { - return S_casApp_noMemory; + str = new aitFixedString[nStr]; + if (!str) { + return S_casApp_noMemory; + } + + pDes = new exFixedStringDestructor; + if (!pDes) { + delete [] str; + return S_casApp_noMemory; + } + + strncpy (str[0].fixed_string, "off", + sizeof(str[0].fixed_string)); + strncpy (str[1].fixed_string, "on", + sizeof(str[1].fixed_string)); + + enumsIn.setDimension(1); + enumsIn.setBound (0,0,nStr); + enumsIn.putRef (str, pDes); + + return S_cas_success; } - pDes = new exFixedStringDestructor; - if (!pDes) { - delete [] str; - return S_casApp_noMemory; - } - - enums.putRef (str, pDes); - - strncpy (str[0].fixed_string, "off", sizeof(str[0].fixed_string)); - strncpy (str[1].fixed_string, "on", sizeof(str[1].fixed_string)); - - enums.setBound (0,0,nStr); - return S_cas_success; } @@ -286,7 +291,7 @@ caStatus exPV::getValue(gdd &value) gddStatus gdds; gdds = gddApplicationTypeTable:: - app_table.smartCopy (&value, & (*this->pValue) ); + app_table.smartCopy ( &value, & (*this->pValue) ); if (gdds) { status = S_cas_noConvert; }