channelList using svector

This commit is contained in:
Matej Sekoranja
2014-06-09 22:13:48 +02:00
parent aea156ebbb
commit 4e62a7d4df
7 changed files with 15 additions and 22 deletions

View File

@@ -65,7 +65,7 @@ ChannelFind::shared_pointer CAChannelProvider::channelList(
Status errorStatus(Status::STATUSTYPE_ERROR, "not implemented");
ChannelFind::shared_pointer nullChannelFind;
std::set<epics::pvData::String> none;
PVStringArray::const_svector none;
EXCEPTION_GUARD(channelListRequester->channelListResult(errorStatus, nullChannelFind, none, false));
return nullChannelFind;
}

View File

@@ -8,7 +8,6 @@
#define PVACCESS_H
#include <vector>
#include <set>
#ifdef epicsExportSharedSymbols
# define pvAccessEpicsExportSharedSymbols
@@ -284,7 +283,7 @@ namespace pvAccess {
virtual void channelListResult(
const epics::pvData::Status& status,
ChannelFind::shared_pointer const & channelFind,
std::set<epics::pvData::String> const & channelNames,
epics::pvData::PVStringArray::const_svector const & channelNames,
bool hasDynamic) = 0;
};

View File

@@ -3023,7 +3023,7 @@ namespace epics {
Status errorStatus(Status::STATUSTYPE_ERROR, "not implemented");
ChannelFind::shared_pointer nullChannelFind;
std::set<epics::pvData::String> none;
PVStringArray::const_svector none;
EXCEPTION_GUARD(channelListRequester->channelListResult(errorStatus, nullChannelFind, none, false));
return nullChannelFind;
}

View File

@@ -375,17 +375,18 @@ public:
if (!channelListRequester.get())
throw std::runtime_error("null requester");
std::set<epics::pvData::String> channelNames;
PVStringArray::svector channelNames;
{
Lock guard(m_mutex);
channelNames.reserve(m_services.size());
for (RPCServiceMap::const_iterator iter = m_services.begin();
iter != m_services.end();
iter++)
channelNames.insert(iter->first);
channelNames.push_back(iter->first);
}
ChannelFind::shared_pointer thisPtr(shared_from_this());
channelListRequester->channelListResult(Status::Ok, thisPtr, channelNames, false);
channelListRequester->channelListResult(Status::Ok, thisPtr, freeze(channelNames), false);
return thisPtr;
}

View File

@@ -387,13 +387,13 @@ class ChannelListRequesterImpl :
public:
POINTER_DEFINITIONS(ChannelListRequesterImpl);
std::set<String> channelNames;
PVStringArray::const_svector channelNames;
Status status;
virtual void channelListResult(
const epics::pvData::Status& status,
ChannelFind::shared_pointer const & channelFind,
std::set<epics::pvData::String> const & channelNames,
PVStringArray::const_svector const & channelNames,
bool hasDynamic)
{
epics::pvData::Lock lock(_waitMutex);
@@ -474,18 +474,10 @@ public:
throw RPCRequestException(Status::STATUSTYPE_ERROR, errorMessage);
}
std::set<String>& channelNames = listListener->channelNames;
PVStructure::shared_pointer result =
getPVDataCreate()->createPVStructure(channelListStructure);
PVStringArray::shared_pointer pvArray = result->getSubField<PVStringArray>("value");
PVStringArray::svector newdata(channelNames.size());
size_t i = 0;
for (std::set<String>::const_iterator iter = channelNames.begin();
iter != channelNames.end();
iter++)
newdata[i++] = *iter;
pvArray->replace(freeze(newdata));
pvArray->replace(listListener->channelNames);
return result;
}

View File

@@ -2633,15 +2633,16 @@ public:
throw std::runtime_error("null requester");
// NOTE: this adds only active channels, not all (especially RPC ones)
std::set<epics::pvData::String> channelNames;
PVStringArray::svector channelNames;
{
Lock guard(structureStoreMutex);
channelNames.reserve(structureStore.size());
for (map<String, PVStructure::shared_pointer>::const_iterator iter = structureStore.begin();
iter != structureStore.end();
iter++)
channelNames.insert(iter->first);
channelNames.push_back(iter->first);
}
channelListRequester->channelListResult(Status::Ok, m_mockChannelFind, channelNames, true);
channelListRequester->channelListResult(Status::Ok, m_mockChannelFind, freeze(channelNames), true);
return m_mockChannelFind;
}

View File

@@ -27,7 +27,7 @@ public:
ChannelFind::shared_pointer channelList(ChannelListRequester::shared_pointer const & channelListRequester)
{
ChannelFind::shared_pointer nullCF;
std::set<String> none;
PVStringArray::const_svector none;
channelListRequester->channelListResult(Status::Ok, nullCF, none, false);
return nullCF;
}