This is Unofficial EPICS BASE Doxygen Site
epics::pvAccess::ca::CAChannelProvider Class Reference

#include "caProviderPvt.h"

+ Inheritance diagram for epics::pvAccess::ca::CAChannelProvider:
+ Collaboration diagram for epics::pvAccess::ca::CAChannelProvider:

Public Member Functions

 POINTER_DEFINITIONS (CAChannelProvider)
 
 CAChannelProvider ()
 
 CAChannelProvider (const std::tr1::shared_ptr< Configuration > &)
 
virtual ~CAChannelProvider ()
 
virtual std::string getProviderName ()
 
virtual ChannelFind::shared_pointer channelFind (std::string const &channelName, ChannelFindRequester::shared_pointer const &channelFindRequester)
 
virtual ChannelFind::shared_pointer channelList (ChannelListRequester::shared_pointer const &channelListRequester)
 
virtual Channel::shared_pointer createChannel (std::string const &channelName, ChannelRequester::shared_pointer const &channelRequester, short priority)
 
virtual Channel::shared_pointer createChannel (std::string const &channelName, ChannelRequester::shared_pointer const &channelRequester, short priority, std::string const &address)
 
virtual void configure (epics::pvData::PVStructure::shared_pointer configuration)
 
virtual void flush ()
 
virtual void poll ()
 
void attachContext ()
 
void addChannel (const CAChannelPtr &channel)
 
- Public Member Functions inherited from epics::pvAccess::ChannelProvider
 POINTER_DEFINITIONS (ChannelProvider)
 
 ChannelProvider ()
 
virtual ~ChannelProvider ()
 
- Public Member Functions inherited from epics::pvAccess::Destroyable
 POINTER_DEFINITIONS (Destroyable)
 

Additional Inherited Members

- Static Public Attributes inherited from epics::pvAccess::ChannelProvider
static const short PRIORITY_MIN = 0
 
static const short PRIORITY_MAX = 99
 
static const short PRIORITY_DEFAULT = PRIORITY_MIN
 
static const short PRIORITY_LINKS_DB = PRIORITY_MAX
 
static const short PRIORITY_ARCHIVE = (PRIORITY_MAX + PRIORITY_MIN) / 2
 
static const short PRIORITY_OPI = PRIORITY_MIN
 
static size_t num_instances
 
- Protected Member Functions inherited from epics::pvAccess::Destroyable
virtual ~Destroyable ()
 

Detailed Description

Definition at line 47 of file caProviderPvt.h.

Constructor & Destructor Documentation

epics::pvAccess::ca::CAChannelProvider::CAChannelProvider ( )

Definition at line 35 of file caProvider.cpp.

36  : current_context(0)
37 {
38  initialize();
39 }
#define initialize
Definition: aaiRecord.c:54
epics::pvAccess::ca::CAChannelProvider::CAChannelProvider ( const std::tr1::shared_ptr< Configuration > &  )

Definition at line 41 of file caProvider.cpp.

42  : current_context(0),
43  channelConnectThread(ChannelConnectThread::get()),
44  monitorEventThread(MonitorEventThread::get()),
45  getDoneThread(GetDoneThread::get()),
46  putDoneThread(PutDoneThread::get())
47 {
48  if(DEBUG_LEVEL>0) {
49  std::cout<< "CAChannelProvider::CAChannelProvider\n";
50  }
51  initialize();
52 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
#define initialize
Definition: aaiRecord.c:54
static PutDoneThreadPtr get()
static GetDoneThreadPtr get()
static MonitorEventThreadPtr get()
epics::pvAccess::ca::CAChannelProvider::~CAChannelProvider ( )
virtual

Definition at line 54 of file caProvider.cpp.

55 {
56  if(DEBUG_LEVEL>0) {
57  std::cout << "CAChannelProvider::~CAChannelProvider()"
58  << " caChannelList.size() " << caChannelList.size()
59  << std::endl;
60  }
61  std::queue<CAChannelPtr> channelQ;
62  {
63  Lock lock(channelListMutex);
64  for(size_t i=0; i< caChannelList.size(); ++i)
65  {
66  CAChannelPtr caChannel(caChannelList[i].lock());
67  if(caChannel) channelQ.push(caChannel);
68  }
69  caChannelList.clear();
70  }
71  while(!channelQ.empty()) {
72  if(DEBUG_LEVEL>0) {
73  std::cout << "~CAChannelProvider() calling disconnectChannel "
74  << channelQ.front()->getChannelName()
75  << std::endl;
76  }
77  channelQ.front()->disconnectChannel();
78  channelQ.pop();
79  }
80  putDoneThread->stop();
81  getDoneThread->stop();
82  monitorEventThread->stop();
83  channelConnectThread->stop();
84  if(DEBUG_LEVEL>0) {
85  std::cout << "CAChannelProvider::~CAChannelProvider() calling ca_context_destroy\n";
86  }
88 //std::cout << "CAChannelProvider::~CAChannelProvider() returning\n";
89 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
int i
Definition: scan.c:967
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< CAChannel > CAChannelPtr
Definition: caChannel.h:31
void epicsStdCall ca_context_destroy()
Definition: access.cpp:232

Member Function Documentation

void epics::pvAccess::ca::CAChannelProvider::addChannel ( const CAChannelPtr channel)

Definition at line 147 of file caProvider.cpp.

148 {
149  if(DEBUG_LEVEL>0) {
150  std::cout << "CAChannelProvider::addChannel "
151  << channel->getChannelName()
152  << std::endl;
153  }
154  Lock lock(channelListMutex);
155  for(size_t i=0; i< caChannelList.size(); ++i) {
156  if(!(caChannelList[i].lock())) {
157  caChannelList[i] = channel;
158  return;
159  }
160  }
161  caChannelList.push_back(channel);
162 }
#define DEBUG_LEVEL
Definition: caProviderPvt.h:25
epicsMutexId lock
Definition: osiClockTime.c:37
int i
Definition: scan.c:967
A lock for multithreading.
Definition: lock.h:36
void epics::pvAccess::ca::CAChannelProvider::attachContext ( )

Definition at line 176 of file caProvider.cpp.

177 {
178  ca_client_context* thread_context = ca_current_context();
179  if (thread_context == current_context) return;
180  int result = ca_attach_context(current_context);
181  if(result==ECA_ISATTACHED) return;
182  if (result != ECA_NORMAL) {
183  std::string mess("CAChannelProvider::attachContext error calling ca_attach_context ");
184  mess += ca_message(result);
185  throw std::runtime_error(mess);
186  }
187 }
pvac::PutEvent result
Definition: clientSync.cpp:117
int epicsStdCall ca_attach_context(struct ca_client_context *pCtx)
Definition: access.cpp:746
#define ECA_NORMAL
Definition: caerr.h:77
#define ECA_ISATTACHED
Definition: caerr.h:130
const char *epicsStdCall ca_message(long ca_status)
Definition: access.cpp:561
struct ca_client_context *epicsStdCall ca_current_context()
Definition: access.cpp:726
ChannelFind::shared_pointer epics::pvAccess::ca::CAChannelProvider::channelFind ( std::string const &  name,
ChannelFindRequester::shared_pointer const &  requester 
)
virtual

Test to see if this provider has the named channel.

May call ChannelFindRequester::channelFindResult() before returning, or at some time later. If an exception is thrown, then channelFindResult() will never be called.

Parameters
nameThe channel name.
requesterThe Requester.
Returns
An unique()==true handle for the pending response. May only return NULL if channelFindResult() called with an Error

Implements epics::pvAccess::ChannelProvider.

Definition at line 96 of file caProvider.cpp.

99 {
100  if (channelName.empty())
101  throw std::invalid_argument("CAChannelProvider::channelFind empty channel name");
102 
103  if (!channelFindRequester)
104  throw std::invalid_argument("CAChannelProvider::channelFind null requester");
105 
106  Status errorStatus(Status::STATUSTYPE_ERROR, "CAChannelProvider::channelFind not implemented");
107  ChannelFind::shared_pointer nullChannelFind;
108  EXCEPTION_GUARD(channelFindRequester->channelFindResult(errorStatus, nullChannelFind, false));
109  return nullChannelFind;
110 }
#define EXCEPTION_GUARD(code)
Definition: caProvider.cpp:31
ChannelFind::shared_pointer epics::pvAccess::ca::CAChannelProvider::channelList ( ChannelListRequester::shared_pointer const &  requester)
virtual

Request a list of all valid channel names for this provider.

May call ChannelListRequester::channelListResult() before returning, or at some time later. If an exception is thrown, then channelListResult() will never be called.

Parameters
requesterThe Requester.
Returns
An unique()==true handle for the pending response. May only return NULL if channelFindResult() called with an Error

Reimplemented from epics::pvAccess::ChannelProvider.

Definition at line 112 of file caProvider.cpp.

114 {
115  if (!channelListRequester.get())
116  throw std::runtime_error("CAChannelProvider::channelList null requester");
117 
118  Status errorStatus(Status::STATUSTYPE_ERROR, "CAChannelProvider::channelList not implemented");
119  ChannelFind::shared_pointer nullChannelFind;
121  EXCEPTION_GUARD(channelListRequester->channelListResult(errorStatus, nullChannelFind, none, false));
122  return nullChannelFind;
123 }
#define EXCEPTION_GUARD(code)
Definition: caProvider.cpp:31
void epics::pvAccess::ca::CAChannelProvider::configure ( epics::pvData::PVStructure::shared_pointer  configuration)
virtual

Definition at line 164 of file caProvider.cpp.

165 {
166 }
Channel::shared_pointer epics::pvAccess::ca::CAChannelProvider::createChannel ( std::string const &  name,
ChannelRequester::shared_pointer const &  requester,
short  priority 
)
virtual

See longer form

Reimplemented from epics::pvAccess::ChannelProvider.

Definition at line 125 of file caProvider.cpp.

129 {
130  Channel::shared_pointer channel(
131  createChannel(channelName, channelRequester, priority, std::string()));
132  return channel;
133 }
virtual Channel::shared_pointer createChannel(std::string const &channelName, ChannelRequester::shared_pointer const &channelRequester, short priority)
Definition: caProvider.cpp:125
Channel::shared_pointer epics::pvAccess::ca::CAChannelProvider::createChannel ( std::string const &  name,
ChannelRequester::shared_pointer const &  requester,
short  priority,
std::string const &  address 
)
virtual

Request a Channel.

Channel creation is immediate. ChannelRequester::channelCreated() will be called before returning. The shared_ptr which is passed to channelCreated() will also be returned.

Failures during channel creation are delivered to ChannelRequester::channelCreated() with Status::isSuccess()==false.

Postcondition
The returned Channel will hold a strong reference to the provided ChannelRequester and to the ChannelProvider through which it is created.
The shared_ptr passed to ChannelRequester::channelCreated() is unique. See providers_ownership_unique
The new Channel will not hold a strong reference to this ChannelProvider. This provider must be kept alive in order to keep the Channel from being destoryed.
Parameters
nameThe name of the channel.
requesterWill receive notifications about channel state changes
prioritychannel priority, must be PRIORITY_MIN <= priority <= PRIORITY_MAX.
addressImplementation dependent condition. eg. A network address to bypass the search phase. Pass an empty() string for default behavour.
Returns
A non-NULL Channel unless channelCreated() called with an Error

Implements epics::pvAccess::ChannelProvider.

Definition at line 135 of file caProvider.cpp.

140 {
141  if (!address.empty())
142  throw std::invalid_argument("CAChannelProvider::createChannel does not support 'address' parameter");
143 
144  return CAChannel::create(shared_from_this(), channelName, priority, channelRequester);
145 }
static CAChannelPtr create(CAChannelProvider::shared_pointer const &channelProvider, std::string const &channelName, short priority, ChannelRequester::shared_pointer const &channelRequester)
Definition: caChannel.cpp:36
void epics::pvAccess::ca::CAChannelProvider::flush ( )
virtual

Definition at line 168 of file caProvider.cpp.

169 {
170 }
std::string epics::pvAccess::ca::CAChannelProvider::getProviderName ( )
virtual

Get the provider name.

Returns
The name.

Implements epics::pvAccess::ChannelProvider.

Definition at line 91 of file caProvider.cpp.

92 {
93  return "ca";
94 }
epics::pvAccess::ca::CAChannelProvider::POINTER_DEFINITIONS ( CAChannelProvider  )
void epics::pvAccess::ca::CAChannelProvider::poll ( )
virtual

Definition at line 172 of file caProvider.cpp.

173 {
174 }

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