From 25b621890b7937794a52f968724d5bdf68954d58 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 6 Nov 2017 12:57:21 -0600 Subject: [PATCH] Convert debug into a file static data member MSVC doesn't seem to be able to provide access to it as a class static, so this fixes the DLL build errors of exampleCPP --- src/pv/pvaClient.h | 6 +++--- src/pvaClient.cpp | 29 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/pv/pvaClient.h b/src/pv/pvaClient.h index 3031e38..b31092f 100644 --- a/src/pv/pvaClient.h +++ b/src/pv/pvaClient.h @@ -95,6 +95,7 @@ typedef std::tr1::weak_ptr PvaClientRPCRequesterWPtr; class PvaClientChannelCache; typedef std::tr1::shared_ptr PvaClientChannelCachePtr; + /** * @brief pvaClient is a synchronous wrapper for the pvAccess API, which is a callback based API. * @@ -172,14 +173,13 @@ public: * * @param value true or false */ - static void setDebug(bool value) {debug = value;} + static void setDebug(bool value); /** @brief Is debug set? * * @return true or false */ - static bool getDebug() {return debug;} + static bool getDebug(); private: - static bool debug; PvaClient(std::string const & providerNames); PvaClientChannelCachePtr pvaClientChannelCache; epics::pvData::Requester::weak_pointer requester; diff --git a/src/pvaClient.cpp b/src/pvaClient.cpp index cb3790d..4fea159 100644 --- a/src/pvaClient.cpp +++ b/src/pvaClient.cpp @@ -87,7 +87,18 @@ size_t PvaClientChannelCache::cacheSize() } -bool PvaClient::debug = false; +// MSVC doesn't like making this a class static data member: +static bool debug = 0; + +void PvaClient::setDebug(bool value) +{ + debug = value; +} + +bool PvaClient::getDebug() +{ + return debug; +} PvaClientPtr PvaClient::get(std::string const & providerNames) { @@ -109,19 +120,19 @@ PvaClient::PvaClient(std::string const & providerNames) { stringstream ss(providerNames); string providerName; - if(PvaClient::debug) { + if(getDebug()) { cout<< "PvaClient::PvaClient()\n"; } while (getline(ss, providerName, ' ')) { if(providerName=="pva") { - if(PvaClient::debug) { + if(getDebug()) { cout<< "calling ClientFactory::start()\n"; } ClientFactory::start(); pvaStarted = true; } else if(providerName=="ca") { - if(PvaClient::debug) { + if(getDebug()) { cout<< "calling CAClientFactory::start()\n"; } CAClientFactory::start(); @@ -135,20 +146,20 @@ PvaClient::PvaClient(std::string const & providerNames) } PvaClient::~PvaClient() { - if(PvaClient::debug) { + if(getDebug()) { cout<< "PvaClient::~PvaClient()\n" << "pvaChannel cache:\n"; showCache(); } if(pvaStarted){ - if(PvaClient::debug) cout<< "calling ClientFactory::stop()\n"; + if(getDebug()) cout<< "calling ClientFactory::stop()\n"; ClientFactory::stop(); - if(PvaClient::debug) cout<< "after calling ClientFactory::stop()\n"; + if(getDebug()) cout<< "after calling ClientFactory::stop()\n"; } if(caStarted) { - if(PvaClient::debug) cout<< "calling CAClientFactory::stop()\n"; + if(getDebug()) cout<< "calling CAClientFactory::stop()\n"; CAClientFactory::stop(); - if(PvaClient::debug) cout<< "after calling CAClientFactory::stop()\n"; + if(getDebug()) cout<< "after calling CAClientFactory::stop()\n"; } channelRegistry.reset(); }