automatic ClientFactory::start()

register the "pva" provider automatically.
This commit is contained in:
Michael Davidsaver
2017-07-17 14:29:27 +02:00
parent 2c530868f6
commit eef51a9a6d
10 changed files with 38 additions and 35 deletions

View File

@ -20,7 +20,6 @@
//! [Headers]
#include <pv/configuration.h>
#include <pv/clientFactory.h>
#include <pv/caProvider.h>
#include <pva/client.h>
//! [Headers]
@ -138,8 +137,7 @@ int main(int argc, char *argv[]) {
.push_env()
.build());
// add "pva" provider to registry
pva::ClientFactory::start();
// "pva" provider automatically in registry
// add "ca" provider to registry
pva::ca::CAClientFactory::start();

View File

@ -6,7 +6,6 @@
#include <iostream>
#include "pv/clientFactory.h"
#include "pva/client.h"
int main(int argc, char *argv[])
@ -17,8 +16,6 @@ int main(int argc, char *argv[])
return 1;
}
epics::pvAccess::ClientFactory::start();
pvac::ClientProvider provider("pva");
pvac::ClientChannel channel(provider.connect(argv[1]));

View File

@ -20,7 +20,6 @@
#include <epicsGuard.h>
#include <pv/configuration.h>
#include <pv/clientFactory.h>
#include <pv/caProvider.h>
#include <pv/thread.h>
#include <pva/client.h>
@ -238,8 +237,7 @@ int main(int argc, char *argv[]) {
.push_env()
.build());
// add "pva" provider to registry
pva::ClientFactory::start();
// "pva" provider automatically in registry
// add "ca" provider to registry
pva::ca::CAClientFactory::start();

View File

@ -22,7 +22,6 @@
//! [Headers]
#include <pv/configuration.h>
#include <pv/clientFactory.h>
#include <pv/caProvider.h>
#include <pva/client.h>
//! [Headers]
@ -182,8 +181,7 @@ int main(int argc, char *argv[]) {
.push_env()
.build());
// add "pva" provider to registry
pva::ClientFactory::start();
// "pva" provider automatically in registry
// add "ca" provider to registry
pva::ca::CAClientFactory::start();

View File

@ -3,7 +3,6 @@
#endif
#include <iostream>
#include <pv/clientFactory.h>
#include <pv/pvAccess.h>
#include <pv/caProvider.h>
@ -1670,8 +1669,7 @@ int main (int argc, char *argv[])
serviceRequest = true;
}
// register "pva" and "ca" providers
ClientFactory::start();
// register "ca" provider
epics::pvAccess::ca::CAClientFactory::start();
// PVs mode
@ -1878,9 +1876,6 @@ int main (int argc, char *argv[])
while (true)
epicsThreadSleep(timeOut);
}
epics::pvAccess::ca::CAClientFactory::stop();
ClientFactory::stop();
}
// service RPC mode
else
@ -2020,7 +2015,6 @@ int main (int argc, char *argv[])
}
ClientFactory::start();
ChannelProvider::shared_pointer provider = ChannelProviderRegistry::clients()->getProvider("pva");
assert(provider);
@ -2060,8 +2054,6 @@ int main (int argc, char *argv[])
}
channel->destroy();
ClientFactory::stop();
}
if (cleanupAndReport)

View File

@ -18,7 +18,6 @@
#include <epicsExit.h>
#include <epicsGuard.h>
#include <pv/clientFactory.h>
#include <pv/caProvider.h>
#include <pv/pvAccess.h>
#include <epicsThread.h>
@ -505,7 +504,6 @@ int main (int argc, char *argv[])
// ================ Connect channels and start operations
ClientFactory::start();
epics::pvAccess::ca::CAClientFactory::start();
bool allOK = true;
@ -613,9 +611,6 @@ int main (int argc, char *argv[])
// ========================== All done now
epics::pvAccess::ca::CAClientFactory::stop();
ClientFactory::stop();
if(debugFlag)
std::cerr<<"Done\n";
return allOK ? 0 : 1;

View File

@ -1,5 +1,4 @@
#include <iostream>
#include <pv/clientFactory.h>
#include <pv/pvAccess.h>
#include <pv/caProvider.h>
@ -137,7 +136,6 @@ int main (int argc, char *argv[])
bool allOK = true;
ClientFactory::start();
epics::pvAccess::ca::CAClientFactory::start();
{
@ -218,8 +216,6 @@ int main (int argc, char *argv[])
}
}
epics::pvAccess::ca::CAClientFactory::stop();
ClientFactory::stop();
}
if (cleanupAndReport)

View File

@ -1,5 +1,4 @@
#include <iostream>
#include <pv/clientFactory.h>
#include <pv/pvAccess.h>
#include <stdio.h>
@ -619,7 +618,6 @@ int main (int argc, char *argv[])
address = uri.host;
}
ClientFactory::start();
epics::pvAccess::ca::CAClientFactory::start();
ChannelProvider::shared_pointer provider(ChannelProviderRegistry::clients()->getProvider(providerName));
@ -733,8 +731,5 @@ int main (int argc, char *argv[])
std::cerr << "unknown exception caught" << std::endl;
}
epics::pvAccess::ca::CAClientFactory::stop();
ClientFactory::stop();
return allOK ? 0 : 1;
}

View File

@ -197,3 +197,15 @@ void CAClientFactory::stop()
{
// unregister now done with exit hook
}
// perhaps useful during dynamic loading?
extern "C" {
void registerClientProvider_ca()
{
try {
CAClientFactory::start();
} catch(std::exception& e){
std::cerr<<"Error loading ca: "<<e.what()<<"\n";
}
}
} // extern "C"

View File

@ -41,3 +41,25 @@ void ClientFactory::stop()
{
// unregister now done with exit hook
}
// automatically register on load
namespace {
struct pvaloader
{
pvaloader() {
ClientFactory::start();
}
} pvaloaderinstance;
} // namespace
// perhaps useful during dynamic loading?
extern "C" {
void registerClientProvider_pva()
{
try {
ClientFactory::start();
} catch(std::exception& e){
std::cerr<<"Error loading pva: "<<e.what()<<"\n";
}
}
} // extern "C"