From 3d59fef56e34a4ba6d640e16f8a15310e36f62b0 Mon Sep 17 00:00:00 2001 From: Gasper Jansa Date: Sun, 9 Jan 2011 21:44:38 +0100 Subject: [PATCH] some search manager fixes --- pvAccessApp/remote/channelSearchManager.cpp | 3 +- pvAccessApp/remote/channelSearchManager.h | 49 ++++++++++++++++++--- testApp/remote/testChannelSearchManager.cpp | 23 +++++++++- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/pvAccessApp/remote/channelSearchManager.cpp b/pvAccessApp/remote/channelSearchManager.cpp index e879dcc..e1c2358 100644 --- a/pvAccessApp/remote/channelSearchManager.cpp +++ b/pvAccessApp/remote/channelSearchManager.cpp @@ -98,13 +98,14 @@ SearchTimer::SearchTimer(ChannelSearchManager* _chanSearchManager, int32 timerIn _requestPendingChannelsMutex(Mutex()), _mutex(Mutex()) { - + _timerNode = new TimerNode(this); } SearchTimer::~SearchTimer() { if(_requestPendingChannels) delete _requestPendingChannels; if(_responsePendingChannels) delete _responsePendingChannels; + if(_timerNode) delete _timerNode; } void SearchTimer::shutdown() diff --git a/pvAccessApp/remote/channelSearchManager.h b/pvAccessApp/remote/channelSearchManager.h index cb5f3c3..b09571c 100644 --- a/pvAccessApp/remote/channelSearchManager.h +++ b/pvAccessApp/remote/channelSearchManager.h @@ -71,11 +71,13 @@ class ChannelImpl; class ChannelSearchManager; class ClientContextImpl : public ClientContext { +private: + Timer* _timer; public: ClientContextImpl() { - + _timer = new Timer("krneki",lowPriority); } virtual Version* getVersion() { @@ -88,7 +90,7 @@ class ClientContextImpl : public ClientContext Timer* getTimer() { - return NULL; + return _timer; } virtual void initialize() { @@ -128,9 +130,9 @@ class ClientContextImpl : public ClientContext return NULL; } - + ~ClientContextImpl() { delete _timer;}; private: - ~ClientContextImpl() {}; + void loadConfiguration() { @@ -237,16 +239,53 @@ class ClientContextImpl : public ClientContext /** * SearchInstance. */ -//TODO document class SearchInstance { public: + /** + * Destructor + */ virtual ~SearchInstance() {}; + /** + * Return channel ID. + * + * @return channel ID. + */ virtual pvAccessID getChannelID() = 0; + /** + * Return channel name. + * + * @return channel channel name. + */ virtual String getChannelName() = 0; + /** + * Removes the owner of this search instance. + */ virtual void unsetListOwnership() = 0; + /** + * Adds this search instance into the provided list and sets it as the owner of this search instance. + * + * @param newOwner a list to which this search instance is added. + * @param ownerMutex mutex belonging to the newOwner list. The mutex will be locked beofe any modification + * to the list will be done. + * @param index index of the owner (which is search timer index). + * + * @throws BaseException if the ownerMutex is NULL. + */ virtual void addAndSetListOwnership(ArrayFIFO* newOwner, Mutex* ownerMutex, int32 index) = 0; + /** + * Removes this search instance from the owner list and also removes the list as the owner of this + * search instance. + * + * @throws BaseException if the ownerMutex is NULL. + */ virtual void removeAndUnsetListOwnership() = 0; + /** + * Returns the index of the owner. + */ virtual int32 getOwnerIndex() = 0; + /** + * Generates request message. + */ virtual bool generateSearchRequestMessage(ByteBuffer* requestMessage, TransportSendControl* control) = 0; /** diff --git a/testApp/remote/testChannelSearchManager.cpp b/testApp/remote/testChannelSearchManager.cpp index 780cda2..1d07806 100644 --- a/testApp/remote/testChannelSearchManager.cpp +++ b/testApp/remote/testChannelSearchManager.cpp @@ -5,14 +5,35 @@ using namespace epics::pvData; using namespace epics::pvAccess; - +class TestSearcInstance : public BaseSearchInstance +{ +public: + TestSearcInstance(string channelName, pvAccessID channelID): _channelID(channelID), _channelName(channelName) {} + pvAccessID getChannelID() { return _channelID;}; + string getChannelName() {return _channelName;}; + void searchResponse(int8 minorRevision, osiSockAddr* serverAddress) {}; +private: + pvAccessID _channelID; + string _channelName; +}; int main(int argc,char *argv[]) { ClientContextImpl* context = new ClientContextImpl(); ChannelSearchManager* manager = new ChannelSearchManager(context); + TestSearcInstance* chan1 = new TestSearcInstance("chan1", 1); + manager->registerChannel(chan1); + + sleep(3); + + manager->cancel(); + context->destroy(); getShowConstructDestruct()->constuctDestructTotals(stdout); + + //if(chan1) delete chan1; + if(manager) delete manager; + if(context) delete context; return(0); }