replace destroy by RAII; many implementation changes

This commit is contained in:
mrkraimer
2016-05-13 12:50:47 -04:00
parent 9f8073aaa2
commit 3cc13e2c5a
18 changed files with 531 additions and 445 deletions

View File

@@ -125,18 +125,27 @@ public:
void message(
std::string const & message,
epics::pvData::MessageType messageType);
/** Destroy all the channels and multiChannels.
*/
void destroy();
/** Get a cached channel or create and connect to a new channel.
*
* The provider is pva. The timeout is 0 seconds.
* The provider is pva. The timeout is 5 seconds.
* @param channelName The channelName.
* @return The interface.
* @throw runtime_error if connection fails.
*/
PvaClientChannelPtr channel(std::string const & channelName)
{ return channel(channelName,"pva", 5.0); }
/** Get a cached channel or create and connect to a new channel.
*
* The timeout is 5 seconds.
* @param channelName The channelName.
* @param providerName The providerName.
* @return The interface.
* @throw runtime_error if connection fails.
*/
PvaClientChannelPtr channel(
std::string const & channelName,
std::string const &providerName)
{ return channel(channelName,providerName, 5.0); }
/** Get a cached channel or create and connect to a new channel.
* @param channelName The channelName.
* @param providerName The providerName.
@@ -179,16 +188,29 @@ public:
/** Get the number of cached channels.
*/
size_t cacheSize();
/** Should debug info be shown?
* @param value true or false
*/
static void setDebug(bool value) {debug = value;}
/** Is debug set?
* @return true or false
*/
static bool getDebug() {return debug;}
/** Get shared pointer to this
*/
PvaClientPtr getPtrSelf()
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
static bool debug;
PvaClient(std::string const & providerNames);
PvaClientChannelCachePtr pvaClientChannelCache;
epics::pvData::Requester::weak_pointer requester;
bool isDestroyed;
bool pvaStarted;
@@ -209,23 +231,37 @@ class ChannelRequesterImpl;
* @author mrk
*/
class epicsShareClass PvaClientChannel :
public epics::pvAccess::ChannelRequester,
public std::tr1::enable_shared_from_this<PvaClientChannel>
{
public:
POINTER_DEFINITIONS(PvaClientChannel);
/** Create a PvaClientChannel.
* @param channelName The name of the channel.
* @param providerName The name of the provider.
* @return The interface to the PvaClientChannel.
*/
static PvaClientChannelPtr create(
PvaClientPtr const &pvaClient,
std::string const & channelName,
std::string const & providerName);
~PvaClientChannel();
/** Destroy the pvAccess connection.
/** ChannelRequester method
* @param status The status
* @param channel The channel
*/
void destroy();
void channelCreated(
const epics::pvData::Status& status,
epics::pvAccess::Channel::shared_pointer const & channel);
/** ChannelRequester method
* @param channel The channel
* @param connectionState The connection state.
*/
void channelStateChange(
epics::pvAccess::Channel::shared_pointer const & channel,
epics::pvAccess::Channel::ConnectionState connectionState);
/** ChannelRequester method
* @return The name
*/
std::string getRequesterName();
/** ChannelRequester method
* @param message The message.
* @param messageType The message type.
*/
void message(
std::string const & message,
epics::pvData::MessageType messageType);
/** Get the name of the channel to which PvaClientChannel is connected.
* @return The channel name.
*/
@@ -368,7 +404,7 @@ public:
* @throw runtime_error if failure.
*/
PvaClientMonitorPtr monitor();
/** Get a cached PvaClientMonitor or create and connect to a new PvaClientMonitor.
/** Create and connect to a new PvaClientMonitor.
* Then call it's start method.
* If connection can not be made an exception is thrown.
* @param request The request as described in package org.epics.pvdata.copy
@@ -382,7 +418,7 @@ public:
*/
PvaClientMonitorPtr monitor(PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester);
/** get a cached PvaClientMonitor or create and connect to a new PvaClientMonitor.
/** Create and connect to a new PvaClientMonitor.
* Then call it's start method.
* If connection can not be made an exception is thrown.
* @param request The request as described in package org.epics.pvdata.copy
@@ -420,21 +456,20 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
static PvaClientChannelPtr create(
PvaClientPtr const &pvaClient,
std::string const & channelName,
std::string const & providerName);
PvaClientChannel(
PvaClientPtr const &pvaClient,
std::string const & channelName,
std::string const & providerName);
void channelCreated(
const epics::pvData::Status& status,
epics::pvAccess::Channel::shared_pointer const & channel);
void channelStateChange(
epics::pvAccess::Channel::shared_pointer const & channel,
epics::pvAccess::Channel::ConnectionState connectionState);
std::string getRequesterName();
void message(
std::string const & message,
epics::pvData::MessageType messageType);
enum ConnectState {connectIdle,connectActive,notConnected,connected};
@@ -443,16 +478,15 @@ private:
std::string providerName;
ConnectState connectState;
bool isDestroyed;
epics::pvData::CreateRequest::shared_pointer createRequest;
PvaClientGetCachePtr pvaClientGetCache;
PvaClientPutCachePtr pvaClientPutCache;
epics::pvData::Status channelConnectStatus;
epics::pvData::Mutex mutex;
epics::pvData::Event waitForConnect;
epics::pvAccess::Channel::shared_pointer channel;
epics::pvAccess::ChannelRequester::shared_pointer channelRequester;
friend class ChannelRequesterImpl;
friend class PvaClient;
};
/**
@@ -463,9 +497,6 @@ class epicsShareClass PvaClientGetData
{
public:
POINTER_DEFINITIONS(PvaClientGetData);
/** Factory method for creating an instance of PvaClientGetData.
*/
static PvaClientGetDataPtr create(epics::pvData::StructureConstPtr const & structure);
~PvaClientGetData() {}
/** Set a prefix for throw messages.
* @param value The prefix.
@@ -559,6 +590,11 @@ public:
* @return The timeStamp.
*/
epics::pvData::TimeStamp getTimeStamp();
/** Factory method for creating an instance of PvaClientGetData.
* NOTE: Not normally called by clients
* @param structure Introspection interface
*/
static PvaClientGetDataPtr create(epics::pvData::StructureConstPtr const & structure);
private:
PvaClientGetData(epics::pvData::StructureConstPtr const & structure);
void checkValue();
@@ -570,6 +606,8 @@ private:
epics::pvData::PVFieldPtr pvValue;
epics::pvData::PVAlarm pvAlarm;
epics::pvData::PVTimeStamp pvTimeStamp;
friend class PvaClientGet;
friend class PvaClientPutGet;
};
class PvaClientPostHandlerPvt; // private to PvaClientPutData
@@ -577,13 +615,11 @@ class PvaClientPostHandlerPvt; // private to PvaClientPutData
* @brief A class that holds data given to by PvaClientPut or PvaClientPutGet
*
*/
class epicsShareClass PvaClientPutData
class epicsShareClass PvaClientPutData
{
public:
POINTER_DEFINITIONS(PvaClientPutData);
/** Factory method for creating an instance of PvaClientPutData.
*/
static PvaClientPutDataPtr create(epics::pvData::StructureConstPtr const & structure);
~PvaClientPutData() {}
/** Set a prefix for throw messages.
* @param value The prefix.
@@ -684,6 +720,11 @@ public:
* @throw runtime_error if failure.
*/
void putStringArray(std::vector<std::string> const & value);
/** Factory method for creating an instance of PvaClientGetData.
* NOTE: Not normally called by clients
* @param structure Introspection interface
*/
static PvaClientPutDataPtr create(epics::pvData::StructureConstPtr const & structure);
private:
PvaClientPutData(epics::pvData::StructureConstPtr const &structure);
void checkValue();
@@ -697,6 +738,8 @@ private:
std::string messagePrefix;
epics::pvData::PVFieldPtr pvValue;
friend class PvaClientPut;
friend class PvaClientPutGet;
};
/**
@@ -707,10 +750,7 @@ class epicsShareClass PvaClientMonitorData
{
public:
POINTER_DEFINITIONS(PvaClientMonitorData);
/**
* @brief Factory method for creating an instance of PvaClientMonitorData.
*/
static PvaClientMonitorDataPtr create(epics::pvData::StructureConstPtr const & structure);
~PvaClientMonitorData() {}
/** Set a prefix for throw messages.
* @param value The prefix.
@@ -814,12 +854,16 @@ public:
* @return The timeStamp.
*/
epics::pvData::TimeStamp getTimeStamp();
/*
* This is called by pvaClientMonitor when it gets a monitor.
* @param monitorElement The new data.
* @param monitorElement The new data.
/** Factory method for creating an instance of PvaClientGetData.
* NOTE: Not normally called by clients
* @param structure Introspection interface
*/
void setData(epics::pvData::MonitorElementPtr const & monitorElement);
static PvaClientMonitorDataPtr create(epics::pvData::StructureConstPtr const & structure);
/** Put data into PVStructure from monitorElement
* NOTE: Not normally called by clients
* @param monitorElement the monitorElement that has new data.
*/
void setData(epics::pvData::MonitorElementPtr const & monitorElement);
private:
PvaClientMonitorData(epics::pvData::StructureConstPtr const & structure);
void checkValue();
@@ -836,13 +880,13 @@ private:
friend class PvaClientMonitor;
};
class ChannelProcessRequesterImpl; // private to PvaClientProcess
/**
* @brief An easy to use alternative to ChannelProcess.
*
* @author mrk
*/
class epicsShareClass PvaClientProcess
class epicsShareClass PvaClientProcess :
public epics::pvAccess::ChannelProcessRequester
{
public:
POINTER_DEFINITIONS(PvaClientProcess);
@@ -860,9 +904,14 @@ public:
/** Destructor
*/
~PvaClientProcess();
/** Destroy all resources used.
*/
void destroy();
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelProcessConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelProcess::shared_pointer const & channelProcess);
void processDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelProcess::shared_pointer const & channelProcess);
/** Call issueConnect and then waitConnect.
* An exception is thrown if connect fails.
* @throw runtime_error if failure.
@@ -887,24 +936,20 @@ public:
* @return status.
*/
epics::pvData::Status waitProcess();
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientProcess(
PvaClientPtr const &pvaClient,
epics::pvAccess::Channel::shared_pointer const & channel,
epics::pvData::PVStructurePtr const &pvRequest);
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelProcessConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelProcess::shared_pointer const & channelProcess);
void processDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelProcess::shared_pointer const & channelProcess);
enum ProcessConnectState {connectIdle,connectActive,connected};
PvaClient::weak_pointer pvaClient;
epics::pvAccess::Channel::shared_pointer channel;
epics::pvAccess::ChannelProcessRequester::shared_pointer processRequester;
epics::pvData::PVStructurePtr pvRequest;
epics::pvData::Mutex mutex;
epics::pvData::Event waitForConnect;
@@ -919,16 +964,15 @@ private:
enum ProcessState {processIdle,processActive,processComplete};
ProcessState processState;
friend class ChannelProcessRequesterImpl;
};
class ChannelGetRequesterImpl; // private to PvaClientGet
/**
* @brief An easy to use alternative to ChannelGet.
*
* @author mrk
*/
class epicsShareClass PvaClientGet
class epicsShareClass PvaClientGet :
public epics::pvAccess::ChannelGetRequester
{
public:
POINTER_DEFINITIONS(PvaClientGet);
@@ -946,10 +990,17 @@ public:
/** Destructor
*/
~PvaClientGet();
/**
* @brief destroy an resources used.
*/
void destroy();
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelGetConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelGet::shared_pointer const & channelGet,
epics::pvData::StructureConstPtr const & structure);
void getDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelGet::shared_pointer const & channelGet,
epics::pvData::PVStructurePtr const & pvStructure,
epics::pvData::BitSetPtr const & bitSet);
/** Call issueConnect and then waitConnect.
* An exception is thrown if connect fails.
* @throw runtime_error if failure.
@@ -979,29 +1030,22 @@ public:
* @brief Get the data/
* @return The interface.
*/
PvaClientGetDataPtr getData();
PvaClientGetDataPtr getData();
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientGet(
PvaClientPtr const &pvaClient,
epics::pvAccess::Channel::shared_pointer const & channel,
epics::pvData::PVStructurePtr const &pvRequest);
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelGetConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelGet::shared_pointer const & channelGet,
epics::pvData::StructureConstPtr const & structure);
void getDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelGet::shared_pointer const & channelGet,
epics::pvData::PVStructurePtr const & pvStructure,
epics::pvData::BitSetPtr const & bitSet);
void checkGetState();
enum GetConnectState {connectIdle,connectActive,connected};
PvaClient::weak_pointer pvaClient;
epics::pvAccess::Channel::shared_pointer channel;
epics::pvAccess::ChannelGetRequester::shared_pointer getRequester;
epics::pvData::PVStructurePtr pvRequest;
epics::pvData::Mutex mutex;
epics::pvData::Event waitForConnect;
@@ -1021,13 +1065,13 @@ private:
friend class ChannelGetRequesterImpl;
};
class ChannelPutRequesterImpl; // private to PvaClientPut
/**
* @brief An easy to use alternative to ChannelPut.
*
* @author mrk
*/
class epicsShareClass PvaClientPut
class epicsShareClass PvaClientPut :
public epics::pvAccess::ChannelPutRequester
{
public:
POINTER_DEFINITIONS(PvaClientPut);
@@ -1045,10 +1089,20 @@ public:
/** Destructor
*/
~PvaClientPut();
/**
* @brief destroy all resources used.
*/
void destroy();
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelPutConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPut::shared_pointer const & channelPut,
epics::pvData::StructureConstPtr const & structure);
void getDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPut::shared_pointer const & channelPut,
epics::pvData::PVStructurePtr const & pvStructure,
epics::pvData::BitSetPtr const & bitSet);
void putDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPut::shared_pointer const & channelPut);
/** Call issueConnect and then waitConnect.
* An exception is thrown if connect fails.
* @throw runtime_error if failure.
@@ -1089,32 +1143,22 @@ public:
* @brief Get the data/
* @return The interface.
*/
PvaClientPutDataPtr getData();
PvaClientPutDataPtr getData();
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private :
PvaClientPut(
PvaClientPtr const &pvaClient,
epics::pvAccess::Channel::shared_pointer const & channel,
epics::pvData::PVStructurePtr const &pvRequest);
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelPutConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPut::shared_pointer const & channelPut,
epics::pvData::StructureConstPtr const & structure);
void getDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPut::shared_pointer const & channelPut,
epics::pvData::PVStructurePtr const & pvStructure,
epics::pvData::BitSetPtr const & bitSet);
void putDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPut::shared_pointer const & channelPut);
void checkPutState();
enum PutConnectState {connectIdle,connectActive,connected};
PvaClient::weak_pointer pvaClient;
epics::pvAccess::Channel::shared_pointer channel;
epics::pvAccess::ChannelPutRequester::shared_pointer putRequester;
epics::pvData::PVStructurePtr pvRequest;
epics::pvData::Mutex mutex;
epics::pvData::Event waitForConnect;
@@ -1127,18 +1171,18 @@ private :
epics::pvAccess::ChannelPut::shared_pointer channelPut;
PutConnectState connectState;
enum PutState {putIdle,getActive,putActive,putComplete};
enum PutState {putIdle,getActive,putActive};
PutState putState;
friend class ChannelPutRequesterImpl;
};
class ChannelPutGetRequesterImpl; // private to PvaClientPutGet
/**
* @brief An easy to use alternative to ChannelPutGet.
*
* @author mrk
*/
class epicsShareClass PvaClientPutGet
class epicsShareClass PvaClientPutGet :
public epics::pvAccess::ChannelPutGetRequester
{
public:
POINTER_DEFINITIONS(PvaClientPutGet);
@@ -1156,9 +1200,28 @@ public:
/** Destructor
*/
~PvaClientPutGet();
/** Destroy all resources used.
*/
void destroy();
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelPutGetConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::StructureConstPtr const & putStructure,
epics::pvData::StructureConstPtr const & getStructure);
void putGetDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::PVStructurePtr const & getPVStructure,
epics::pvData::BitSetPtr const & getBitSet);
void getPutDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::PVStructurePtr const & putPVStructure,
epics::pvData::BitSet::shared_pointer const & putBitSet);
void getGetDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::PVStructurePtr const & getPVStructure,
epics::pvData::BitSet::shared_pointer const & getBitSet);
/** Call issueConnect and then waitConnect.
* An exception is thrown if connect fails.
* @throw runtime_error if failure.
@@ -1215,40 +1278,21 @@ public:
/** Get the get data.
* @return The interface.
*/
PvaClientGetDataPtr getGetData();
PvaClientGetDataPtr getGetData();
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private :
PvaClientPutGet(
PvaClientPtr const &pvaClient,
epics::pvAccess::Channel::shared_pointer const & channel,
epics::pvData::PVStructurePtr const &pvRequest);
std::string getRequesterName();
void message(std::string const & message,epics::pvData::MessageType messageType);
void channelPutGetConnect(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::StructureConstPtr const & putStructure,
epics::pvData::StructureConstPtr const & getStructure);
void putGetDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::PVStructurePtr const & getPVStructure,
epics::pvData::BitSetPtr const & getBitSet);
void getPutDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::PVStructurePtr const & putPVStructure,
epics::pvData::BitSet::shared_pointer const & putBitSet);
void getGetDone(
const epics::pvData::Status& status,
epics::pvAccess::ChannelPutGet::shared_pointer const & channelPutGet,
epics::pvData::PVStructurePtr const & getPVStructure,
epics::pvData::BitSet::shared_pointer const & getBitSet);
void checkPutGetState();
enum PutGetConnectState {connectIdle,connectActive,connected};
PvaClient::weak_pointer pvaClient;
epics::pvAccess::Channel::shared_pointer channel;
epics::pvAccess::ChannelPutGetRequester::shared_pointer putGetRequester;
epics::pvData::PVStructurePtr pvRequest;
epics::pvData::Mutex mutex;
epics::pvData::Event waitForConnect;
@@ -1267,7 +1311,7 @@ private :
friend class ChannelPutGetRequesterImpl;
};
class ChannelMonitorRequester; // private to PvaClientMonitor
//class ChannelMonitorRequester; // private to PvaClientMonitor
/**
* @brief Optional client callback.
*
@@ -1339,9 +1383,6 @@ public:
* @param monitor The monitor.
*/
virtual void monitorEvent(epics::pvData::MonitorPtr const & monitor);
/** Destroy all resources used.
*/
void destroy();
/** Call issueConnect and then waitConnect.
* An exception is thrown if connect fails.
*/
@@ -1390,6 +1431,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientMonitor(
PvaClientPtr const &pvaClient,

View File

@@ -79,9 +79,7 @@ public:
* Destructor
*/
~PvaClientMultiChannel();
/** Destroy the pvAccess connections.
*/
void destroy();
/** Get the channelNames.
* @return The names.
*/
@@ -164,13 +162,16 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientMultiChannel(
PvaClientPtr const &pvaClient,
epics::pvData::shared_vector<const std::string> const & channelName,
std::string const & providerName,
size_t maxNotConnected);
void checkConnected();
PvaClientPtr pvaClient;
@@ -211,9 +212,6 @@ public:
~PvaClientMultiGetDouble();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Create a channelGet for each channel.
*/
@@ -230,6 +228,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientMultiGetDouble(
PvaClientMultiChannelPtr const &pvaClientMultiChannel,
@@ -266,10 +268,6 @@ public:
PvaClientMultiChannelPtr const &pvaMultiChannel,
PvaClientChannelArray const &pvaClientChannelArray);
~PvaClientMultiPutDouble();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Create a channelPut for each channel.
*/
@@ -285,6 +283,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientMultiPutDouble(
PvaClientMultiChannelPtr const &pvaClientMultiChannel,
@@ -320,10 +322,6 @@ public:
PvaClientMultiChannelPtr const &pvaMultiChannel,
PvaClientChannelArray const &pvaClientChannelArray);
~PvaClientMultiMonitorDouble();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Create a channel monitor for each channel.
*/
@@ -336,11 +334,11 @@ public:
bool poll();
/**
* Wait until poll returns true.
* @param waitForEvent The time to keep trying.
* @param secondsToWait The time to keep trying.
* A thread sleep of .1 seconds occurs between each call to poll.
* @return (false,true) if (timeOut, poll returned true).
*/
bool waitEvent(double waitForEvent);
bool waitEvent(double secondsToWait);
/**
* get the data.
* @return The double[] where each element is the value field of the corresponding channel.
@@ -353,6 +351,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientMultiMonitorDouble(
PvaClientMultiChannelPtr const &pvaClientMultiChannel,
@@ -391,10 +393,6 @@ public:
epics::pvData::PVStructurePtr const & pvRequest);
~PvaClientNTMultiGet();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Create a channelGet for each channel.
*/
@@ -415,6 +413,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientNTMultiGet(
epics::pvData::UnionConstPtr const & u,
@@ -453,11 +455,8 @@ public:
static PvaClientNTMultiPutPtr create(
PvaClientMultiChannelPtr const &pvaClientMultiChannel,
PvaClientChannelArray const &pvaClientChannelArray);
~PvaClientNTMultiPut();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Create a channelPut for each channel.
*/
@@ -478,6 +477,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientNTMultiPut(
PvaClientMultiChannelPtr const &pvaClientMultiChannel,
@@ -516,10 +519,6 @@ public:
PvaClientChannelArray const &pvaClientChannelArray,
epics::pvData::PVStructurePtr const & pvRequest);
~PvaClientNTMultiMonitor();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Create a channel monitor for each channel.
*/
@@ -532,11 +531,11 @@ public:
bool poll();
/**
* Wait until poll returns true.
* @param waitForEvent The time to keep trying.
* @param secondsToWait The time to keep trying.
* A thread sleep of .1 seconds occurs between each call to poll.
* @return (false,true) if (timeOut, poll returned true).
*/
bool waitEvent(double waitForEvent);
bool waitEvent(double secondsToWait);
/**
* get the data.
* @return the pvaClientNTMultiData.
@@ -549,6 +548,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientNTMultiMonitor(
epics::pvData::UnionConstPtr const & u,
@@ -590,10 +593,7 @@ public:
PvaClientChannelArray const &pvaClientChannelArray,
epics::pvData::PVStructurePtr const & pvRequest);
~PvaClientNTMultiData();
/** Destroy the pvAccess connection.
*/
void destroy();
/**
* Get the number of channels.
* @return The number of channels.
@@ -626,7 +626,10 @@ public:
{
return shared_from_this();
}
/** Deprecated method
* \deprecated This method will go away in future versions.
*/
void destroy() EPICS_DEPRECATED {}
private:
PvaClientNTMultiData(
epics::pvData::UnionConstPtr const & u,

View File

@@ -37,11 +37,9 @@ class PvaClientChannelCache
public:
PvaClientChannelCache(){}
~PvaClientChannelCache(){
destroy();
if(PvaClient::getDebug()) cout << "PvaClientChannelCache::~PvaClientChannelCache\n";
pvaClientChannelMap.clear();
}
void destroy() {
pvaClientChannelMap.clear();
}
PvaClientChannelPtr getChannel(
string const & channelName,
string const & providerName);
@@ -68,17 +66,12 @@ void PvaClientChannelCache::addChannel(PvaClientChannelPtr const & pvaClientChan
Channel::shared_pointer channel = pvaClientChannel->getChannel();
string name = channel->getChannelName()
+ channel->getProvider()->getProviderName();
pvaClientChannelMap.insert(std::pair<string,PvaClientChannelPtr>(
name,pvaClientChannel));
}
void PvaClientChannelCache::removeChannel(
string const & channelName,
string const & providerName)
{
string name = channelName + providerName;
map<string,PvaClientChannelPtr>::iterator iter = pvaClientChannelMap.find(name);
if(iter!=pvaClientChannelMap.end()) pvaClientChannelMap.erase(iter);
if(iter!=pvaClientChannelMap.end()) {
throw std::runtime_error("pvaClientChannelCache::addChannel channel already cached");
}
pvaClientChannelMap.insert(std::pair<string,PvaClientChannelPtr>(
name,pvaClientChannel));
}
void PvaClientChannelCache::showCache()
@@ -103,6 +96,8 @@ size_t PvaClientChannelCache::cacheSize()
}
bool PvaClient::debug = false;
PvaClientPtr PvaClient::get(std::string const & providerNames)
{
static PvaClientPtr master;
@@ -141,16 +136,16 @@ PvaClient::PvaClient(std::string const & providerNames)
}
PvaClient::~PvaClient() {
destroy();
}
void PvaClient::destroy()
{
if(PvaClient::debug) cout<< "PvaClient::~PvaClient()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClient::~PvaClient() called more then once????\n";
return;
}
isDestroyed = true;
}
if(PvaClient::debug) showCache();
pvaClientChannelCache.reset();
if(pvaStarted) ClientFactory::stop();
if(caStarted) CAClientFactory::stop();

View File

@@ -30,9 +30,9 @@ class PvaClientGetCache
{
public:
PvaClientGetCache(){}
~PvaClientGetCache();
void destroy() {
pvaClientGetMap.clear();
~PvaClientGetCache()
{
pvaClientGetMap.clear();
}
PvaClientGetPtr getGet(string const & request);
void addGet(string const & request,PvaClientGetPtr const & pvaClientGet);
@@ -42,11 +42,6 @@ private:
map<string,PvaClientGetPtr> pvaClientGetMap;
};
PvaClientGetCache::~PvaClientGetCache()
{
destroy();
}
PvaClientGetPtr PvaClientGetCache::getGet(string const & request)
{
map<string,PvaClientGetPtr>::iterator iter = pvaClientGetMap.find(request);
@@ -56,8 +51,11 @@ PvaClientGetPtr PvaClientGetCache::getGet(string const & request)
void PvaClientGetCache::addGet(string const & request,PvaClientGetPtr const & pvaClientGet)
{
pvaClientGetMap.insert(std::pair<string,PvaClientGetPtr>(
request,pvaClientGet));
map<string,PvaClientGetPtr>::iterator iter = pvaClientGetMap.find(request);
if(iter!=pvaClientGetMap.end()) {
throw std::runtime_error("pvaClientGetCache::addGet pvaClientGet already cached");
}
pvaClientGetMap.insert(std::pair<string,PvaClientGetPtr>(request,pvaClientGet));
}
void PvaClientGetCache::showCache()
@@ -79,9 +77,9 @@ class PvaClientPutCache
{
public:
PvaClientPutCache(){}
~PvaClientPutCache();
void destroy() {
pvaClientPutMap.clear();
~PvaClientPutCache()
{
pvaClientPutMap.clear();
}
PvaClientPutPtr getPut(string const & request);
void addPut(string const & request,PvaClientPutPtr const & pvaClientPut);
@@ -91,10 +89,6 @@ private:
map<string,PvaClientPutPtr> pvaClientPutMap;
};
PvaClientPutCache::~PvaClientPutCache()
{
destroy();
}
PvaClientPutPtr PvaClientPutCache::getPut(string const & request)
{
@@ -105,6 +99,10 @@ PvaClientPutPtr PvaClientPutCache::getPut(string const & request)
void PvaClientPutCache::addPut(string const & request,PvaClientPutPtr const & pvaClientPut)
{
map<string,PvaClientPutPtr>::iterator iter = pvaClientPutMap.find(request);
if(iter!=pvaClientPutMap.end()) {
throw std::runtime_error("pvaClientPutCache::addPut pvaClientPut already cached");
}
pvaClientPutMap.insert(std::pair<string,PvaClientPutPtr>(
request,pvaClientPut));
}
@@ -124,30 +122,6 @@ size_t PvaClientPutCache::cacheSize()
}
class ChannelRequesterImpl : public ChannelRequester
{
PvaClientChannel *pvaClientChannel;
public:
ChannelRequesterImpl(PvaClientChannel *pvaClientChannel)
: pvaClientChannel(pvaClientChannel) {}
void channelCreated(
const Status& status,
Channel::shared_pointer const & channel)
{ pvaClientChannel->channelCreated(status,channel); }
void channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState)
{pvaClientChannel->channelStateChange(channel,connectionState);}
tr1::shared_ptr<Channel> getChannel() {return pvaClientChannel->getChannel();}
string getRequesterName()
{return pvaClientChannel->getRequesterName();}
void message(
string const & message,
MessageType messageType)
{ pvaClientChannel->message(message,messageType); }
void destroy() {pvaClientChannel->destroy();}
};
PvaClientChannel::PvaClientChannel(
PvaClientPtr const &pvaClient,
@@ -161,35 +135,75 @@ PvaClientChannel::PvaClientChannel(
createRequest(CreateRequest::create()),
pvaClientGetCache(new PvaClientGetCache()),
pvaClientPutCache(new PvaClientPutCache())
{}
{
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::PvaClientChannel channelName " << channelName << endl;
}
}
PvaClientChannel::~PvaClientChannel()
{
destroy();
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::~PvaClientChannel() "
<< " channelName " << channelName
<< " this " << this << " channel " << channel
<< endl;
}
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
if(PvaClient::getDebug()) showCache();
if(channel) channel->destroy();
if(channel) channel.reset();
pvaClientGetCache.reset();
pvaClientPutCache.reset();
}
void PvaClientChannel::channelCreated(const Status& status, Channel::shared_pointer const & channel)
{
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::channelCreated"
<< " channelName " << channelName
<< " isConnected " << (channel->isConnected() ? "true" : "false")
<< " status.isOK " << (status.isOK() ? "true" : "false")
<< " this " << this
<< endl;
}
Lock xx(mutex);
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
if(status.isOK()) {
this->channel = channel;
if(channel->isConnected()) {
bool waitingForConnect = false;
if(connectState==connectActive) waitingForConnect = true;
connectState = connected;
channelConnectStatus = Status::Ok;
if(waitingForConnect) waitForConnect.signal();
}
return;
if(connectState!=connectActive) {
string message("PvaClientChannel::channelCreated");
message += " channel " + channelName
+ " why was this called when connectState!=ConnectState.connectActive";
throw std::runtime_error(message);
}
if(!status.isOK()) {
string message("PvaClientChannel::channelCreated");
+ " status " + status.getMessage() + " why??";
throw std::runtime_error(message);
}
if(channel->isConnected()) {
connectState = connected;
waitForConnect.signal();
}
cout << "PvaClientChannel::channelCreated status " << status.getMessage() << " why??\n";
}
void PvaClientChannel::channelStateChange(
Channel::shared_pointer const & channel,
Channel::ConnectionState connectionState)
{
if(PvaClient::getDebug()) {
cout << " PvaClientChannel::channelStateChange "
<< " channelName " << channelName
<< " is connected " << (connectionState==Channel::CONNECTED ? "true" : "false")
<< " isDestroyed " << isDestroyed
<< " this " << this
<< endl;
}
Lock xx(mutex);
if(isDestroyed) return;
bool waitingForConnect = false;
@@ -197,12 +211,11 @@ void PvaClientChannel::channelStateChange(
if(connectionState!=Channel::CONNECTED) {
string mess(channelName +
" connection state " + Channel::ConnectionStateNames[connectionState]);
message(mess,errorMessage);
channelConnectStatus = Status(Status::STATUSTYPE_ERROR,mess);
connectState = notConnected;
message(mess,errorMessage);
connectState = notConnected;
return;
} else {
connectState = connected;
channelConnectStatus = Status::Ok;
connectState = connected;
}
if(waitingForConnect) waitForConnect.signal();
}
@@ -210,7 +223,8 @@ void PvaClientChannel::channelStateChange(
string PvaClientChannel::getRequesterName()
{
PvaClientPtr yyy = pvaClient.lock();
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
if(!yyy) throw std::runtime_error(
"PvaClientChannel::getRequesterName() PvaClientChannel isDestroyed");
return yyy->getRequesterName();
}
@@ -218,76 +232,80 @@ void PvaClientChannel::message(
string const & message,
MessageType messageType)
{
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
PvaClientPtr yyy = pvaClient.lock();
if(!yyy) throw std::runtime_error("PvaClient was destroyed");
if(isDestroyed) throw std::runtime_error(
"PvaClientChannel::message() pvaClientChannel isDestroyed");
yyy->message(channelName + " " + message, messageType);
}
void PvaClientChannel::destroy()
{
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
if(channel) channel->destroy();
channel.reset();
pvaClientGetCache.reset();
pvaClientPutCache.reset();
}
string PvaClientChannel::getChannelName()
{
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
if(isDestroyed) throw std::runtime_error(
"PvaClientChannel::getChannelName() pvaClientChannel was destroyed");
return channelName;
}
Channel::shared_pointer PvaClientChannel::getChannel()
{
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
if(isDestroyed) throw std::runtime_error(
"PvaClientChannel::getChannel() pvaClientChannel was destroyed");
return channel;
}
void PvaClientChannel::connect(double timeout)
{
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
if(isDestroyed) throw std::runtime_error(
"PvaClientChannel::connect() pvaClientChannel was destroyed");
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::connect"
<< " channelName " << channelName << endl;
}
issueConnect();
Status status = waitConnect(timeout);
if(status.isOK()) return;
string message = string("channel ") + getChannelName()
if(PvaClient::getDebug()) cout << "PvaClientChannel::connect waitConnect failed\n";
string message = string("channel ") + channelName
+ " PvaClientChannel::connect " + status.getMessage();
throw std::runtime_error(message);
}
void PvaClientChannel::issueConnect()
{
if(isDestroyed) throw std::runtime_error(
"PvaClientChannel::issueConnect() pvaClientChannel was destroyed");
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::issueConnect"
<< " channelName " << channelName << endl;
}
{
Lock xx(mutex);
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
if(connectState!=connectIdle) {
throw std::runtime_error("pvaClientChannel already connected");
}
channelConnectStatus = Status(
Status::STATUSTYPE_ERROR,
getChannelName() + " createChannel failed");
connectState = connectActive;
}
ChannelProviderRegistry::shared_pointer reg = getChannelProviderRegistry();
ChannelProvider::shared_pointer provider = reg->getProvider(providerName);
if(!provider) {
throw std::runtime_error(getChannelName() + " provider " + providerName + " not registered");
throw std::runtime_error(channelName + " provider " + providerName + " not registered");
}
channelRequester = ChannelRequester::shared_pointer(new ChannelRequesterImpl(this));
ChannelRequester::shared_pointer channelRequester(ChannelRequester::shared_pointer(this));
if(PvaClient::getDebug()) cout << "PvaClientChannel::issueConnect calling provider->createChannel\n";
channel = provider->createChannel(channelName,channelRequester,ChannelProvider::PRIORITY_DEFAULT);
if(!channel) {
throw std::runtime_error(getChannelName() + " channelCreate failed ");
throw std::runtime_error(channelName + " channelCreate failed ");
}
}
Status PvaClientChannel::waitConnect(double timeout)
{
if(isDestroyed) throw std::runtime_error(
"PvaClientChannel::waitConnect() pvaClientChannel was destroyed");
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::waitConnect"
<< " channelName " << channelName << endl;
}
{
Lock xx(mutex);
if(isDestroyed) throw std::runtime_error("pvaClientChannel was destroyed");
@@ -298,7 +316,8 @@ Status PvaClientChannel::waitConnect(double timeout)
} else {
waitForConnect.wait();
}
return channelConnectStatus;
if(channel->isConnected()) return Status::Ok;
return Status(Status::STATUSTYPE_ERROR,channelName + " not connected");
}
PvaClientFieldPtr PvaClientChannel::createField()
@@ -321,7 +340,7 @@ PvaClientProcessPtr PvaClientChannel::createProcess(string const & request)
{
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(!pvRequest) {
string message = string("channel ") + getChannelName()
string message = string("channel ") + channelName
+ " PvaClientChannel::createProcess invalid pvRequest: "
+ createRequest->getMessage();
throw std::runtime_error(message);
@@ -358,7 +377,7 @@ PvaClientGetPtr PvaClientChannel::createGet(string const & request)
{
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(!pvRequest) {
string message = string("channel ") + getChannelName()
string message = string("channel ") + channelName
+ " PvaClientChannel::createGet invalid pvRequest: "
+ createRequest->getMessage();
throw std::runtime_error(message);
@@ -396,7 +415,7 @@ PvaClientPutPtr PvaClientChannel::createPut(string const & request)
{
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(!pvRequest) {
string message = string("channel ") + getChannelName()
string message = string("channel ") + channelName
+ " PvaClientChannel::createPut invalid pvRequest: "
+ createRequest->getMessage();
throw std::runtime_error(message);
@@ -421,7 +440,7 @@ PvaClientPutGetPtr PvaClientChannel::createPutGet(string const & request)
{
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(!pvRequest) {
string message = string("channel ") + getChannelName()
string message = string("channel ") + channelName
+ " PvaClientChannel::createPutGet invalid pvRequest: "
+ createRequest->getMessage();
throw std::runtime_error(message);
@@ -447,7 +466,7 @@ PvaClientArrayPtr PvaClientChannel::createArray(string const & request)
{
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(!pvRequest) {
string message = string("channel ") + getChannelName()
string message = string("channel ") + channelName
+ " PvaClientChannel::createArray invalid pvRequest: "
+ createRequest->getMessage();
throw std::runtime_error(message);
@@ -499,7 +518,7 @@ PvaClientMonitorPtr PvaClientChannel::createMonitor(string const & request)
{
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(!pvRequest) {
string message = string("channel ") + getChannelName()
string message = string("channel ") + channelName
+ " PvaClientChannel::createMonitor invalid pvRequest: "
+ createRequest->getMessage();
throw std::runtime_error(message);

View File

@@ -57,11 +57,18 @@ PvaClientGet::PvaClientGet(
connectState(connectIdle),
getState(getIdle)
{
if(PvaClient::getDebug()) cout<< "PvaClientGet::PvaClientGet\n";
}
PvaClientGet::~PvaClientGet()
{
destroy();
if(PvaClient::getDebug()) cout<< "PvaClientGet::~PvaClientGet()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
// if(channelGet) channelGet->destroy();
}
void PvaClientGet::checkGetState()
@@ -75,7 +82,7 @@ void PvaClientGet::checkGetState()
string PvaClientGet::getRequesterName()
{
PvaClientPtr yyy = pvaClient.lock();
if(!yyy) throw std::runtime_error("pvaClient was destroyed");
if(!yyy) return string();
return yyy->getRequesterName();
}
@@ -83,7 +90,7 @@ void PvaClientGet::message(string const & message,MessageType messageType)
{
if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed");
PvaClientPtr yyy = pvaClient.lock();
if(!yyy) throw std::runtime_error("pvaClient was destroyed");
if(!yyy) return;
yyy->message(message, messageType);
}
@@ -93,12 +100,15 @@ void PvaClientGet::channelGetConnect(
StructureConstPtr const & structure)
{
if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed");
channelGetConnectStatus = status;
this->channelGet = channelGet;
if(status.isOK()) {
pvaClientData = PvaClientGetData::create(structure);
pvaClientData->setMessagePrefix(channel->getChannelName());
{
Lock xx(mutex);
channelGetConnectStatus = status;
connectState = connected;
this->channelGet = channelGet;
if(status.isOK()) {
pvaClientData = PvaClientGetData::create(structure);
pvaClientData->setMessagePrefix(channel->getChannelName());
}
}
waitForConnect.signal();
@@ -111,24 +121,15 @@ void PvaClientGet::getDone(
BitSetPtr const & bitSet)
{
if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed");
channelGetStatus = status;
if(status.isOK()) {
pvaClientData->setData(pvStructure,bitSet);
}
waitForGet.signal();
}
// from PvaClientGet
void PvaClientGet::destroy()
{
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
channelGetStatus = status;
getState = getComplete;
if(status.isOK()) {
pvaClientData->setData(pvStructure,bitSet);
}
}
if(channelGet) channelGet->destroy();
channelGet.reset();
waitForGet.signal();
}
void PvaClientGet::connect()
@@ -150,7 +151,7 @@ void PvaClientGet::issueConnect()
+ " pvaClientGet already connected ";
throw std::runtime_error(message);
}
getRequester = ChannelGetRequester::shared_pointer(new ChannelGetRequesterImpl(this));
ChannelGetRequester::shared_pointer getRequester(ChannelGetRequester::shared_pointer(this));
connectState = connectActive;
channelGet = channel->createChannelGet(getRequester,pvRequest);
}
@@ -158,14 +159,20 @@ void PvaClientGet::issueConnect()
Status PvaClientGet::waitConnect()
{
if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed");
if(connectState==connected) return channelGetConnectStatus;
if(connectState!=connectActive) {
string message = string("channel ") + channel->getChannelName()
+ " pvaClientGet illegal connect state ";
throw std::runtime_error(message);
{
Lock xx(mutex);
if(connectState==connected) {
if(!channelGetConnectStatus.isOK()) connectState = connectIdle;
return channelGetConnectStatus;
}
if(connectState!=connectActive) {
string message = string("channel ") + channel->getChannelName()
+ " pvaClientGet illegal connect state ";
throw std::runtime_error(message);
}
}
waitForConnect.wait();
connectState = channelGetConnectStatus.isOK() ? connected : connectIdle;
if(!channelGetConnectStatus.isOK()) connectState = connectIdle;
return channelGetConnectStatus;
}
@@ -196,16 +203,20 @@ void PvaClientGet::issueGet()
Status PvaClientGet::waitGet()
{
if(isDestroyed) throw std::runtime_error("pvaClientGet was destroyed");
if(getState!=getActive){
string message = string("channel ") + channel->getChannelName()
+ " PvaClientGet::waitGet llegal get state";
throw std::runtime_error(message);
{
Lock xx(mutex);
if(getState==getComplete) {
getState =getIdle;
return channelGetStatus;
}
if(getState!=getActive){
string message = string("channel ") + channel->getChannelName()
+ " PvaClientGet::waitGet llegal get state";
throw std::runtime_error(message);
}
}
waitForGet.wait();
getState = getIdle;
if(channelGetStatus.isOK()) {
return Status::Ok;
}
return channelGetStatus;
}
PvaClientGetDataPtr PvaClientGet::getData()

View File

@@ -37,11 +37,23 @@ PvaClientMonitor::PvaClientMonitor(
userPoll(false),
userWait(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientMonitor::PvaClientMonitor()\n";
}
PvaClientMonitor::~PvaClientMonitor()
{
destroy();
if(PvaClient::getDebug()) cout<< "PvaClientMonitor::~PvaClientMonitor()\n";
{
Lock xx(mutex);
if(isDestroyed) {
cerr<< "Why was PvaClientMonitor::~PvaClientMonitor() called more then once????\n";
return;
}
isDestroyed = true;
}
if(monitor) monitor->destroy();
monitor.reset();
monitorElement.reset();
}
void PvaClientMonitor::checkMonitorState()
@@ -74,6 +86,7 @@ void PvaClientMonitor::monitorConnect(
{
if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed");
connectStatus = status;
connectState = connected;
this->monitor = monitor;
if(status.isOK()) {
pvaClientData = PvaClientMonitorData::create(structure);
@@ -93,19 +106,16 @@ void PvaClientMonitor::monitorEvent(MonitorPtr const & monitor)
void PvaClientMonitor::unlisten(MonitorPtr const & monitor)
{
destroy();
}
void PvaClientMonitor::destroy()
{
if(PvaClient::getDebug()) cout << "PvaClientMonitor::unlisten\n";
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
if(isDestroyed) {
cerr<< "Why was PvaClientMonitor::unlisten called when PvaClientMonitor was destroyed?\n";
return;
}
}
if(monitor) monitor->destroy();
monitor.reset();
monitorElement.reset();
this->monitor.reset();
this->monitorElement.reset();
}
void PvaClientMonitor::connect()
@@ -137,6 +147,10 @@ void PvaClientMonitor::issueConnect()
Status PvaClientMonitor::waitConnect()
{
if(isDestroyed) throw std::runtime_error("pvaClientMonitor was destroyed");
if(connectState==connected) {
if(connectStatus.isOK()) connectState = connectIdle;
return connectStatus;
}
if(connectState!=connectActive) {
string message = string("channel ") + channel->getChannelName()
+ " pvaClientMonitor illegal connect state ";

View File

@@ -56,18 +56,18 @@ PvaClientMultiChannel::PvaClientMultiChannel(
createRequest(CreateRequest::create()),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiChannel::PvaClientMultiChannel()\n";
}
PvaClientMultiChannel::~PvaClientMultiChannel()
{
destroy();
}
void PvaClientMultiChannel::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiChannel::~PvaClientMultiChannel()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientMultiChannel::~PvaClientMultiChannel() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();
@@ -75,11 +75,7 @@ void PvaClientMultiChannel::destroy()
void PvaClientMultiChannel::checkConnected()
{
if(numConnected==0){
Status status = connect(3.0);
if(status.isOK()) return;
throw std::runtime_error("pvaClientMultiChannel connect failure");
}
if(numConnected==0) connect();
}
epics::pvData::shared_vector<const string> PvaClientMultiChannel::getChannelNames()

View File

@@ -51,18 +51,18 @@ PvaClientMultiGetDouble::PvaClientMultiGetDouble(
isGetConnected(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiGetDouble::PvaClientMultiGetDouble()\n";
}
PvaClientMultiGetDouble::~PvaClientMultiGetDouble()
{
destroy();
}
void PvaClientMultiGetDouble::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiGetDouble::~PvaClientMultiGetDouble()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientMultiGetDouble::~PvaClientMultiGetDouble() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();

View File

@@ -52,18 +52,18 @@ PvaClientMultiMonitorDouble::PvaClientMultiMonitorDouble(
isMonitorConnected(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiMonitorDouble::PvaClientMultiMonitorDouble()\n";
}
PvaClientMultiMonitorDouble::~PvaClientMultiMonitorDouble()
{
destroy();
}
void PvaClientMultiMonitorDouble::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiMonitorDouble::~PvaClientMultiMonitorDouble()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientMultiMonitorDouble::~PvaClientMultiMonitorDouble() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();

View File

@@ -51,25 +51,26 @@ PvaClientMultiPutDouble::PvaClientMultiPutDouble(
isPutConnected(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiPutDouble::PvaClientMultiPutDouble()\n";
}
PvaClientMultiPutDouble::~PvaClientMultiPutDouble()
{
destroy();
}
void PvaClientMultiPutDouble::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientMultiPutDouble::~PvaClientMultiPutDouble()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientMultiPutDouble::~PvaClientMultiPutDouble() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();
}
void PvaClientMultiPutDouble::connect()
{
shared_vector<epics::pvData::boolean> isConnected = pvaClientMultiChannel->getIsConnected();

View File

@@ -48,6 +48,7 @@ PvaClientNTMultiData::PvaClientNTMultiData(
gotTimeStamp(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiData::PvaClientNTMultiData()\n";
PVFieldPtr pvValue = pvRequest->getSubField("field.value");
if(!pvValue) {
throw std::runtime_error("pvRequest did not specify value");
@@ -88,19 +89,19 @@ PvaClientNTMultiData::PvaClientNTMultiData(
PvaClientNTMultiData::~PvaClientNTMultiData()
{
destroy();
}
void PvaClientNTMultiData::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiData::~PvaClientNTMultiData()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientNTMultiData::~PvaClientNTMultiData() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();
}
void PvaClientNTMultiData::setStructure(StructureConstPtr const & structure,size_t index)
{
FieldConstPtr field = structure->getField("value");

View File

@@ -60,18 +60,18 @@ PvaClientNTMultiGet::PvaClientNTMultiGet(
isConnected(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiGet::PvaClientNTMultiGet()\n";
}
PvaClientNTMultiGet::~PvaClientNTMultiGet()
{
destroy();
}
void PvaClientNTMultiGet::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiGet::~PvaClientNTMultiGet()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientNTMultiGet::~PvaClientNTMultiGet() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();

View File

@@ -57,19 +57,19 @@ PvaClientNTMultiMonitor::PvaClientNTMultiMonitor(
isConnected(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiMonitor::PvaClientNTMultiMonitor()\n";
}
PvaClientNTMultiMonitor::~PvaClientNTMultiMonitor()
{
destroy();
}
void PvaClientNTMultiMonitor::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiMonitor::~PvaClientNTMultiMonitor()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientNTMultiMonitor::~PvaClientNTMultiMonitor() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();

View File

@@ -48,19 +48,19 @@ PvaClientNTMultiPut::PvaClientNTMultiPut(
isConnected(false),
isDestroyed(false)
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiPut::PvaClientNTMultiPut()\n";
}
PvaClientNTMultiPut::~PvaClientNTMultiPut()
{
destroy();
}
void PvaClientNTMultiPut::destroy()
{
if(PvaClient::getDebug()) cout<< "PvaClientNTMultiPut::~PvaClientNTMultiPut()\n";
{
Lock xx(mutex);
if(isDestroyed) return;
if(isDestroyed) {
cerr<< "Why was PvaClientNTMultiPut::~PvaClientNTMultiPut() called more then once????\n";
return;
}
isDestroyed = true;
}
pvaClientChannelArray.clear();

View File

@@ -54,11 +54,21 @@ PvaClientProcess::PvaClientProcess(
connectState(connectIdle),
processState(processIdle)
{
if(PvaClient::getDebug()) cout<< "PvaClientProcess::PvaClientProcess()\n";
}
PvaClientProcess::~PvaClientProcess()
{
destroy();
if(PvaClient::getDebug()) cout<< "PvaClientProcess::~PvaClientProcess()\n";
{
Lock xx(mutex);
if(isDestroyed) {
cerr<< "Why was PvaClientProcess::~PvaClientProcess() called more then once????\n";
return;
}
isDestroyed = true;
}
channelProcess->destroy();
}
// from ChannelProcessRequester
@@ -97,19 +107,6 @@ void PvaClientProcess::processDone(
waitForProcess.signal();
}
// from PvaClientProcess
void PvaClientProcess::destroy()
{
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
if(channelProcess) channelProcess->destroy();
channelProcess.reset();
}
void PvaClientProcess::connect()
{
if(isDestroyed) throw std::runtime_error("pvaClientProcess was destroyed");
@@ -129,7 +126,8 @@ void PvaClientProcess::issueConnect()
+ " pvaClientProcess already connected ";
throw std::runtime_error(message);
}
processRequester = ChannelProcessRequester::shared_pointer(new ChannelProcessRequesterImpl(this));
ChannelProcessRequester::shared_pointer processRequester(
ChannelProcessRequester::shared_pointer(this));
connectState = connectActive;
channelProcess = channel->createChannelProcess(processRequester,pvRequest);
}

View File

@@ -60,11 +60,21 @@ PvaClientPut::PvaClientPut(
connectState(connectIdle),
putState(putIdle)
{
if(PvaClient::getDebug()) cout<< "PvaClientPut::PvaClientPut()\n";
}
PvaClientPut::~PvaClientPut()
{
destroy();
if(PvaClient::getDebug()) cout<< "PvaClientPut::~PvaClientPut()\n";
{
Lock xx(mutex);
if(isDestroyed) {
cerr<< "Why was PvaClientPut::~PvaClientPut() called more then once????\n";
return;
}
isDestroyed = true;
}
if(channelPut) channelPut->destroy();
}
void PvaClientPut::checkPutState()
@@ -116,6 +126,7 @@ void PvaClientPut::getDone(
{
if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed");
channelGetPutStatus = status;
connectState = connected;
if(status.isOK()) {
PVStructurePtr pvs = pvaClientData->getPVStructure();
pvs->copyUnchecked(*pvStructure,*bitSet);
@@ -135,27 +146,16 @@ void PvaClientPut::putDone(
waitForGetPut.signal();
}
// from PvaClientPut
void PvaClientPut::destroy()
{
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
if(channelPut) channelPut->destroy();
channelPut.reset();
}
void PvaClientPut::connect()
{
if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed");
issueConnect();
Status status = waitConnect();
if(status.isOK()) return;
string message = string("channel ") + channel->getChannelName()
+ " PvaClientPut::connect " + status.getMessage();
string message = string("channel ")
+ channel->getChannelName()
+ " PvaClientPut::connect "
+ status.getMessage();
throw std::runtime_error(message);
}
@@ -167,7 +167,7 @@ void PvaClientPut::issueConnect()
+ " pvaClientPut already connected ";
throw std::runtime_error(message);
}
putRequester = ChannelPutRequester::shared_pointer(new ChannelPutRequesterImpl(this));
ChannelPutRequester::shared_pointer putRequester(ChannelPutRequester::shared_pointer(this));
connectState = connectActive;
channelPut = channel->createChannelPut(putRequester,pvRequest);
}
@@ -175,13 +175,17 @@ void PvaClientPut::issueConnect()
Status PvaClientPut::waitConnect()
{
if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed");
if(connectState==connected) {
if(!channelPutConnectStatus.isOK()) connectState = connectIdle;
return channelPutConnectStatus;
}
if(connectState!=connectActive) {
string message = string("channel ") + channel->getChannelName()
+ " pvaClientPut illegal connect state ";
throw std::runtime_error(message);
}
waitForConnect.wait();
connectState = channelPutConnectStatus.isOK() ? connected : connectIdle;
if(!channelPutConnectStatus.isOK()) connectState = connectIdle;
return channelPutConnectStatus;
}
@@ -191,8 +195,10 @@ void PvaClientPut::get()
issueGet();
Status status = waitGet();
if(status.isOK()) return;
string message = string("channel ") + channel->getChannelName()
+ " PvaClientPut::get " + status.getMessage();
string message = string("channel ")
+ channel->getChannelName()
+ " PvaClientPut::get "
+ status.getMessage();
throw std::runtime_error(message);
}
@@ -201,12 +207,12 @@ void PvaClientPut::issueGet()
if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed");
if(connectState==connectIdle) connect();
if(putState!=putIdle) {
string message = string("channel ") + channel->getChannelName()
string message = string("channel ")
+ channel->getChannelName()
+ "PvaClientPut::issueGet get or put aleady active ";
throw std::runtime_error(message);
}
putState = getActive;
pvaClientData->getChangedBitSet()->clear();
channelPut->get();
}
@@ -215,7 +221,7 @@ Status PvaClientPut::waitGet()
if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed");
if(putState!=getActive){
string message = string("channel ") + channel->getChannelName()
+ " PvaClientPut::waitGet llegal put state";
+ " PvaClientPut::waitGet illegal put state";
throw std::runtime_error(message);
}
waitForGetPut.wait();
@@ -229,8 +235,10 @@ void PvaClientPut::put()
issuePut();
Status status = waitPut();
if(status.isOK()) return;
string message = string("channel ") + channel->getChannelName()
+ " PvaClientPut::put " + status.getMessage();
string message = string("channel ")
+ channel->getChannelName()
+ " PvaClientPut::put "
+ status.getMessage();
throw std::runtime_error(message);
}
@@ -252,7 +260,7 @@ Status PvaClientPut::waitPut()
if(isDestroyed) throw std::runtime_error("pvaClientPut was destroyed");
if(putState!=putActive){
string message = string("channel ") + channel->getChannelName()
+ " PvaClientPut::waitPut llegal put state";
+ " PvaClientPut::waitPut illegal put state";
throw std::runtime_error(message);
}
waitForGetPut.wait();

View File

@@ -36,7 +36,6 @@ public:
void postPut() { easyData->postPut(fieldNumber);}
};
typedef std::tr1::shared_ptr<PVArray> PVArrayPtr;
static ConvertPtr convert = getConvert();
static string noValue("no value field");

View File

@@ -76,11 +76,21 @@ PvaClientPutGet::PvaClientPutGet(
connectState(connectIdle),
putGetState(putGetIdle)
{
if(PvaClient::getDebug()) cout<< "PvaClientPutGet::PvaClientPutGet()\n";
}
PvaClientPutGet::~PvaClientPutGet()
{
destroy();
if(PvaClient::getDebug()) cout<< "PvaClientPutGet::~PvaClientPutGet()\n";
{
Lock xx(mutex);
if(isDestroyed) {
cerr<< "Why was PvaClientPutGet::~PvaClientPutGet() called more then once????\n";
return;
}
isDestroyed = true;
}
channelPutGet->destroy();
}
void PvaClientPutGet::checkPutGetState()
@@ -173,20 +183,6 @@ void PvaClientPutGet::getGetDone(
waitForPutGet.signal();
}
// from PvaClientPutGet
void PvaClientPutGet::destroy()
{
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
if(channelPutGet) channelPutGet->destroy();
channelPutGet.reset();
}
void PvaClientPutGet::connect()
{
if(isDestroyed) throw std::runtime_error("pvaClientPutGet was destroyed");
@@ -206,7 +202,7 @@ void PvaClientPutGet::issueConnect()
+ " pvaClientPutGet already connected ";
throw std::runtime_error(message);
}
putGetRequester = ChannelPutGetRequester::shared_pointer(new ChannelPutGetRequesterImpl(this));
ChannelPutGetRequester::shared_pointer putGetRequester(ChannelPutGetRequester::shared_pointer(this));
connectState = connectActive;
channelPutGet = channel->createChannelPutGet(putGetRequester,pvRequest);
}