use new API

make copying explicit and replace some
use of PVValueArray<T>::put and get
This commit is contained in:
Michael Davidsaver
2013-05-08 18:35:51 -04:00
parent e843779555
commit 992ac73068
6 changed files with 21 additions and 32 deletions
+6 -14
View File
@@ -78,9 +78,8 @@ String PVEnumerated::getChoice()
throw std::logic_error(notAttached);
}
int index = pvIndex->get();
StringArrayData data;
pvChoices->get(0,pvChoices->getLength(),data);
return data.data[index];
const PVStringArray::svector& data(pvChoices->viewUnsafe());
return data[index];
}
bool PVEnumerated::choicesMutable()
@@ -91,15 +90,6 @@ bool PVEnumerated::choicesMutable()
return pvChoices->isImmutable();
}
StringArrayPtr const & PVEnumerated:: getChoices()
{
if(pvIndex.get()==NULL ) {
throw std::logic_error(notAttached);
}
StringArrayData data;
return pvChoices->getSharedVector();
}
int32 PVEnumerated::getNumberChoices()
{
if(pvIndex.get()==NULL ) {
@@ -108,13 +98,15 @@ int32 PVEnumerated::getNumberChoices()
return pvChoices->getLength();
}
bool PVEnumerated:: setChoices(StringArray & choices)
bool PVEnumerated:: setChoices(const StringArray & choices)
{
if(pvIndex.get()==NULL ) {
throw std::logic_error(notAttached);
}
if(pvChoices->isImmutable()) return false;
pvChoices->put(0,choices.size(),get(choices),0);
PVStringArray::svector data(choices.size());
std::copy(choices.begin(), choices.end(), data.begin());
pvChoices->swap(data);
return true;
}