pvAccessCPP  7.1.6
serverContext.h
1 /**
2  * Copyright - See the COPYRIGHT that is included with this distribution.
3  * pvAccessCPP is distributed subject to a Software License Agreement found
4  * in file LICENSE that is included with this distribution.
5  */
6 
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 
24 /**
25  * The class representing a PVA Server context.
26  */
27 class epicsShareClass ServerContext
28 {
29 public:
31 
32  /**
33  * Destructor
34  */
35  virtual ~ServerContext() {};
36 
37  /**
38  * Returns GUID (12-byte array).
39  * @return GUID.
40  */
41  virtual const ServerGUID& getGUID() = 0;
42 
43  /**
44  * Get context implementation version.
45  * @return version of the context implementation.
46  */
47  virtual const Version& getVersion() = 0;
48 
49  /**
50  * Run server (process events).
51  * @param seconds time in seconds the server will process events (method will block), if <code>0</code>
52  * the method would block until <code>destroy()</code> is called.
53  * @throws BaseException if server is already destroyed.
54  */
55  virtual void run(epics::pvData::uint32 seconds) = 0;
56 
57  virtual void shutdown() = 0;
58 
59  /**
60  * Prints detailed information about the context to the standard output stream.
61  */
62  void printInfo(int lvl =0);
63 
64  /**
65  * Prints detailed information about the context to the specified output stream.
66  * @param lvl detail level
67  * @param str stream to which to print the info
68  */
69  virtual void printInfo(std::ostream& str, int lvl=0) = 0;
70 
71  virtual epicsTimeStamp& getStartTime() = 0;
72 
73  /**
74  * Get server port.
75  * @return server port.
76  */
77  virtual epics::pvData::int32 getServerPort() = 0;
78 
79  /**
80  * Get broadcast port.
81  * @return broadcast port.
82  */
83  virtual epics::pvData::int32 getBroadcastPort() = 0;
84 
85  /** Return a Configuration with the actual values being used,
86  * including defaults used, and bounds limits applied.
87  */
89 
91 
92  // ************************************************************************** //
93  // **************************** [ Plugins ] ********************************* //
94  // ************************************************************************** //
95 
96  /**
97  * Set beacon server status provider.
98  * @param beaconServerStatusProvider <code>BeaconServerStatusProvider</code> implementation to set.
99  */
101 
102  //! Options for a server insatnce
103  class Config {
104  friend class ServerContext;
107  public:
108  Config() {}
109  //! Use specific configuration. Default is process environment
110  Config& config(const Configuration::const_shared_pointer& c) { _conf = c; return *this; }
111  //! Attach many providers.
113  //! short hand for providers() with a length 1 vector.
115  };
116 
117  /** Start a new PVA server
118  *
119  * By default the server will select ChannelProviders using the
120  * EPICS_PVAS_PROVIDER_NAMES Configuration key.
121  *
122  * If a list of provided is given with Config::providers() then this
123  * overrides any Configuration.
124  *
125  * If a specific Configuration is given with Config::config() then
126  * this overrides the default Configuration.
127  *
128  * @returns shared_ptr<ServerContext> which will automatically shutdown() when the last reference is released.
129  */
130  static ServerContext::shared_pointer create(const Config& conf = Config());
131 };
132 
133 // Caller must store the returned pointer to keep the server alive.
136  int timeToRun = 0,
137  bool runInSeparateThread = false,
138  bool printInfo = false);
139 
140 }
141 }
142 
143 
144 #endif /* SERVERCONTEXT_H_ */
virtual void authNZMessage(epics::pvData::PVStructure::shared_pointer const &data)=0
Pass data to the active security plug-in session.
The class representing a PVA Server context.
Definition: serverContext.h:27