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
This commit is contained in:
Andrew Johnson
2017-11-06 12:57:21 -06:00
parent 64fc25c240
commit 25b621890b
2 changed files with 23 additions and 12 deletions

View File

@@ -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();
}