separate ChannelProviderRegistry for client/server
This commit is contained in:
@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
|
|||||||
pva::ca::CAClientFactory::start();
|
pva::ca::CAClientFactory::start();
|
||||||
|
|
||||||
std::cout<<"Use provider: "<<providerName<<"\n";
|
std::cout<<"Use provider: "<<providerName<<"\n";
|
||||||
pva::ChannelProvider::shared_pointer provider(pva::getChannelProviderRegistry()->createProvider(providerName, conf));
|
pva::ChannelProvider::shared_pointer provider(pva::ChannelProviderRegistry::clients()->createProvider(providerName, conf));
|
||||||
if(!provider)
|
if(!provider)
|
||||||
throw std::logic_error("pva provider not registered");
|
throw std::logic_error("pva provider not registered");
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
|
|||||||
pva::ca::CAClientFactory::start();
|
pva::ca::CAClientFactory::start();
|
||||||
|
|
||||||
std::cout<<"Use provider: "<<providerName<<"\n";
|
std::cout<<"Use provider: "<<providerName<<"\n";
|
||||||
pva::ChannelProvider::shared_pointer provider(pva::getChannelProviderRegistry()->createProvider(providerName, conf));
|
pva::ChannelProvider::shared_pointer provider(pva::ChannelProviderRegistry::clients()->createProvider(providerName, conf));
|
||||||
if(!provider)
|
if(!provider)
|
||||||
throw std::logic_error("pva provider not registered");
|
throw std::logic_error("pva provider not registered");
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ static
|
|||||||
void ca_factory_cleanup(void*)
|
void ca_factory_cleanup(void*)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
getChannelProviderRegistry()->remove("ca");
|
ChannelProviderRegistry::clients()->remove("ca");
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
LOG(logLevelWarn, "Error when unregister \"ca\" factory");
|
LOG(logLevelWarn, "Error when unregister \"ca\" factory");
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ void CAClientFactory::start()
|
|||||||
epicsSignalInstallSigAlarmIgnore();
|
epicsSignalInstallSigAlarmIgnore();
|
||||||
epicsSignalInstallSigPipeIgnore();
|
epicsSignalInstallSigPipeIgnore();
|
||||||
|
|
||||||
if(getChannelProviderRegistry()->add<CAChannelProvider>("ca", false))
|
if(ChannelProviderRegistry::clients()->add<CAChannelProvider>("ca", false))
|
||||||
epicsAtExit(&ca_factory_cleanup, NULL);
|
epicsAtExit(&ca_factory_cleanup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#define PVACCESS_H
|
#define PVACCESS_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#ifdef epicsExportSharedSymbols
|
#ifdef epicsExportSharedSymbols
|
||||||
# define pvAccessEpicsExportSharedSymbols
|
# define pvAccessEpicsExportSharedSymbols
|
||||||
@ -1242,6 +1243,20 @@ public:
|
|||||||
|
|
||||||
typedef std::vector<std::string> stringVector_t;
|
typedef std::vector<std::string> stringVector_t;
|
||||||
|
|
||||||
|
|
||||||
|
//! Create a custom registry
|
||||||
|
static ChannelProviderRegistry::shared_pointer build();
|
||||||
|
//! 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
|
||||||
|
static ChannelProviderRegistry::shared_pointer clients();
|
||||||
|
//! 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
|
||||||
|
static ChannelProviderRegistry::shared_pointer servers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a shared instance of the provider with the specified name.
|
* Get a shared instance of the provider with the specified name.
|
||||||
* @param providerName The name of the provider.
|
* @param providerName The name of the provider.
|
||||||
@ -1249,43 +1264,32 @@ public:
|
|||||||
*/
|
*/
|
||||||
ChannelProvider::shared_pointer getProvider(std::string const & providerName);
|
ChannelProvider::shared_pointer getProvider(std::string const & providerName);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instanceof the provider with the specified name.
|
|
||||||
* @param providerName The name of the provider.
|
|
||||||
* @return The interface for the provider or null if the provider is not known.
|
|
||||||
*/
|
|
||||||
ChannelProvider::shared_pointer createProvider(std::string const & providerName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instanceof the provider with the specified name.
|
* Creates a new instanceof the provider with the specified name.
|
||||||
* @param providerName The name of the provider.
|
* @param providerName The name of the provider.
|
||||||
* @return The interface for the provider or null if the provider is not known.
|
* @return The interface for the provider or null if the provider is not known.
|
||||||
*/
|
*/
|
||||||
ChannelProvider::shared_pointer createProvider(std::string const & providerName,
|
ChannelProvider::shared_pointer createProvider(std::string const & providerName,
|
||||||
const std::tr1::shared_ptr<Configuration>& conf);
|
const std::tr1::shared_ptr<Configuration>& conf = std::tr1::shared_ptr<Configuration>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch provider factor with the specified name.
|
* Fetch provider factor with the specified name.
|
||||||
* @param providerName The name of the provider.
|
* @param providerName The name of the provider.
|
||||||
* @return The factor or null if the provider is not known.
|
* @return The factor or null if the provider is not known.
|
||||||
*/
|
*/
|
||||||
ChannelProviderFactory::shared_pointer getFactory(std::string const & providerName);
|
virtual ChannelProviderFactory::shared_pointer getFactory(std::string const & providerName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a array of the names of all the known providers.
|
* Get a array of the names of all the known providers.
|
||||||
* @return The names. Be sure to delete vector instance.
|
* @return The names. Be sure to delete vector instance.
|
||||||
*/
|
*/
|
||||||
std::auto_ptr<stringVector_t> getProviderNames();
|
std::auto_ptr<stringVector_t> getProviderNames() EPICS_DEPRECATED;
|
||||||
|
|
||||||
|
virtual void getProviderNames(std::set<std::string>& names);
|
||||||
static ChannelProviderRegistry::shared_pointer build() {
|
|
||||||
ChannelProviderRegistry::shared_pointer ret(new ChannelProviderRegistry);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Add new factory. if replace=false and name already in use, return false with no change
|
//! 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.
|
//! in other cases insert provided factory and return true.
|
||||||
bool add(const ChannelProviderFactory::shared_pointer& fact, bool replace=true);
|
virtual bool add(const ChannelProviderFactory::shared_pointer& fact, bool replace=true);
|
||||||
|
|
||||||
//! Add a new Provider which will be built using SimpleChannelProviderFactory<Provider>
|
//! Add a new Provider which will be built using SimpleChannelProviderFactory<Provider>
|
||||||
template<class Provider>
|
template<class Provider>
|
||||||
@ -1304,16 +1308,16 @@ public:
|
|||||||
ChannelProviderFactory::shared_pointer remove(const std::string& name);
|
ChannelProviderFactory::shared_pointer remove(const std::string& name);
|
||||||
|
|
||||||
//! Attempt to remove a factory. Return true if Factory was previously registered, and now removed.
|
//! Attempt to remove a factory. Return true if Factory was previously registered, and now removed.
|
||||||
bool remove(const ChannelProviderFactory::shared_pointer& factory);
|
virtual bool remove(const ChannelProviderFactory::shared_pointer& factory);
|
||||||
|
|
||||||
//! Drop all factories
|
//! Drop all factories
|
||||||
void clear()
|
virtual void clear();
|
||||||
{
|
|
||||||
providers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// ctor is hidden to ensure explict compile errors from a hypothetical sub-class
|
||||||
|
// we no longer support sub-classing by outside code
|
||||||
ChannelProviderRegistry() {}
|
ChannelProviderRegistry() {}
|
||||||
|
friend struct CompatRegistry;
|
||||||
|
|
||||||
epics::pvData::Mutex mutex;
|
epics::pvData::Mutex mutex;
|
||||||
typedef std::map<std::string, ChannelProviderFactory::shared_pointer> providers_t;
|
typedef std::map<std::string, ChannelProviderFactory::shared_pointer> providers_t;
|
||||||
@ -1323,14 +1327,16 @@ private:
|
|||||||
/** Access to the global ChannelProviderRegistry instance.
|
/** Access to the global ChannelProviderRegistry instance.
|
||||||
*
|
*
|
||||||
* Never returns NULL
|
* Never returns NULL
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated in favor of either ChannelProviderRegistry::clients() or ChannelProviderRegistry::servers()
|
||||||
*/
|
*/
|
||||||
epicsShareFunc ChannelProviderRegistry::shared_pointer getChannelProviderRegistry();
|
epicsShareFunc ChannelProviderRegistry::shared_pointer getChannelProviderRegistry() EPICS_DEPRECATED;
|
||||||
//! Shorthand for getChannelProviderRegistry()->add(channelProviderFactory);
|
//! Shorthand for getChannelProviderRegistry()->add(channelProviderFactory);
|
||||||
epicsShareFunc void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory);
|
epicsShareFunc void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) EPICS_DEPRECATED;
|
||||||
//! Shorthand for getChannelProviderRegistry()->remove(channelProviderFactory);
|
//! Shorthand for getChannelProviderRegistry()->remove(channelProviderFactory);
|
||||||
epicsShareFunc void unregisterChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory);
|
epicsShareFunc void unregisterChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) EPICS_DEPRECATED;
|
||||||
//! Shorthand for getChannelProviderRegistry()->clear();
|
//! Shorthand for getChannelProviderRegistry()->clear();
|
||||||
epicsShareFunc void unregisterAllChannelProviderFactory();
|
epicsShareFunc void unregisterAllChannelProviderFactory() EPICS_DEPRECATED;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,11 @@ using std::string;
|
|||||||
namespace epics {
|
namespace epics {
|
||||||
namespace pvAccess {
|
namespace pvAccess {
|
||||||
|
|
||||||
|
ChannelProviderRegistry::shared_pointer ChannelProviderRegistry::build() {
|
||||||
|
ChannelProviderRegistry::shared_pointer ret(new ChannelProviderRegistry);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ChannelProvider::shared_pointer ChannelProviderRegistry::getProvider(std::string const & providerName) {
|
ChannelProvider::shared_pointer ChannelProviderRegistry::getProvider(std::string const & providerName) {
|
||||||
ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
|
ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
|
||||||
if(fact)
|
if(fact)
|
||||||
@ -31,14 +36,6 @@ ChannelProvider::shared_pointer ChannelProviderRegistry::getProvider(std::string
|
|||||||
return ChannelProvider::shared_pointer();
|
return ChannelProvider::shared_pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelProvider::shared_pointer ChannelProviderRegistry::createProvider(std::string const & providerName) {
|
|
||||||
ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
|
|
||||||
if(fact)
|
|
||||||
return fact->newInstance();
|
|
||||||
else
|
|
||||||
return ChannelProvider::shared_pointer();
|
|
||||||
}
|
|
||||||
|
|
||||||
ChannelProvider::shared_pointer ChannelProviderRegistry::createProvider(std::string const & providerName,
|
ChannelProvider::shared_pointer ChannelProviderRegistry::createProvider(std::string const & providerName,
|
||||||
const std::tr1::shared_ptr<Configuration>& conf) {
|
const std::tr1::shared_ptr<Configuration>& conf) {
|
||||||
ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
|
ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
|
||||||
@ -60,15 +57,28 @@ ChannelProviderFactory::shared_pointer ChannelProviderRegistry::getFactory(std::
|
|||||||
|
|
||||||
std::auto_ptr<ChannelProviderRegistry::stringVector_t> ChannelProviderRegistry::getProviderNames()
|
std::auto_ptr<ChannelProviderRegistry::stringVector_t> ChannelProviderRegistry::getProviderNames()
|
||||||
{
|
{
|
||||||
Lock G(mutex);
|
std::set<std::string> names;
|
||||||
std::auto_ptr<stringVector_t> ret(new stringVector_t);
|
getProviderNames(names);
|
||||||
for (providers_t::const_iterator iter = providers.begin();
|
|
||||||
iter != providers.end(); iter++)
|
|
||||||
ret->push_back(iter->first);
|
|
||||||
|
|
||||||
|
std::auto_ptr<ChannelProviderRegistry::stringVector_t> ret(new ChannelProviderRegistry::stringVector_t);
|
||||||
|
ret->reserve(names.size());
|
||||||
|
|
||||||
|
for(std::set<std::string>::const_iterator it=names.begin(); it!=names.end(); ++it)
|
||||||
|
{
|
||||||
|
ret->push_back(*it);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelProviderRegistry::getProviderNames(std::set<std::string>& names)
|
||||||
|
{
|
||||||
|
Lock G(mutex);
|
||||||
|
for (providers_t::const_iterator iter = providers.begin();
|
||||||
|
iter != providers.end(); iter++)
|
||||||
|
names.insert(iter->first);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ChannelProviderRegistry::add(const ChannelProviderFactory::shared_pointer& fact, bool replace)
|
bool ChannelProviderRegistry::add(const ChannelProviderFactory::shared_pointer& fact, bool replace)
|
||||||
{
|
{
|
||||||
assert(fact);
|
assert(fact);
|
||||||
@ -121,13 +131,11 @@ ChannelProviderFactory::shared_pointer ChannelProviderRegistry::add(const std::s
|
|||||||
ChannelProviderFactory::shared_pointer ChannelProviderRegistry::remove(const std::string& name)
|
ChannelProviderFactory::shared_pointer ChannelProviderRegistry::remove(const std::string& name)
|
||||||
{
|
{
|
||||||
Lock G(mutex);
|
Lock G(mutex);
|
||||||
ChannelProviderFactory::shared_pointer ret;
|
ChannelProviderFactory::shared_pointer fact(getFactory(name));
|
||||||
providers_t::iterator iter(providers.find(name));
|
if(fact) {
|
||||||
if(iter!=providers.end()) {
|
remove(fact);
|
||||||
ret = iter->second;
|
|
||||||
providers.erase(iter);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return fact;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChannelProviderRegistry::remove(const ChannelProviderFactory::shared_pointer& fact)
|
bool ChannelProviderRegistry::remove(const ChannelProviderFactory::shared_pointer& fact)
|
||||||
@ -142,10 +150,57 @@ bool ChannelProviderRegistry::remove(const ChannelProviderFactory::shared_pointe
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelProviderRegistry::clear()
|
||||||
|
{
|
||||||
|
Lock G(mutex);
|
||||||
|
providers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CompatRegistry : public ChannelProviderRegistry
|
||||||
|
{
|
||||||
|
CompatRegistry() {}
|
||||||
|
virtual ~CompatRegistry() {}
|
||||||
|
virtual ChannelProviderFactory::shared_pointer getFactory(std::string const & providerName) OVERRIDE FINAL
|
||||||
|
{
|
||||||
|
ChannelProviderFactory::shared_pointer ret(clients()->getFactory(providerName));
|
||||||
|
if(!ret)
|
||||||
|
ret = servers()->getFactory(providerName);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
virtual void getProviderNames(std::set<std::string>& names) OVERRIDE FINAL
|
||||||
|
{
|
||||||
|
clients()->getProviderNames(names);
|
||||||
|
servers()->getProviderNames(names);
|
||||||
|
}
|
||||||
|
virtual bool add(const ChannelProviderFactory::shared_pointer& fact, bool replace=true) OVERRIDE FINAL
|
||||||
|
{
|
||||||
|
std::cerr<<"Warning: Adding provider \""<<fact->getFactoryName()<<"\" to compatibility ChannelProviderFactory is deprecated\n"
|
||||||
|
<<" Instead explicitly add to ChannelProviderFactory::clients() or ChannelProviderFactory::servers()\n";
|
||||||
|
// intentionally not using short-circuit or
|
||||||
|
return clients()->add(fact, replace) | servers()->add(fact, replace);
|
||||||
|
}
|
||||||
|
virtual bool remove(const ChannelProviderFactory::shared_pointer& factory) OVERRIDE FINAL
|
||||||
|
{
|
||||||
|
// intentionally not using short-circuit or
|
||||||
|
return clients()->remove(factory) | servers()->remove(factory);
|
||||||
|
}
|
||||||
|
virtual void clear() OVERRIDE FINAL
|
||||||
|
{
|
||||||
|
clients()->clear();
|
||||||
|
servers()->clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct providerRegGbl_t {
|
struct providerRegGbl_t {
|
||||||
Mutex mutex;
|
ChannelProviderRegistry::shared_pointer clients,
|
||||||
ChannelProviderRegistry::shared_pointer reg;
|
servers,
|
||||||
|
compat;
|
||||||
|
providerRegGbl_t()
|
||||||
|
:clients(ChannelProviderRegistry::build())
|
||||||
|
,servers(ChannelProviderRegistry::build())
|
||||||
|
,compat(new CompatRegistry)
|
||||||
|
{}
|
||||||
} *providerRegGbl;
|
} *providerRegGbl;
|
||||||
|
|
||||||
epicsThreadOnceId providerRegOnce = EPICS_THREAD_ONCE_INIT;
|
epicsThreadOnceId providerRegOnce = EPICS_THREAD_ONCE_INIT;
|
||||||
@ -157,16 +212,25 @@ void providerRegInit(void*)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
ChannelProviderRegistry::shared_pointer ChannelProviderRegistry::clients()
|
||||||
|
{
|
||||||
|
epicsThreadOnce(&providerRegOnce, &providerRegInit, 0);
|
||||||
|
|
||||||
|
return providerRegGbl->clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChannelProviderRegistry::shared_pointer ChannelProviderRegistry::servers()
|
||||||
|
{
|
||||||
|
epicsThreadOnce(&providerRegOnce, &providerRegInit, 0);
|
||||||
|
|
||||||
|
return providerRegGbl->servers;
|
||||||
|
}
|
||||||
|
|
||||||
ChannelProviderRegistry::shared_pointer getChannelProviderRegistry()
|
ChannelProviderRegistry::shared_pointer getChannelProviderRegistry()
|
||||||
{
|
{
|
||||||
epicsThreadOnce(&providerRegOnce, &providerRegInit, 0);
|
epicsThreadOnce(&providerRegOnce, &providerRegInit, 0);
|
||||||
|
|
||||||
Lock guard(providerRegGbl->mutex);
|
return providerRegGbl->compat;
|
||||||
|
|
||||||
if(!providerRegGbl->reg) {
|
|
||||||
providerRegGbl->reg = ChannelProviderRegistry::build();
|
|
||||||
}
|
|
||||||
return providerRegGbl->reg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) {
|
void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) {
|
||||||
|
@ -45,9 +45,9 @@ static void startitup() {
|
|||||||
the_server = pva::ServerContext::create(pva::ServerContext::Config()
|
the_server = pva::ServerContext::create(pva::ServerContext::Config()
|
||||||
.config(pva::ConfigurationBuilder()
|
.config(pva::ConfigurationBuilder()
|
||||||
// default to all providers instead of just "local"
|
// default to all providers instead of just "local"
|
||||||
.add("EPICS_PVA_PROVIDER_NAMES", pva::PVACCESS_ALL_PROVIDERS)
|
.add("EPICS_PVAS_PROVIDER_NAMES", pva::PVACCESS_ALL_PROVIDERS)
|
||||||
.push_map()
|
.push_map()
|
||||||
// prefer to use EPICS_PVA_PROVIDER_NAMES or EPICS_PVAS_PROVIDER_NAMES
|
// prefer to use EPICS_PVAS_PROVIDER_NAMES
|
||||||
// from environment
|
// from environment
|
||||||
.push_env()
|
.push_env()
|
||||||
.build()));
|
.build()));
|
||||||
|
@ -22,7 +22,7 @@ static
|
|||||||
void pva_factory_cleanup(void*)
|
void pva_factory_cleanup(void*)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
getChannelProviderRegistry()->remove("pva");
|
ChannelProviderRegistry::clients()->remove("pva");
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
LOG(logLevelWarn, "Error when unregister \"pva\" factory");
|
LOG(logLevelWarn, "Error when unregister \"pva\" factory");
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ void ClientFactory::start()
|
|||||||
epicsSignalInstallSigAlarmIgnore();
|
epicsSignalInstallSigAlarmIgnore();
|
||||||
epicsSignalInstallSigPipeIgnore();
|
epicsSignalInstallSigPipeIgnore();
|
||||||
|
|
||||||
if(getChannelProviderRegistry()->add("pva", createClientProvider, false))
|
if(ChannelProviderRegistry::clients()->add("pva", createClientProvider, false))
|
||||||
epicsAtExit(&pva_factory_cleanup, NULL);
|
epicsAtExit(&pva_factory_cleanup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@
|
|||||||
|
|
||||||
#include "pv/pvaVersionNum.h"
|
#include "pv/pvaVersionNum.h"
|
||||||
|
|
||||||
|
#ifndef VERSION_INT
|
||||||
|
# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PVACCESS_VERSION_INT VERSION_INT(EPICS_PVA_MAJOR_VERSION, EPICS_PVA_MINOR_VERSION, EPICS_PVA_MAINTENANCE_VERSION, 0)
|
||||||
|
|
||||||
namespace epics {
|
namespace epics {
|
||||||
namespace pvAccess {
|
namespace pvAccess {
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ RPCClient::RPCClient(const std::string & serviceName,
|
|||||||
: m_serviceName(serviceName), m_pvRequest(pvRequest ? pvRequest : pvd::createRequest(""))
|
: m_serviceName(serviceName), m_pvRequest(pvRequest ? pvRequest : pvd::createRequest(""))
|
||||||
{
|
{
|
||||||
ClientFactory::start();
|
ClientFactory::start();
|
||||||
ChannelProvider::shared_pointer provider(getChannelProviderRegistry()->getProvider("pva"));
|
ChannelProvider::shared_pointer provider(ChannelProviderRegistry::clients()->getProvider("pva"));
|
||||||
if(!provider)
|
if(!provider)
|
||||||
throw std::logic_error("Unknown Provider");
|
throw std::logic_error("Unknown Provider");
|
||||||
construct(provider, serviceName, pvRequest);
|
construct(provider, serviceName, pvRequest);
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
/** Start a new PVA server
|
/** Start a new PVA server
|
||||||
*
|
*
|
||||||
* By default the server will select ChannelProviders using the
|
* By default the server will select ChannelProviders using the
|
||||||
* EPICS_PVA_PROVIDER_NAMES or EPICS_PVAS_PROVIDER_NAMES Configuration key.
|
* EPICS_PVAS_PROVIDER_NAMES Configuration key.
|
||||||
*
|
*
|
||||||
* If a list of provided is given with Config::providers() then this
|
* If a list of provided is given with Config::providers() then this
|
||||||
* overrides any Configuration.
|
* overrides any Configuration.
|
||||||
|
@ -144,17 +144,17 @@ void ServerContextImpl::loadConfiguration()
|
|||||||
_receiveBufferSize = config->getPropertyAsInteger("EPICS_PVAS_MAX_ARRAY_BYTES", _receiveBufferSize);
|
_receiveBufferSize = config->getPropertyAsInteger("EPICS_PVAS_MAX_ARRAY_BYTES", _receiveBufferSize);
|
||||||
|
|
||||||
if(_channelProviders.empty()) {
|
if(_channelProviders.empty()) {
|
||||||
std::string providers = config->getPropertyAsString("EPICS_PVA_PROVIDER_NAMES", PVACCESS_DEFAULT_PROVIDER);
|
std::string providers = config->getPropertyAsString("EPICS_PVAS_PROVIDER_NAMES", PVACCESS_DEFAULT_PROVIDER);
|
||||||
providers = config->getPropertyAsString("EPICS_PVAS_PROVIDER_NAMES", providers);
|
|
||||||
|
|
||||||
ChannelProviderRegistry::shared_pointer reg(getChannelProviderRegistry());
|
ChannelProviderRegistry::shared_pointer reg(ChannelProviderRegistry::servers());
|
||||||
|
|
||||||
if (providers == PVACCESS_ALL_PROVIDERS)
|
if (providers == PVACCESS_ALL_PROVIDERS)
|
||||||
{
|
{
|
||||||
providers.resize(0); // VxWorks 5.5 omits clear()
|
providers.resize(0); // VxWorks 5.5 omits clear()
|
||||||
|
|
||||||
std::auto_ptr<ChannelProviderRegistry::stringVector_t> names = reg->getProviderNames();
|
std::set<std::string> names;
|
||||||
for (ChannelProviderRegistry::stringVector_t::iterator iter = names->begin(); iter != names->end(); iter++)
|
reg->getProviderNames(names);
|
||||||
|
for (std::set<std::string>::const_iterator iter = names.begin(); iter != names.end(); iter++)
|
||||||
{
|
{
|
||||||
ChannelProvider::shared_pointer channelProvider = reg->getProvider(*iter);
|
ChannelProvider::shared_pointer channelProvider = reg->getProvider(*iter);
|
||||||
if (channelProvider) {
|
if (channelProvider) {
|
||||||
@ -247,7 +247,6 @@ ServerContextImpl::getCurrentConfig()
|
|||||||
SET("EPICS_PVA_MAX_ARRAY_BYTES", getReceiveBufferSize());
|
SET("EPICS_PVA_MAX_ARRAY_BYTES", getReceiveBufferSize());
|
||||||
|
|
||||||
SET("EPICS_PVAS_PROVIDER_NAMES", providerName.str());
|
SET("EPICS_PVAS_PROVIDER_NAMES", providerName.str());
|
||||||
SET("EPICS_PVA_PROVIDER_NAMES", providerName.str());
|
|
||||||
|
|
||||||
#undef SET
|
#undef SET
|
||||||
|
|
||||||
@ -257,7 +256,7 @@ ServerContextImpl::getCurrentConfig()
|
|||||||
bool ServerContextImpl::isChannelProviderNamePreconfigured()
|
bool ServerContextImpl::isChannelProviderNamePreconfigured()
|
||||||
{
|
{
|
||||||
Configuration::const_shared_pointer config = getConfiguration();
|
Configuration::const_shared_pointer config = getConfiguration();
|
||||||
return config->hasProperty("EPICS_PVA_PROVIDER_NAMES") || config->hasProperty("EPICS_PVAS_PROVIDER_NAMES");
|
return config->hasProperty("EPICS_PVAS_PROVIDER_NAMES");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerContextImpl::initialize()
|
void ServerContextImpl::initialize()
|
||||||
@ -524,8 +523,6 @@ std::map<std::string, std::tr1::shared_ptr<SecurityPlugin> >& ServerContextImpl:
|
|||||||
return SecurityPluginRegistry::instance().getServerSecurityPlugins();
|
return SecurityPluginRegistry::instance().getServerSecurityPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ServerContext::shared_pointer startPVAServer(std::string const & providerNames, int timeToRun, bool runInSeparateThread, bool printInfo)
|
ServerContext::shared_pointer startPVAServer(std::string const & providerNames, int timeToRun, bool runInSeparateThread, bool printInfo)
|
||||||
{
|
{
|
||||||
ServerContext::shared_pointer ret(ServerContext::create(ServerContext::Config()
|
ServerContext::shared_pointer ret(ServerContext::create(ServerContext::Config()
|
||||||
|
@ -197,7 +197,7 @@ void ConfigurationProviderImpl::registerConfiguration(const string &name, Config
|
|||||||
if(configsIter != _configs.end())
|
if(configsIter != _configs.end())
|
||||||
{
|
{
|
||||||
string msg = "configuration with name " + name + " already registered";
|
string msg = "configuration with name " + name + " already registered";
|
||||||
THROW_BASE_EXCEPTION(msg.c_str());
|
THROW_BASE_EXCEPTION(msg);
|
||||||
}
|
}
|
||||||
_configs[name] = configuration;
|
_configs[name] = configuration;
|
||||||
}
|
}
|
||||||
|
@ -50,17 +50,6 @@ std::string ChannelAccessIFTest::TEST_ARRAY_CHANNEL_NAME = "testArray1";
|
|||||||
#define EXTRA_STRESS_TESTS 0
|
#define EXTRA_STRESS_TESTS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
|
||||||
struct ScopedClientFactory {
|
|
||||||
ScopedClientFactory() {
|
|
||||||
ClientFactory::start();
|
|
||||||
}
|
|
||||||
~ScopedClientFactory() {
|
|
||||||
ClientFactory::stop();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
int ChannelAccessIFTest::runAllTest() {
|
int ChannelAccessIFTest::runAllTest() {
|
||||||
|
|
||||||
testPlan(152+EXTRA_STRESS_TESTS);
|
testPlan(152+EXTRA_STRESS_TESTS);
|
||||||
@ -87,7 +76,9 @@ int ChannelAccessIFTest::runAllTest() {
|
|||||||
.add("EPICS_PVA_BROADCAST_PORT", tstserv->getBroadcastPort())
|
.add("EPICS_PVA_BROADCAST_PORT", tstserv->getBroadcastPort())
|
||||||
.push_map()
|
.push_map()
|
||||||
.build());
|
.build());
|
||||||
ScopedClientFactory SCF;
|
epics::pvAccess::ClientFactory::start();
|
||||||
|
|
||||||
|
m_provider = ChannelProviderRegistry::clients()->getProvider("pva");
|
||||||
|
|
||||||
test_implementation();
|
test_implementation();
|
||||||
test_providerName();
|
test_providerName();
|
||||||
@ -2403,31 +2394,15 @@ PVStructure::shared_pointer ChannelAccessIFTest::createArrayPvRequest() {
|
|||||||
return pvRequest;
|
return pvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ChannelAccessIFRemoteTest: public ChannelAccessIFTest {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ChannelProvider::shared_pointer getChannelProvider() {
|
|
||||||
return getChannelProviderRegistry()->getProvider(
|
|
||||||
"pva");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual long getTimeoutSec() {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool isLocal() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
MAIN(testChannelAccess)
|
MAIN(testChannelAccess)
|
||||||
{
|
{
|
||||||
SET_LOG_LEVEL(logLevelError);
|
try{
|
||||||
ChannelAccessIFRemoteTest caRemoteTest;
|
SET_LOG_LEVEL(logLevelError);
|
||||||
return caRemoteTest.runAllTest();
|
ChannelAccessIFTest caRemoteTest;
|
||||||
|
return caRemoteTest.runAllTest();
|
||||||
|
}catch(std::exception& e){
|
||||||
|
PRINT_EXCEPTION(e);
|
||||||
|
std::cerr<<"Unhandled exception: "<<e.what()<<"\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
class ChannelAccessIFTest {
|
class ChannelAccessIFTest {
|
||||||
|
|
||||||
|
ChannelProvider::shared_pointer m_provider;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int runAllTest();
|
int runAllTest();
|
||||||
@ -23,9 +24,9 @@ protected:
|
|||||||
static std::string TEST_ARRAY_CHANNEL_NAME;
|
static std::string TEST_ARRAY_CHANNEL_NAME;
|
||||||
|
|
||||||
|
|
||||||
virtual ChannelProvider::shared_pointer getChannelProvider() = 0;
|
ChannelProvider::shared_pointer getChannelProvider() { return m_provider; }
|
||||||
virtual long getTimeoutSec() = 0;
|
long getTimeoutSec() {return 3;}
|
||||||
virtual bool isLocal() = 0;
|
bool isLocal() {return false;}
|
||||||
|
|
||||||
|
|
||||||
Channel::shared_pointer createChannel(std::string channelName, bool debug = false );
|
Channel::shared_pointer createChannel(std::string channelName, bool debug = false );
|
||||||
|
Reference in New Issue
Block a user