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

#include "pvAccess.h"

Public Types

typedef std::vector< std::string > stringVector_t
 
typedef std::set< std::string > provider_name_set
 
typedef ChannelProvider::shared_pointer(* factoryfn_t) (const std::tr1::shared_ptr< Configuration > &)
 

Public Member Functions

 POINTER_DEFINITIONS (ChannelProviderRegistry)
 
virtual ~ChannelProviderRegistry ()
 
ChannelProvider::shared_pointer getProvider (std::string const &providerName)
 
ChannelProvider::shared_pointer createProvider (std::string const &providerName, const std::tr1::shared_ptr< Configuration > &conf=std::tr1::shared_ptr< Configuration >())
 
virtual ChannelProviderFactory::shared_pointer getFactory (std::string const &providerName)
 
virtual void getProviderNames (provider_name_set &names)
 
virtual bool add (const ChannelProviderFactory::shared_pointer &fact, bool replace=true)
 
template<class Provider >
ChannelProviderFactory::shared_pointer add (const std::string &name, bool replace=true)
 Add a new Provider which will be built using SimpleChannelProviderFactory<Provider> More...
 
ChannelProviderFactory::shared_pointer add (const std::string &name, factoryfn_t, bool replace=true)
 
template<class Provider >
ChannelProviderFactory::shared_pointer addSingleton (const std::string &name, const std::tr1::shared_ptr< const Configuration > &conf=std::tr1::shared_ptr< const Configuration >(), bool replace=true)
 Add a new Provider which will be built using SingletonChannelProviderFactory<Provider> More...
 
ChannelProviderFactory::shared_pointer addSingleton (const ChannelProvider::shared_pointer &provider, bool replace=true)
 
ChannelProviderFactory::shared_pointer remove (const std::string &name)
 Attempt to remove a factory with the given name. Return Factory which was removed, or NULL if not found. More...
 
virtual bool remove (const ChannelProviderFactory::shared_pointer &factory)
 Attempt to remove a factory. Return true if Factory was previously registered, and now removed. More...
 
virtual void clear ()
 Drop all factories. More...
 

Static Public Member Functions

static ChannelProviderRegistry::shared_pointer build ()
 Create a custom registry. More...
 
static ChannelProviderRegistry::shared_pointer clients ()
 
static ChannelProviderRegistry::shared_pointer servers ()
 

Friends

struct CompatRegistry
 

Detailed Description

Interface for locating channel providers.

Definition at line 1433 of file pvAccess.h.

Member Typedef Documentation

typedef ChannelProvider::shared_pointer(* epics::pvAccess::ChannelProviderRegistry::factoryfn_t) (const std::tr1::shared_ptr< Configuration > &)

Definition at line 1496 of file pvAccess.h.

Definition at line 1477 of file pvAccess.h.

Definition at line 1437 of file pvAccess.h.

Constructor & Destructor Documentation

virtual epics::pvAccess::ChannelProviderRegistry::~ChannelProviderRegistry ( )
inlinevirtual

Definition at line 1439 of file pvAccess.h.

1439 {}

Member Function Documentation

bool epics::pvAccess::ChannelProviderRegistry::add ( const ChannelProviderFactory::shared_pointer &  fact,
bool  replace = true 
)
virtual

Add new factory. if replace=false and name already in use, return false with no change in other cases insert provided factory and return true.

Definition at line 81 of file ChannelAccessFactory.cpp.

82 {
83  assert(fact);
84  Lock G(mutex);
85  std::string name(fact->getFactoryName());
86  if(!replace && providers.find(name)!=providers.end())
87  return false;
88  providers[name] = fact;
89  return true;
90 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
A lock for multithreading.
Definition: lock.h:36
template<class Provider >
ChannelProviderFactory::shared_pointer epics::pvAccess::ChannelProviderRegistry::add ( const std::string &  name,
bool  replace = true 
)
inline

Add a new Provider which will be built using SimpleChannelProviderFactory<Provider>

Definition at line 1489 of file pvAccess.h.

1490  {
1491  typedef SimpleChannelProviderFactory<Provider> Factory;
1492  typename Factory::shared_pointer fact(new Factory(name));
1493  return add(fact, replace) ? fact : typename Factory::shared_pointer();
1494  }
virtual bool add(const ChannelProviderFactory::shared_pointer &fact, bool replace=true)
ChannelProviderFactory::shared_pointer epics::pvAccess::ChannelProviderRegistry::add ( const std::string &  name,
factoryfn_t  fn,
bool  replace = true 
)

Definition at line 124 of file ChannelAccessFactory.cpp.

125 {
126  ChannelProviderFactory::shared_pointer F(new FunctionFactory(name, fn));
127  return add(F, replace) ? F : ChannelProviderFactory::shared_pointer();
128 }
virtual bool add(const ChannelProviderFactory::shared_pointer &fact, bool replace=true)
const ChannelProviderRegistry::factoryfn_t fn
template<class Provider >
ChannelProviderFactory::shared_pointer epics::pvAccess::ChannelProviderRegistry::addSingleton ( const std::string &  name,
const std::tr1::shared_ptr< const Configuration > &  conf = std::tr1::shared_ptr<const Configuration>(),
bool  replace = true 
)
inline

Add a new Provider which will be built using SingletonChannelProviderFactory<Provider>

Definition at line 1502 of file pvAccess.h.

1505  {
1506  typedef SingletonChannelProviderFactory<Provider> Factory;
1507  typename Factory::shared_pointer fact(new Factory(name, conf));
1508  return add(fact, replace) ? fact : typename Factory::shared_pointer();
1509  }
virtual bool add(const ChannelProviderFactory::shared_pointer &fact, bool replace=true)
ChannelProviderFactory::shared_pointer epics::pvAccess::ChannelProviderRegistry::addSingleton ( const ChannelProvider::shared_pointer &  provider,
bool  replace = true 
)

Add a pre-created Provider instance. Only a weak ref to this instance is kept, so the instance must be kept active through some external means

Since
6.1.0

Definition at line 159 of file ChannelAccessFactory.cpp.

161 {
162  std::tr1::shared_ptr<InstanceChannelProviderFactory> F(new InstanceChannelProviderFactory(provider));
163  return add(F, replace) ? F : std::tr1::shared_ptr<InstanceChannelProviderFactory>();
164 }
virtual bool add(const ChannelProviderFactory::shared_pointer &fact, bool replace=true)
ChannelProviderRegistry::shared_pointer epics::pvAccess::ChannelProviderRegistry::build ( )
static

Create a custom registry.

Definition at line 40 of file ChannelAccessFactory.cpp.

40  {
41  ChannelProviderRegistry::shared_pointer ret(new ChannelProviderRegistry);
42  return ret;
43 }
void epics::pvAccess::ChannelProviderRegistry::clear ( )
virtual

Drop all factories.

Definition at line 188 of file ChannelAccessFactory.cpp.

189 {
190  Lock G(mutex);
191  providers.clear();
192 }
A lock for multithreading.
Definition: lock.h:36
ChannelProviderRegistry::shared_pointer epics::pvAccess::ChannelProviderRegistry::clients ( )
static

The global registry for "clients". Register providers which will be used within this process. Typically providers which access data outside of the process. Associated with EPICS_PVA_PROVIDER_NAMES

Definition at line 235 of file ChannelAccessFactory.cpp.

236 {
237  epicsThreadOnce(&providerRegOnce, &providerRegInit, 0);
238 
239  return providerRegGbl->clients;
240 }
void providerRegInit(void *)
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
ChannelProvider::shared_pointer epics::pvAccess::ChannelProviderRegistry::createProvider ( std::string const &  providerName,
const std::tr1::shared_ptr< Configuration > &  conf = std::tr1::shared_ptr<Configuration>() 
)

Creates a new instanceof the provider with the specified name.

Parameters
providerNameThe name of the provider.
Returns
The interface for the provider or null if the provider is not known.

Definition at line 53 of file ChannelAccessFactory.cpp.

54  {
55  ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
56  if(fact)
57  return fact->newInstance(conf);
58  else
59  return ChannelProvider::shared_pointer();
60 }
virtual ChannelProviderFactory::shared_pointer getFactory(std::string const &providerName)
ChannelProviderFactory::shared_pointer epics::pvAccess::ChannelProviderRegistry::getFactory ( std::string const &  providerName)
virtual

Fetch provider factor with the specified name.

Parameters
providerNameThe name of the provider.
Returns
The factor or null if the provider is not known.

Definition at line 62 of file ChannelAccessFactory.cpp.

63 {
64  Lock G(mutex);
65  providers_t::const_iterator iter = providers.find(providerName);
66  if (iter == providers.end())
67  return ChannelProviderFactory::shared_pointer();
68  else
69  return iter->second;
70 }
A lock for multithreading.
Definition: lock.h:36
ChannelProvider::shared_pointer epics::pvAccess::ChannelProviderRegistry::getProvider ( std::string const &  providerName)

Get a shared instance of the provider with the specified name.

Parameters
providerNameThe name of the provider.
Returns
The interface for the provider or null if the provider is not known.

Definition at line 45 of file ChannelAccessFactory.cpp.

45  {
46  ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
47  if(fact)
48  return fact->sharedInstance();
49  else
50  return ChannelProvider::shared_pointer();
51 }
virtual ChannelProviderFactory::shared_pointer getFactory(std::string const &providerName)
void epics::pvAccess::ChannelProviderRegistry::getProviderNames ( provider_name_set names)
virtual

Find currently registered provider names.

Definition at line 72 of file ChannelAccessFactory.cpp.

73 {
74  Lock G(mutex);
75  for (providers_t::const_iterator iter = providers.begin();
76  iter != providers.end(); iter++)
77  names.insert(iter->first);
78 }
A lock for multithreading.
Definition: lock.h:36
epics::pvAccess::ChannelProviderRegistry::POINTER_DEFINITIONS ( ChannelProviderRegistry  )
ChannelProviderFactory::shared_pointer epics::pvAccess::ChannelProviderRegistry::remove ( const std::string &  name)

Attempt to remove a factory with the given name. Return Factory which was removed, or NULL if not found.

Definition at line 166 of file ChannelAccessFactory.cpp.

167 {
168  Lock G(mutex);
169  ChannelProviderFactory::shared_pointer fact(getFactory(name));
170  if(fact) {
171  remove(fact);
172  }
173  return fact;
174 }
virtual ChannelProviderFactory::shared_pointer getFactory(std::string const &providerName)
A lock for multithreading.
Definition: lock.h:36
bool epics::pvAccess::ChannelProviderRegistry::remove ( const ChannelProviderFactory::shared_pointer &  factory)
virtual

Attempt to remove a factory. Return true if Factory was previously registered, and now removed.

Definition at line 176 of file ChannelAccessFactory.cpp.

177 {
178  assert(fact);
179  Lock G(mutex);
180  providers_t::iterator iter(providers.find(fact->getFactoryName()));
181  if(iter!=providers.end() && iter->second==fact) {
182  providers.erase(iter);
183  return true;
184  }
185  return false;
186 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
A lock for multithreading.
Definition: lock.h:36
ChannelProviderRegistry::shared_pointer epics::pvAccess::ChannelProviderRegistry::servers ( )
static

The global registry for "servers". Register providers which will be used outside of this process (via ServerContext). Typically providers which access data within the process. Associated with EPICS_PVAS_PROVIDER_NAMES

Definition at line 242 of file ChannelAccessFactory.cpp.

243 {
244  epicsThreadOnce(&providerRegOnce, &providerRegInit, 0);
245 
246  return providerRegGbl->servers;
247 }
void providerRegInit(void *)
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)

Friends And Related Function Documentation

friend struct CompatRegistry
friend

Definition at line 1531 of file pvAccess.h.


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