pvAccessCPP  7.1.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
serverContext.h
1 
7 #ifndef SERVERCONTEXT_H_
8 #define SERVERCONTEXT_H_
9 
10 #include <epicsTime.h>
11 
12 #include <pv/pvaDefs.h>
13 #include <pv/beaconServerStatusProvider.h>
14 #include <pv/pvaConstants.h>
15 #include <pv/pvaVersion.h>
16 #include <pv/pvAccess.h>
17 #include <pv/configuration.h>
18 
19 #include <shareLib.h>
20 
21 namespace epics {
22 namespace pvAccess {
23 
27 class epicsShareClass ServerContext
28 {
29 public:
30  POINTER_DEFINITIONS(ServerContext);
31 
35  virtual ~ServerContext() {};
36 
41  virtual const ServerGUID& getGUID() = 0;
42 
47  virtual const Version& getVersion() = 0;
48 
55  virtual void run(epics::pvData::uint32 seconds) = 0;
56 
57  virtual void shutdown() = 0;
58 
62  void printInfo(int lvl =0);
63 
69  virtual void printInfo(std::ostream& str, int lvl=0) = 0;
70 
71  virtual epicsTimeStamp& getStartTime() = 0;
72 
77  virtual epics::pvData::int32 getServerPort() = 0;
78 
83  virtual epics::pvData::int32 getBroadcastPort() = 0;
84 
88  virtual Configuration::shared_pointer getCurrentConfig() = 0;
89 
90  virtual const std::vector<ChannelProvider::shared_pointer>& getChannelProviders() =0;
91 
92  // ************************************************************************** //
93  // **************************** [ Plugins ] ********************************* //
94  // ************************************************************************** //
95 
100  virtual void setBeaconServerStatusProvider(BeaconServerStatusProvider::shared_pointer const & beaconServerStatusProvider) = 0;
101 
103  class Config {
104  friend class ServerContext;
105  Configuration::const_shared_pointer _conf;
107  public:
108  Config() {}
110  Config& config(const Configuration::const_shared_pointer& c) { _conf = c; return *this; }
112  Config& providers(const std::vector<ChannelProvider::shared_pointer>& p) { _providers = p; return *this; }
114  Config& provider(const ChannelProvider::shared_pointer& p) { _providers.push_back(p); return *this; }
115  };
116 
130  static ServerContext::shared_pointer create(const Config& conf = Config());
131 };
132 
133 // Caller must store the returned pointer to keep the server alive.
134 epicsShareFunc ServerContext::shared_pointer startPVAServer(
135  std::string const & providerNames = PVACCESS_ALL_PROVIDERS,
136  int timeToRun = 0,
137  bool runInSeparateThread = false,
138  bool printInfo = false);
139 
140 }
141 }
142 
143 
144 #endif /* SERVERCONTEXT_H_ */
duration< int64_t > seconds
Config & config(const Configuration::const_shared_pointer &c)
Use specific configuration. Default is process environment.
Options for a server insatnce.
const std::string PVACCESS_ALL_PROVIDERS
&quot;All-providers registered&quot; PVA provider name.
virtual ~ServerContext()
Destructor.
Definition: serverContext.h:35
Globally unique ID.
Definition: pvaDefs.h:14
Config & provider(const ChannelProvider::shared_pointer &p)
short hand for providers() with a length 1 vector.
Config & providers(const std::vector< ChannelProvider::shared_pointer > &p)
Attach many providers.
The class representing a PVA Server context.
Definition: serverContext.h:27