This is Unofficial EPICS BASE Doxygen Site
pvas::StaticProvider Class Reference

A Provider based on a list of SharedPV instance. More...

#include "server.h"

Classes

struct  ChannelBuilder
 Interface for something which can provide Channels. aka A "PV". Typically a SharedPV. More...
 
struct  Impl
 

Public Types

typedef builders_t::const_iterator const_iterator
 

Public Member Functions

 POINTER_DEFINITIONS (StaticProvider)
 
 StaticProvider (const std::string &name)
 
 ~StaticProvider ()
 
void close (bool destroy=false)
 
void add (const std::string &name, const std::tr1::shared_ptr< ChannelBuilder > &builder)
 Add a PV (eg. SharedPV) to this provider. More...
 
std::tr1::shared_ptr< ChannelBuilderremove (const std::string &name)
 
std::tr1::shared_ptr< epics::pvAccess::ChannelProviderprovider () const
 Fetch the underlying ChannelProvider. Usually to build a ServerContext around. More...
 
const_iterator begin () const
 
const_iterator end () const
 

Detailed Description

A Provider based on a list of SharedPV instance.

SharedPV instances may be added/removed at any time. So it is only "static" in the sense that the list of PV names is known to StaticProvider at all times.

See also
Server API shared_ptr Ownership

Definition at line 105 of file server.h.

Member Typedef Documentation

typedef builders_t::const_iterator pvas::StaticProvider::const_iterator

Definition at line 128 of file server.h.

Constructor & Destructor Documentation

pvas::StaticProvider::StaticProvider ( const std::string &  name)
explicit

Build a new, empty, provider.

Parameters
nameProvider Name. Only relevant if registerAsServer() is called, then must be unique in this process.

Definition at line 117 of file server.cpp.

118  :impl(new Impl(name))
119 {
120  impl->internal_self = impl;
121  impl->finder = pva::ChannelFind::buildDummy(impl);
122  // wrap ref to call destroy when all external refs (from DyamicProvider::impl) are released.
123  impl.reset(impl.get(), pva::Destroyable::cleaner(impl));
124  impl->external_self = impl;
125 }
static ChannelFind::shared_pointer buildDummy(const std::tr1::shared_ptr< ChannelProvider > &provider)
Definition: pvAccess.cpp:473
pvas::StaticProvider::~StaticProvider ( )

Definition at line 127 of file server.cpp.

127 { close(true); }
void close(bool destroy=false)
Definition: server.cpp:129

Member Function Documentation

void pvas::StaticProvider::add ( const std::string &  name,
const std::tr1::shared_ptr< ChannelBuilder > &  builder 
)

Add a PV (eg. SharedPV) to this provider.

Definition at line 150 of file server.cpp.

152 {
153  Guard G(impl->mutex);
154  if(impl->builders.find(name)!=impl->builders.end())
155  throw std::logic_error("Duplicate PV name");
156  impl->builders[name] = builder;
157 }
StaticProvider::builders_t::const_iterator pvas::StaticProvider::begin ( ) const

Definition at line 175 of file server.cpp.

175  {
176  Guard G(impl->mutex);
177  return impl->builders.begin();
178 }
void pvas::StaticProvider::close ( bool  destroy = false)

Call Channelbuilder::close(destroy) for all currently added ChannelBuilders.

See also
SharedPV::close()
Note
Provider locking rules apply (
See also
provider_roles_requester_locking).

Definition at line 129 of file server.cpp.

130 {
131  Impl::builders_t pvs;
132  {
133  Guard G(impl->mutex);
134  if(destroy) {
135  pvs.swap(impl->builders); // consume
136  } else {
137  pvs = impl->builders; // just copy, close() is a relatively rare action
138  }
139  }
140  for(Impl::builders_t::iterator it(pvs.begin()), end(pvs.end()); it!=end; ++it) {
141  it->second->disconnect(destroy, impl.get());
142  }
143 }
StaticProvider::builders_t builders_t
Definition: server.cpp:43
const_iterator end() const
Definition: server.cpp:180
StaticProvider::builders_t::const_iterator pvas::StaticProvider::end ( ) const

Definition at line 180 of file server.cpp.

180  {
181  Guard G(impl->mutex);
182  return impl->builders.end();
183 }
pvas::StaticProvider::POINTER_DEFINITIONS ( StaticProvider  )
std::tr1::shared_ptr< epics::pvAccess::ChannelProvider > pvas::StaticProvider::provider ( ) const

Fetch the underlying ChannelProvider. Usually to build a ServerContext around.

Definition at line 145 of file server.cpp.

146 {
147  return Impl::shared_pointer(impl->internal_self);
148 }
std::tr1::shared_ptr< StaticProvider::ChannelBuilder > pvas::StaticProvider::remove ( const std::string &  name)

Remove a PV. Closes any open Channels to it.

Returns
the PV which has been removed.
Note
Provider locking rules apply (
See also
provider_roles_requester_locking).

Definition at line 159 of file server.cpp.

160 {
161  std::tr1::shared_ptr<StaticProvider::ChannelBuilder> ret;
162  {
163  Guard G(impl->mutex);
164  Impl::builders_t::iterator it(impl->builders.find(name));
165  if(it!=impl->builders.end()) {
166  ret = it->second;
167  impl->builders.erase(it);
168  }
169  }
170  if(ret)
171  ret->disconnect(true, impl.get());
172  return ret;
173 }

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