get rid of unnecessary copies for StringArray
This commit is contained in:
@@ -46,11 +46,11 @@
|
||||
</dd>
|
||||
<dt>This version:</dt>
|
||||
<dd><a
|
||||
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121001.html">pvDataCPP_20121001.html</a>
|
||||
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121026html">pvDataCPP_20121026html</a>
|
||||
</dd>
|
||||
<dt>Previous version:</dt>
|
||||
<dd><a
|
||||
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20120927.html">pvDataCPP_20120927.html</a>
|
||||
href="http://epics-pvdata.hg.sourceforge.net/hgweb/epics-pvdata/pvDataCPP/raw-file/tip/documentation/pvDataCPP_20121001.html">pvDataCPP_20121001.html</a>
|
||||
</dd>
|
||||
<dt>Editors:</dt>
|
||||
<dd>Marty Kraimer, BNL</dd>
|
||||
@@ -2257,13 +2257,13 @@ enum AlarmStatus {
|
||||
class AlarmSeverityFunc {
|
||||
public:
|
||||
static AlarmSeverity getSeverity(int value);
|
||||
static StringArray getSeverityNames();
|
||||
static StringArrayPtr getSeverityNames();
|
||||
};
|
||||
|
||||
class AlarmStatusFunc {
|
||||
public:
|
||||
static AlarmStatus getStatus(int value);
|
||||
static StringArray getStatusNames();
|
||||
static StringArrayPtr getStatusNames();
|
||||
};
|
||||
|
||||
class Alarm {
|
||||
@@ -2565,7 +2565,7 @@ public:
|
||||
int32 getIndex();
|
||||
String getChoice();
|
||||
bool choicesMutable();
|
||||
StringArray getChoices();
|
||||
StringArrayPtr const & getChoices();
|
||||
int32 getNumberChoices();
|
||||
bool setChoices(StringArray &choices,int32 numberChoices);
|
||||
};</pre>
|
||||
|
||||
3646
documentation/pvDataCPP_20121026.html
Normal file
3646
documentation/pvDataCPP_20121026.html
Normal file
File diff suppressed because it is too large
Load Diff
@@ -498,7 +498,7 @@ PVFieldPtr PVDataCreate::createPVField(PVFieldPtr const & fieldToClone)
|
||||
{
|
||||
PVStructurePtr pvStructure
|
||||
= static_pointer_cast<PVStructure>(fieldToClone);
|
||||
StringArray fieldNames = pvStructure->getStructure()->getFieldNames();
|
||||
StringArray const & fieldNames = pvStructure->getStructure()->getFieldNames();
|
||||
PVFieldPtrArray pvFieldPtrArray = pvStructure->getPVFields();
|
||||
return createPVStructure(fieldNames,pvFieldPtrArray);
|
||||
}
|
||||
|
||||
@@ -32,19 +32,20 @@ AlarmSeverity AlarmSeverityFunc::getSeverity(int value)
|
||||
throw std::logic_error(String("should never get here"));
|
||||
}
|
||||
|
||||
StringArray AlarmSeverityFunc::getSeverityNames()
|
||||
StringArrayPtr AlarmSeverityFunc::getSeverityNames()
|
||||
{
|
||||
static size_t severityCount = 5;
|
||||
static StringArray severityNames;
|
||||
static StringArrayPtr severityNames;
|
||||
static Mutex mutex;
|
||||
Lock xx(mutex);
|
||||
if(severityNames.size()==0) {
|
||||
severityNames.reserve(severityCount);
|
||||
severityNames.push_back("NONE");
|
||||
severityNames.push_back("MINOR");
|
||||
severityNames.push_back("MAJOR");
|
||||
severityNames.push_back("INVALID");
|
||||
severityNames.push_back("UNDEFINED");
|
||||
if(severityNames.get()==NULL) {
|
||||
severityNames = StringArrayPtr(new StringArray());
|
||||
severityNames->reserve(severityCount);
|
||||
severityNames->push_back("NONE");
|
||||
severityNames->push_back("MINOR");
|
||||
severityNames->push_back("MAJOR");
|
||||
severityNames->push_back("INVALID");
|
||||
severityNames->push_back("UNDEFINED");
|
||||
}
|
||||
return severityNames;
|
||||
}
|
||||
@@ -79,22 +80,23 @@ AlarmStatus AlarmStatusFunc::getStatus(int value)
|
||||
throw std::logic_error(String("should never get here"));
|
||||
}
|
||||
|
||||
StringArray AlarmStatusFunc::getStatusNames()
|
||||
StringArrayPtr AlarmStatusFunc::getStatusNames()
|
||||
{
|
||||
static size_t statusCount = 8;
|
||||
static StringArray statusNames;
|
||||
static StringArrayPtr statusNames;
|
||||
static Mutex mutex;
|
||||
Lock xx(mutex);
|
||||
if(statusNames.size()==0) {
|
||||
statusNames.reserve(statusCount);
|
||||
statusNames.push_back("NONE");
|
||||
statusNames.push_back("DEVICE");
|
||||
statusNames.push_back("DRIVER");
|
||||
statusNames.push_back("RECORD");
|
||||
statusNames.push_back("DB");
|
||||
statusNames.push_back("CONF");
|
||||
statusNames.push_back("UNDEFINED");
|
||||
statusNames.push_back("CLIENT");
|
||||
if(statusNames.get()==NULL) {
|
||||
statusNames = StringArrayPtr(new StringArray());
|
||||
statusNames->reserve(statusCount);
|
||||
statusNames->push_back("NONE");
|
||||
statusNames->push_back("DEVICE");
|
||||
statusNames->push_back("DRIVER");
|
||||
statusNames->push_back("RECORD");
|
||||
statusNames->push_back("DB");
|
||||
statusNames->push_back("CONF");
|
||||
statusNames->push_back("UNDEFINED");
|
||||
statusNames->push_back("CLIENT");
|
||||
}
|
||||
return statusNames;
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ extern const size_t severityCount;
|
||||
class AlarmSeverityFunc {
|
||||
public:
|
||||
static AlarmSeverity getSeverity(int value);
|
||||
static StringArray getSeverityNames();
|
||||
static StringArrayPtr getSeverityNames();
|
||||
};
|
||||
|
||||
extern const size_t statusCount;
|
||||
class AlarmStatusFunc {
|
||||
public:
|
||||
static AlarmStatus getStatus(int value);
|
||||
static StringArray getStatusNames();
|
||||
static StringArrayPtr getStatusNames();
|
||||
};
|
||||
|
||||
class Alarm {
|
||||
|
||||
@@ -91,14 +91,13 @@ bool PVEnumerated::choicesMutable()
|
||||
return pvChoices->isImmutable();
|
||||
}
|
||||
|
||||
StringArray PVEnumerated:: getChoices()
|
||||
StringArrayPtr const & PVEnumerated:: getChoices()
|
||||
{
|
||||
if(pvIndex.get()==NULL ) {
|
||||
throw std::logic_error(notAttached);
|
||||
}
|
||||
StringArrayData data;
|
||||
pvChoices->get(0,pvChoices->getLength(),data);
|
||||
return data.data;
|
||||
return pvChoices->getSharedVector();
|
||||
}
|
||||
|
||||
int32 PVEnumerated::getNumberChoices()
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
int32 getIndex();
|
||||
String getChoice();
|
||||
bool choicesMutable();
|
||||
StringArray getChoices();
|
||||
StringArrayPtr const & getChoices();
|
||||
int32 getNumberChoices();
|
||||
bool setChoices(StringArray & choices);
|
||||
private:
|
||||
|
||||
@@ -106,8 +106,8 @@ static void testAlarm(FILE * fd,FILE *auxfd)
|
||||
assert(al.getSeverity()==alarm.getSeverity());
|
||||
assert(al.getStatus()==alarm.getStatus());
|
||||
String message = alarm.getMessage();
|
||||
String severity = AlarmSeverityFunc::getSeverityNames()[alarm.getSeverity()];
|
||||
String status = AlarmStatusFunc::getStatusNames()[alarm.getStatus()];
|
||||
String severity = (*AlarmSeverityFunc::getSeverityNames())[alarm.getSeverity()];
|
||||
String status = (*AlarmStatusFunc::getStatusNames())[alarm.getStatus()];
|
||||
if(debug) {
|
||||
fprintf(fd," message %s severity %s status %s\n",
|
||||
message.c_str(),severity.c_str(),status.c_str());
|
||||
@@ -229,11 +229,11 @@ static void testEnumerated(FILE * fd,FILE *auxfd)
|
||||
assert(result);
|
||||
int32 index = pvEnumerated.getIndex();
|
||||
String choice = pvEnumerated.getChoice();
|
||||
StringArray choices = pvEnumerated.getChoices();
|
||||
StringArrayPtr const & choices = pvEnumerated.getChoices();
|
||||
int32 numChoices = pvEnumerated.getNumberChoices();
|
||||
if(debug) {
|
||||
fprintf(fd,"index %d choice %s choices",index,choice.c_str());
|
||||
for(int i=0; i<numChoices; i++ ) fprintf(fd," %s",choices[i].c_str());
|
||||
for(int i=0; i<numChoices; i++ ) fprintf(fd," %s",(*choices)[i].c_str());
|
||||
fprintf(fd,"\n");
|
||||
}
|
||||
pvEnumerated.setIndex(2);
|
||||
|
||||
Reference in New Issue
Block a user