pvAccessCPP  7.1.1
serverContextImpl.h
1 #ifndef SERVERCONTEXTIMPL_H
2 #define SERVERCONTEXTIMPL_H
3 
4 #ifdef epicsExportSharedSymbols
5 # define serverContextImplEpicsExportSharedSymbols
6 # undef epicsExportSharedSymbols
7 #endif
8 
9 #include <pv/thread.h>
10 
11 #ifdef serverContextImplEpicsExportSharedSymbols
12 # define epicsExportSharedSymbols
13 # undef serverContextImplEpicsExportSharedSymbols
14 #endif
15 
16 #include <pv/blockingUDP.h>
17 #include <pv/blockingTCP.h>
18 #include <pv/beaconEmitter.h>
19 
20 #include "serverContext.h"
21 
22 namespace epics {
23 namespace pvAccess {
24 
25 class ServerContextImpl :
26  public ServerContext,
27  public Context,
28  public std::tr1::enable_shared_from_this<ServerContextImpl>
29 {
30  friend class ServerContext;
31 public:
32  typedef std::tr1::shared_ptr<ServerContextImpl> shared_pointer;
33  typedef std::tr1::shared_ptr<const ServerContextImpl> const_shared_pointer;
34 
35  static size_t num_instances;
36 
37  ServerContextImpl();
38  virtual ~ServerContextImpl();
39 
40  //**************** derived from ServerContext ****************//
41  const ServerGUID& getGUID() OVERRIDE FINAL;
42  const Version& getVersion() OVERRIDE FINAL;
43  void initialize();
44  void run(epics::pvData::uint32 seconds) OVERRIDE FINAL;
45  void shutdown() OVERRIDE FINAL;
46  void printInfo(std::ostream& str, int lvl) OVERRIDE FINAL;
47  void setBeaconServerStatusProvider(BeaconServerStatusProvider::shared_pointer const & beaconServerStatusProvider) OVERRIDE FINAL;
48  //**************** derived from Context ****************//
49  epics::pvData::Timer::shared_pointer getTimer() OVERRIDE FINAL;
50  Channel::shared_pointer getChannel(pvAccessID id) OVERRIDE FINAL;
51  Transport::shared_pointer getSearchTransport() OVERRIDE FINAL;
52  Configuration::const_shared_pointer getConfiguration() OVERRIDE FINAL;
53  TransportRegistry* getTransportRegistry() OVERRIDE FINAL;
54 
55  virtual void newServerDetected() OVERRIDE FINAL;
56 
57 
58  epicsTimeStamp& getStartTime() OVERRIDE FINAL;
59 
60  virtual Configuration::shared_pointer getCurrentConfig() OVERRIDE FINAL;
61 
62  /**
63  * Version.
64  */
65  static const Version VERSION;
66 
67  /**
68  * Get beacon period (in seconds).
69  * @return beacon period (in seconds).
70  */
71  float getBeaconPeriod();
72 
73  /**
74  * Get receiver buffer (payload) size.
75  * @return max payload size.
76  */
77  epics::pvData::int32 getReceiveBufferSize();
78 
79  /**
80  * Get server port.
81  * @return server port.
82  */
83  epics::pvData::int32 getServerPort() OVERRIDE FINAL;
84 
85  /**
86  * Get broadcast port.
87  * @return broadcast port.
88  */
89  epics::pvData::int32 getBroadcastPort() OVERRIDE FINAL;
90 
91  /**
92  * Get registered beacon server status provider.
93  * @return registered beacon server status provider.
94  */
95  BeaconServerStatusProvider::shared_pointer getBeaconServerStatusProvider();
96 
97  /**
98  * Get server newtwork (IP) address.
99  * @return server network (IP) address, <code>NULL</code> if not bounded.
100  */
101  const osiSockAddr *getServerInetAddress();
102 
103  /**
104  * Broadcast (UDP send) transport.
105  * @return broadcast transport.
106  */
107  const BlockingUDPTransport::shared_pointer& getBroadcastTransport();
108 
109  /**
110  * Get channel providers.
111  * @return channel providers.
112  */
113  virtual const std::vector<ChannelProvider::shared_pointer>& getChannelProviders() OVERRIDE FINAL;
114 
115  /**
116  * Return <code>true</code> if channel provider name is provided by configuration (e.g. system env. var.).
117  * @return <code>true</code> if channel provider name is provided by configuration (e.g. system env. var.)
118  */
119  bool isChannelProviderNamePreconfigured();
120 
121  // used by ServerChannelFindRequesterImpl
122  typedef std::map<std::string, std::tr1::weak_ptr<ChannelProvider> > s_channelNameToProvider_t;
123  s_channelNameToProvider_t s_channelNameToProvider;
124 private:
125 
126  /**
127  * Server GUID.
128  */
129  ServerGUID _guid;
130 
131  /**
132  * A space-separated list of broadcast address which to send beacons.
133  * Each address must be of the form: ip.number:port or host.name:port
134  */
135  std::string _beaconAddressList;
136 
137  /**
138  * List of used NIF.
139  */
140  IfaceNodeVector _ifaceList;
141 
142  osiSockAddr _ifaceAddr;
143 
144  /**
145  * A space-separated list of address from which to ignore name resolution requests.
146  * Each address must be of the form: ip.number:port or host.name:port
147  */
148  std::string _ignoreAddressList;
149 
150  /**
151  * Define whether or not the network interfaces should be discovered at runtime.
152  */
153  bool _autoBeaconAddressList;
154 
155  /**
156  * Period in second between two beacon signals.
157  */
158  float _beaconPeriod;
159 
160  /**
161  * Broadcast port number to listen to.
162  */
163  epics::pvData::int32 _broadcastPort;
164 
165  /**
166  * Port number for the server to listen to.
167  */
168  epics::pvData::int32 _serverPort;
169 
170  /**
171  * Length in bytes of the maximum buffer (payload) size that may pass through PVA.
172  */
173  epics::pvData::int32 _receiveBufferSize;
174 
175  epics::pvData::Timer::shared_pointer _timer;
176 
177  /**
178  * UDP transports needed to receive channel searches.
179  */
180  BlockingUDPTransportVector _udpTransports;
181 
182  /** UDP socket used to sending.
183  * constant after ServerContextImpl::initialize()
184  */
185  BlockingUDPTransport::shared_pointer _broadcastTransport;
186 
187  BeaconEmitter::shared_pointer _beaconEmitter;
188 
189  /**
190  * PVAS acceptor (accepts PVA virtual circuit).
191  */
192  BlockingTCPAcceptor::shared_pointer _acceptor;
193 
194  /**
195  * PVA transport (virtual circuit) registry.
196  * This registry contains all active transports - connections to PVA servers.
197  */
198  TransportRegistry _transportRegistry;
199 
200  ResponseHandler::shared_pointer _responseHandler;
201 
202  // const after loadConfiguration()
203  std::vector<ChannelProvider::shared_pointer> _channelProviders;
204 
205 public:
206  epics::pvData::Mutex _mutex;
207 private:
208 
209  epics::pvData::Event _runEvent;
210 
211  /**
212  * Beacon server status provider interface (optional).
213  */
214  BeaconServerStatusProvider::shared_pointer _beaconServerStatusProvider;
215 
216  void generateGUID();
217 
218  void loadConfiguration();
219 
220  Configuration::const_shared_pointer configuration;
221 
222  epicsTimeStamp _startTime;
223 };
224 
225 }
226 }
227 
228 #endif // SERVERCONTEXTIMPL_H
virtual void authNZMessage(epics::pvData::PVStructure::shared_pointer const &data)=0
Pass data to the active security plug-in session.
#define OVERRIDE
Definition: pvAccess.h:55
#define FINAL
Copyright - See the COPYRIGHT that is included with this distribution.
Definition: pvAccess.h:48