From b37baf8ecbef02b3b4ff439ff3614f42d0151ec2 Mon Sep 17 00:00:00 2001 From: mrkraimer Date: Sun, 4 Jun 2017 14:52:53 -0400 Subject: [PATCH] changes suggested by Michael Davidsaver --- MRKCHANGES.md | 6 +----- src/ca/caProvider.cpp | 8 ++++---- src/ca/pv/caProvider.h | 4 +--- src/client/pv/pvAccess.h | 13 ------------- src/factory/ChannelAccessFactory.cpp | 17 ++--------------- src/pva/clientFactory.cpp | 8 ++++---- src/pva/pv/clientFactory.h | 6 +++--- 7 files changed, 15 insertions(+), 47 deletions(-) diff --git a/MRKCHANGES.md b/MRKCHANGES.md index c70272f..9262555 100644 --- a/MRKCHANGES.md +++ b/MRKCHANGES.md @@ -48,14 +48,10 @@ All these changes are in the github repositories belonging to mrkraimer. ChannelProviderRegistry ----------------------- -The following new methods are added to ChannelProviderRegistry: +The following new method is added to ChannelProviderRegistry: static ChannelProviderRegistry::shared_pointer getChannelProviderRegistry(); - void registerChannelProviderFactory( - ChannelProviderFactory::shared_pointer const & channelProviderFactory); - void unregisterChannelProviderFactory( - ChannelProviderFactory::shared_pointer const & channelProviderFactory); **getChannelProviderRegistry** creates the single instance of **ChannelProviderRegistry** the first time it is called and always returns a shared pointer to the single diff --git a/src/ca/caProvider.cpp b/src/ca/caProvider.cpp index ecd8025..fe91e66 100644 --- a/src/ca/caProvider.cpp +++ b/src/ca/caProvider.cpp @@ -233,8 +233,8 @@ public: static Mutex startStopMutex; -ChannelProviderRegistry::shared_pointer CAClientFactory::channelRegistry = ChannelProviderRegistry::shared_pointer(); -CAChannelProviderFactoryPtr CAClientFactory::channelProvider = CAChannelProviderFactory::shared_pointer(); +ChannelProviderRegistry::shared_pointer CAClientFactory::channelRegistry; +ChannelProviderFactory::shared_pointer CAClientFactory::channelProvider; int CAClientFactory::numStart = 0; @@ -249,7 +249,7 @@ std::cout << "CAClientFactory::start() numStart " << numStart << std::endl; channelProvider.reset(new CAChannelProviderFactory()); channelRegistry = ChannelProviderRegistry::getChannelProviderRegistry(); std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std::endl; - channelRegistry->registerChannelProviderFactory(channelProvider); + channelRegistry->add(channelProvider); } void CAClientFactory::stop() @@ -262,7 +262,7 @@ std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std if(numStart>=1) return; if (channelProvider) { - channelRegistry->unregisterChannelProviderFactory(channelProvider); + channelRegistry->remove(CAChannelProvider::PROVIDER_NAME); if(!channelProvider.unique()) { LOG(logLevelWarn, "ClientFactory::stop() finds shared client context with %u remaining users", (unsigned)channelProvider.use_count()); diff --git a/src/ca/pv/caProvider.h b/src/ca/pv/caProvider.h index aa08fd8..58a98bf 100644 --- a/src/ca/pv/caProvider.h +++ b/src/ca/pv/caProvider.h @@ -82,13 +82,11 @@ private: bool destroyed; }; -class CAChannelProviderFactory; -typedef std::tr1::shared_ptr CAChannelProviderFactoryPtr; class epicsShareClass CAClientFactory { private: static epics::pvAccess::ChannelProviderRegistry::shared_pointer channelRegistry; - static CAChannelProviderFactoryPtr channelProvider; + static epics::pvAccess::ChannelProviderFactory::shared_pointer channelProvider; static int numStart; public: static void start(); diff --git a/src/client/pv/pvAccess.h b/src/client/pv/pvAccess.h index afde893..2891942 100644 --- a/src/client/pv/pvAccess.h +++ b/src/client/pv/pvAccess.h @@ -1009,19 +1009,6 @@ public: * @return The interface for ChannelProviderRegistry */ static ChannelProviderRegistry::shared_pointer getChannelProviderRegistry(); - /** - * Register a ChannelProviderFactory. - * @param channelProviderFactory The ChannelProviderFactory. - */ - void registerChannelProviderFactory( - ChannelProviderFactory::shared_pointer const & channelProviderFactory); - /** - * Unregister a ChannelProviderFactory. - * @param channelProviderFactory The ChannelProviderFactory. - */ - void unregisterChannelProviderFactory( - ChannelProviderFactory::shared_pointer const & channelProviderFactory); - /** * Get a shared instance of the provider with the specified name. * @param providerName The name of the provider. diff --git a/src/factory/ChannelAccessFactory.cpp b/src/factory/ChannelAccessFactory.cpp index 4ef4ad1..e869823 100644 --- a/src/factory/ChannelAccessFactory.cpp +++ b/src/factory/ChannelAccessFactory.cpp @@ -43,19 +43,6 @@ ChannelProviderRegistry::shared_pointer ChannelProviderRegistry::getChannelProvi return global_reg; } -void ChannelProviderRegistry::registerChannelProviderFactory( - ChannelProviderFactory::shared_pointer const & channelProviderFactory) -{ - assert(channelProviderFactory); - add(channelProviderFactory); -} - -void ChannelProviderRegistry::unregisterChannelProviderFactory( - ChannelProviderFactory::shared_pointer const & channelProviderFactory) -{ - assert(channelProviderFactory); - remove(channelProviderFactory->getFactoryName()); -} ChannelProvider::shared_pointer ChannelProviderRegistry::getProvider(std::string const & providerName) { ChannelProviderFactory::shared_pointer fact(getFactory(providerName)); @@ -132,12 +119,12 @@ std::cerr << "getChannelProviderRegistry should not be used\n"; void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) { std::cerr << "registerChannelProviderFactory should not be used\n"; - getChannelProviderRegistry()->registerChannelProviderFactory(channelProviderFactory); + getChannelProviderRegistry()->add(channelProviderFactory); } void unregisterChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) { std::cerr << "unregisterChannelProviderFactory should not be used\n"; - getChannelProviderRegistry()->unregisterChannelProviderFactory(channelProviderFactory); + getChannelProviderRegistry()->remove(channelProviderFactory->getFactoryName()); } epicsShareFunc void unregisterAllChannelProviderFactory() diff --git a/src/pva/clientFactory.cpp b/src/pva/clientFactory.cpp index ef95f0f..6252e79 100644 --- a/src/pva/clientFactory.cpp +++ b/src/pva/clientFactory.cpp @@ -66,8 +66,8 @@ public: static Mutex startStopMutex; -ChannelProviderRegistryPtr ClientFactory::channelRegistry = ChannelProviderRegistryPtr(); -ChannelProviderFactoryImplPtr ClientFactory::channelProvider = ChannelProviderFactoryImplPtr(); +ChannelProviderRegistryPtr ClientFactory::channelRegistry; +ChannelProviderFactoryPtr ClientFactory::channelProvider; int ClientFactory::numStart = 0; void ClientFactory::start() @@ -81,7 +81,7 @@ std::cout << "ClientFactory::start() numStart " << numStart << std::endl; channelProvider.reset(new ChannelProviderFactoryImpl()); channelRegistry = ChannelProviderRegistry::getChannelProviderRegistry(); std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std::endl; - channelRegistry->registerChannelProviderFactory(channelProvider); + channelRegistry->add(channelProvider); } void ClientFactory::stop() @@ -95,7 +95,7 @@ std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std if (channelProvider) { - channelRegistry->unregisterChannelProviderFactory(channelProvider); + channelRegistry->remove(ClientContextImpl::PROVIDER_NAME); if(!channelProvider.unique()) { LOG(logLevelWarn, "ClientFactory::stop() finds shared client context with %u remaining users", (unsigned)channelProvider.use_count()); diff --git a/src/pva/pv/clientFactory.h b/src/pva/pv/clientFactory.h index 65e387c..6a583d4 100644 --- a/src/pva/pv/clientFactory.h +++ b/src/pva/pv/clientFactory.h @@ -17,13 +17,13 @@ namespace pvAccess { class ChannelProviderRegistry; typedef std::tr1::shared_ptr ChannelProviderRegistryPtr; -class ChannelProviderFactoryImpl; -typedef std::tr1::shared_ptr ChannelProviderFactoryImplPtr; +class ChannelProviderFactory; +typedef std::tr1::shared_ptr ChannelProviderFactoryPtr; class epicsShareClass ClientFactory { private: static ChannelProviderRegistryPtr channelRegistry; - static ChannelProviderFactoryImplPtr channelProvider; + static ChannelProviderFactoryPtr channelProvider; static int numStart; public: static void start();