This is Unofficial EPICS BASE Doxygen Site
epics::pvaClient::PvaClient Class Reference

pvaClient is a synchronous wrapper for the pvAccess API, which is a callback based API. More...

#include "pvaClient.h"

+ Inheritance diagram for epics::pvaClient::PvaClient:
+ Collaboration diagram for epics::pvaClient::PvaClient:

Public Member Functions

 POINTER_DEFINITIONS (PvaClient)
 
 ~PvaClient ()
 Destructor. More...
 
std::string getRequesterName ()
 
void message (std::string const &message, epics::pvData::MessageType messageType)
 A new message. More...
 
PvaClientChannelPtr channel (std::string const &channelName, std::string const &providerName="pva", double timeOut=5.0)
 Get a cached channel or create and connect to a new channel. More...
 
PvaClientChannelPtr createChannel (std::string const &channelName, std::string const &providerName="pva")
 Create an PvaClientChannel with the specified provider. More...
 
void setRequester (epics::pvData::RequesterPtr const &requester)
 Set a requester. More...
 
void clearRequester ()
 Clear the requester. PvaClient will handle messages. More...
 
void showCache ()
 Show the list of cached channels. More...
 
size_t cacheSize ()
 Get the number of cached channels. More...
 

Static Public Member Functions

static PvaClientPtr get (std::string const &providerNames="pva ca")
 Get the single instance of PvaClient. More...
 
static PvaClientPtr create () EPICS_DEPRECATED
 Get the requester name. More...
 
static void setDebug (bool value)
 Should debug info be shown? More...
 
static bool getDebug ()
 Is debug set? More...
 

Detailed Description

pvaClient is a synchronous wrapper for the pvAccess API, which is a callback based API.

Overview of PvaClient

Definition at line 106 of file pvaClient.h.

Constructor & Destructor Documentation

epics::pvaClient::PvaClient::~PvaClient ( )

Destructor.

Definition at line 148 of file pvaClient.cpp.

148  {
149  if(getDebug()) {
150  cout<< "PvaClient::~PvaClient()\n"
151  << "pvaChannel cache:\n";
152  showCache();
153  }
154  if(pvaStarted){
155  if(getDebug()) cout<< "calling ClientFactory::stop()\n";
156  ClientFactory::stop();
157  if(getDebug()) cout<< "after calling ClientFactory::stop()\n";
158  }
159  if(caStarted) {
160  if(getDebug()) cout<< "calling CAClientFactory::stop()\n";
161  CAClientFactory::stop();
162  if(getDebug()) cout<< "after calling CAClientFactory::stop()\n";
163  }
164 channelRegistry.reset();
165 }
void showCache()
Show the list of cached channels.
Definition: pvaClient.cpp:218
static bool getDebug()
Is debug set?
Definition: pvaClient.cpp:97

Member Function Documentation

size_t epics::pvaClient::PvaClient::cacheSize ( )

Get the number of cached channels.

Definition at line 228 of file pvaClient.cpp.

229 {
230  return pvaClientChannelCache->cacheSize();
231 }
PvaClientChannelPtr epics::pvaClient::PvaClient::channel ( std::string const &  channelName,
std::string const &  providerName = "pva",
double  timeOut = 5.0 
)

Get a cached channel or create and connect to a new channel.

Parameters
channelNameThe channelName.
providerNameThe providerName.
timeOutThe number of seconds to wait for connection. 0.0 means forever.
Returns
The interface.
Exceptions
runtime_errorif connection fails.

Definition at line 189 of file pvaClient.cpp.

193 {
194  PvaClientChannelPtr pvaClientChannel =
195  pvaClientChannelCache->getChannel(channelName,providerName);
196  if(pvaClientChannel) return pvaClientChannel;
197  pvaClientChannel = createChannel(channelName,providerName);
198  pvaClientChannel->connect(timeOut);
199  pvaClientChannelCache->addChannel(pvaClientChannel);
200  return pvaClientChannel;
201 }
std::tr1::shared_ptr< PvaClientChannel > PvaClientChannelPtr
Definition: pvaClient.h:59
PvaClientChannelPtr createChannel(std::string const &channelName, std::string const &providerName="pva")
Create an PvaClientChannel with the specified provider.
Definition: pvaClient.cpp:203
void epics::pvaClient::PvaClient::clearRequester ( )

Clear the requester. PvaClient will handle messages.

Definition at line 213 of file pvaClient.cpp.

214 {
215  requester.reset();
216 }
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
PvaClientPtr epics::pvaClient::PvaClient::create ( )
static

Get the requester name.

Returns
The name.Create an instance of PvaClient with providerName "pva ca".
shared pointer to the single instance
Deprecated:
This method will go away in future versions. Use get instead.

Definition at line 113 of file pvaClient.cpp.

113 {return get();}
PvaClientChannelPtr epics::pvaClient::PvaClient::createChannel ( std::string const &  channelName,
std::string const &  providerName = "pva" 
)

Create an PvaClientChannel with the specified provider.

Parameters
channelNameThe channelName.
providerNameThe provider.
Returns
The interface.
Exceptions
runtime_errorif connection fails.

Definition at line 203 of file pvaClient.cpp.

204 {
205  return PvaClientChannel::create(shared_from_this(),channelName,providerName);
206 }
PvaClientPtr epics::pvaClient::PvaClient::get ( std::string const &  providerNames = "pva ca")
static

Get the single instance of PvaClient.

Parameters
providerNamesSpace separated list of provider names.
Returns
shared pointer to the single instance.

Definition at line 102 of file pvaClient.cpp.

103 {
104  static PvaClientPtr master;
105  static Mutex mutex;
106  Lock xx(mutex);
107  if(!master) {
108  master = PvaClientPtr(new PvaClient(providerNames));
109  }
110  return master;
111 }
std::tr1::shared_ptr< PvaClient > PvaClientPtr
Definition: pvaClient.h:46
A lock for multithreading.
Definition: lock.h:36
epicsMutex Mutex
Definition: lock.h:28
bool epics::pvaClient::PvaClient::getDebug ( )
static

Is debug set?

Returns
true or false

Definition at line 97 of file pvaClient.cpp.

98 {
99  return debug;
100 }
string epics::pvaClient::PvaClient::getRequesterName ( )

Definition at line 167 of file pvaClient.cpp.

168 {
169  static string name("pvaClient");
170  RequesterPtr req = requester.lock();
171  if(req) {
172  return req->getRequesterName();
173  }
174  return name;
175 }
std::tr1::shared_ptr< Requester > RequesterPtr
Definition: requester.h:31
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
void epics::pvaClient::PvaClient::message ( std::string const &  message,
epics::pvData::MessageType  messageType 
)

A new message.

If a requester is set then it is called otherwise message is displayed on standard out.

Parameters
messageThe message.
messageTypeThe type.

Definition at line 177 of file pvaClient.cpp.

180 {
181  RequesterPtr req = requester.lock();
182  if(req) {
183  req->message(message,messageType);
184  return;
185  }
186  cout << getMessageTypeName(messageType) << " " << message << endl;
187 }
void message(std::string const &message, epics::pvData::MessageType messageType)
A new message.
Definition: pvaClient.cpp:177
epicsShareExtern std::string getMessageTypeName(MessageType messageType)
Definition: requester.cpp:25
std::tr1::shared_ptr< Requester > RequesterPtr
Definition: requester.h:31
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
epics::pvaClient::PvaClient::POINTER_DEFINITIONS ( PvaClient  )
void epics::pvaClient::PvaClient::setDebug ( bool  value)
static

Should debug info be shown?

Parameters
valuetrue or false

Definition at line 92 of file pvaClient.cpp.

93 {
94  debug = value;
95 }
Definition: link.h:174
void epics::pvaClient::PvaClient::setRequester ( epics::pvData::RequesterPtr const &  requester)

Set a requester.

The default is for PvaClient to handle messages by printing to System.out.

Parameters
requesterThe requester.

Definition at line 208 of file pvaClient.cpp.

209 {
210  this->requester = requester;
211 }
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
void epics::pvaClient::PvaClient::showCache ( )

Show the list of cached channels.

Definition at line 218 of file pvaClient.cpp.

219 {
220  if(pvaClientChannelCache->cacheSize()>=1) {
221  pvaClientChannelCache->showCache();
222  } else {
223  cout << "pvaClientChannelCache is empty\n";
224  }
225 }

The documentation for this class was generated from the following files: