CAProvider: only CAClientFactory is public

This commit is contained in:
mrkraimer
2017-08-07 11:05:20 -04:00
parent d70e0b2542
commit d36e6f31b1
8 changed files with 108 additions and 86 deletions

View File

@@ -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

View File

@@ -11,9 +11,8 @@
#include <pv/logger.h>
#include <pv/pvAccess.h>
#define epicsExportSharedSymbols
#include <pv/caChannel.h>
#include <pv/caStatus.h>
#include "caChannel.h"
#include "caStatus.h"
using namespace epics::pvData;
using std::string;

View File

@@ -16,7 +16,7 @@
/* for CA */
#include <cadef.h>
#include <pv/caProvider.h>
#include "caProviderPvt.h"
namespace epics {
namespace pvAccess {

View File

@@ -14,13 +14,15 @@
#include <pv/configuration.h>
#include <pv/pvAccess.h>
#define epicsExportSharedSymbols
#include <pv/caProvider.h>
#include <pv/caChannel.h>
#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"
}
}
}

89
src/ca/caProviderPvt.h Normal file
View File

@@ -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 <cadef.h>
#include <pv/caProvider.h>
#include <pv/pvAccess.h>
#include <map>
namespace epics {
namespace pvAccess {
class Configuration;
namespace ca {
class CAChannelProvider :
public ChannelProvider,
public std::tr1::enable_shared_from_this<CAChannelProvider>
{
public:
POINTER_DEFINITIONS(CAChannelProvider);
CAChannelProvider();
CAChannelProvider(const std::tr1::shared_ptr<Configuration>&);
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<void*, Channel::weak_pointer> ChannelList;
ChannelList channels;
// synced on channelsMutex
bool destroyed;
};
}
}
}
#endif /* CAPROVIDERPVT_H */

View File

@@ -4,9 +4,7 @@
* in file LICENSE that is included with this distribution.
*/
#define epicsExportSharedSymbols
#include <pv/caStatus.h>
#include "caStatus.h"
namespace epics {
namespace pvAccess {

View File

@@ -9,8 +9,6 @@
#include <string>
#include <shareLib.h>
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[];
}
}

View File

@@ -7,82 +7,14 @@
#ifndef CAPROVIDER_H
#define CAPROVIDER_H
#include <cadef.h>
#include <pv/pvAccess.h>
#include <map>
#include <shareLib.h>
#include <pv/pvAccess.h>
namespace epics {
namespace pvAccess {
class Configuration;
namespace ca {
class epicsShareClass CAChannelProvider :
public ChannelProvider,
public std::tr1::enable_shared_from_this<CAChannelProvider>
{
public:
POINTER_DEFINITIONS(CAChannelProvider);
CAChannelProvider();
CAChannelProvider(const std::tr1::shared_ptr<Configuration>&);
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<void*, Channel::weak_pointer> ChannelList;
ChannelList channels;
// synced on channelsMutex
bool destroyed;
};
class epicsShareClass CAClientFactory
{
public: