some search manager fixes

This commit is contained in:
Gasper Jansa
2011-01-09 21:44:38 +01:00
parent e26e05bfbf
commit 3d59fef56e
3 changed files with 68 additions and 7 deletions

View File

@@ -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()

View File

@@ -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<SearchInstance*>* 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;
/**

View File

@@ -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);
}