From d36e6f31b180dc0e8a0fe7be016da9d2d9992f89 Mon Sep 17 00:00:00 2001 From: mrkraimer Date: Mon, 7 Aug 2017 11:05:20 -0400 Subject: [PATCH] CAProvider: only CAClientFactory is public --- src/ca/Makefile | 1 - src/ca/caChannel.cpp | 5 +-- src/ca/{pv => }/caChannel.h | 2 +- src/ca/caProvider.cpp | 17 ++++--- src/ca/caProviderPvt.h | 89 +++++++++++++++++++++++++++++++++++++ src/ca/caStatus.cpp | 4 +- src/ca/{pv => }/caStatus.h | 6 +-- src/ca/pv/caProvider.h | 70 +---------------------------- 8 files changed, 108 insertions(+), 86 deletions(-) rename src/ca/{pv => }/caChannel.h (99%) create mode 100644 src/ca/caProviderPvt.h rename src/ca/{pv => }/caStatus.h (79%) diff --git a/src/ca/Makefile b/src/ca/Makefile index ff22361..77de12d 100644 --- a/src/ca/Makefile +++ b/src/ca/Makefile @@ -5,7 +5,6 @@ LIBRARY += pvAccessCA pvAccessCA_LIBS += ca pvAccess pvData Com INC += pv/caProvider.h -INC += pv/caStatus.h pvAccessCA_SRCS += caProvider.cpp pvAccessCA_SRCS += caChannel.cpp diff --git a/src/ca/caChannel.cpp b/src/ca/caChannel.cpp index 00de026..cbc31e5 100644 --- a/src/ca/caChannel.cpp +++ b/src/ca/caChannel.cpp @@ -11,9 +11,8 @@ #include #include -#define epicsExportSharedSymbols -#include -#include +#include "caChannel.h" +#include "caStatus.h" using namespace epics::pvData; using std::string; diff --git a/src/ca/pv/caChannel.h b/src/ca/caChannel.h similarity index 99% rename from src/ca/pv/caChannel.h rename to src/ca/caChannel.h index 5dbd577..cc234d4 100644 --- a/src/ca/pv/caChannel.h +++ b/src/ca/caChannel.h @@ -16,7 +16,7 @@ /* for CA */ #include -#include +#include "caProviderPvt.h" namespace epics { namespace pvAccess { diff --git a/src/ca/caProvider.cpp b/src/ca/caProvider.cpp index e4ea6b1..58e5513 100644 --- a/src/ca/caProvider.cpp +++ b/src/ca/caProvider.cpp @@ -14,13 +14,15 @@ #include #include -#define epicsExportSharedSymbols -#include -#include +#include "caProviderPvt.h" +#include "caChannel.h" + + +namespace epics { +namespace pvAccess { +namespace ca { using namespace epics::pvData; -using namespace epics::pvAccess; -using namespace epics::pvAccess::ca; #define EXCEPTION_GUARD(code) try { code; } \ catch (std::exception &e) { LOG(logLevelError, "Unhandled exception caught from client code at %s:%d: %s", __FILE__, __LINE__, e.what()); } \ @@ -211,3 +213,8 @@ void registerClientProvider_ca() } } } // extern "C" + +} +} +} + diff --git a/src/ca/caProviderPvt.h b/src/ca/caProviderPvt.h new file mode 100644 index 0000000..f75c7f8 --- /dev/null +++ b/src/ca/caProviderPvt.h @@ -0,0 +1,89 @@ +/** + * Copyright - See the COPYRIGHT that is included with this distribution. + * pvAccessCPP is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + */ + +#ifndef CAPROVIDERPVT_H +#define CAPROVIDERPVT_H + +#include + +#include +#include +#include + + +namespace epics { +namespace pvAccess { +class Configuration; +namespace ca { + +class CAChannelProvider : + public ChannelProvider, + public std::tr1::enable_shared_from_this +{ +public: + POINTER_DEFINITIONS(CAChannelProvider); + + CAChannelProvider(); + CAChannelProvider(const std::tr1::shared_ptr&); + virtual ~CAChannelProvider(); + + /* --------------- epics::pvAccess::ChannelProvider --------------- */ + + 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(); + + virtual void destroy(); + + /* ---------------------------------------------------------------- */ + + void threadAttach(); + + void registerChannel(Channel::shared_pointer const & channel); + void unregisterChannel(Channel::shared_pointer const & channel); + void unregisterChannel(Channel* pchannel); + +private: + + void initialize(); + + ca_client_context* current_context; + + epics::pvData::Mutex channelsMutex; + // TODO std::unordered_map + // void* is not the nicest thing, but there is no fast weak_ptr::operator== + typedef std::map ChannelList; + ChannelList channels; + + // synced on channelsMutex + bool destroyed; +}; + +} +} +} + +#endif /* CAPROVIDERPVT_H */ diff --git a/src/ca/caStatus.cpp b/src/ca/caStatus.cpp index 60f134c..7f97221 100644 --- a/src/ca/caStatus.cpp +++ b/src/ca/caStatus.cpp @@ -4,9 +4,7 @@ * in file LICENSE that is included with this distribution. */ -#define epicsExportSharedSymbols - -#include +#include "caStatus.h" namespace epics { namespace pvAccess { diff --git a/src/ca/pv/caStatus.h b/src/ca/caStatus.h similarity index 79% rename from src/ca/pv/caStatus.h rename to src/ca/caStatus.h index 769d988..5b8746b 100644 --- a/src/ca/pv/caStatus.h +++ b/src/ca/caStatus.h @@ -9,8 +9,6 @@ #include -#include - namespace epics { namespace pvAccess { namespace ca { @@ -20,8 +18,8 @@ enum AlarmStatus { dbStatus,confStatus,undefinedStatus,clientStatus }; -epicsShareExtern std::string dbrStatus2alarmMessage[]; -epicsShareExtern int dbrStatus2alarmStatus[]; +extern std::string dbrStatus2alarmMessage[]; +extern int dbrStatus2alarmStatus[]; } } diff --git a/src/ca/pv/caProvider.h b/src/ca/pv/caProvider.h index d4593dd..61799ad 100644 --- a/src/ca/pv/caProvider.h +++ b/src/ca/pv/caProvider.h @@ -7,82 +7,14 @@ #ifndef CAPROVIDER_H #define CAPROVIDER_H -#include - -#include -#include - #include +#include namespace epics { namespace pvAccess { class Configuration; namespace ca { -class epicsShareClass CAChannelProvider : - public ChannelProvider, - public std::tr1::enable_shared_from_this -{ -public: - POINTER_DEFINITIONS(CAChannelProvider); - - CAChannelProvider(); - CAChannelProvider(const std::tr1::shared_ptr&); - virtual ~CAChannelProvider(); - - /* --------------- epics::pvAccess::ChannelProvider --------------- */ - - 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(); - - virtual void destroy(); - - /* ---------------------------------------------------------------- */ - - void threadAttach(); - - void registerChannel(Channel::shared_pointer const & channel); - void unregisterChannel(Channel::shared_pointer const & channel); - void unregisterChannel(Channel* pchannel); - -private: - - void initialize(); - - ca_client_context* current_context; - - epics::pvData::Mutex channelsMutex; - // TODO std::unordered_map - // void* is not the nicest thing, but there is no fast weak_ptr::operator== - typedef std::map ChannelList; - ChannelList channels; - - // synced on channelsMutex - bool destroyed; -}; - - class epicsShareClass CAClientFactory { public: