pvAccessCPP  7.1.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
65  static const Version VERSION;
66 
71  float getBeaconPeriod();
72 
77  epics::pvData::int32 getReceiveBufferSize();
78 
83  epics::pvData::int32 getServerPort() OVERRIDE FINAL;
84 
89  epics::pvData::int32 getBroadcastPort() OVERRIDE FINAL;
90 
95  BeaconServerStatusProvider::shared_pointer getBeaconServerStatusProvider();
96 
101  const osiSockAddr *getServerInetAddress();
102 
107  const BlockingUDPTransport::shared_pointer& getBroadcastTransport();
108 
113  virtual const std::vector<ChannelProvider::shared_pointer>& getChannelProviders() OVERRIDE FINAL;
114 
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 
129  ServerGUID _guid;
130 
135  std::string _beaconAddressList;
136 
140  IfaceNodeVector _ifaceList;
141 
142  osiSockAddr _ifaceAddr;
143 
148  std::string _ignoreAddressList;
149 
153  bool _autoBeaconAddressList;
154 
158  float _beaconPeriod;
159 
163  epics::pvData::int32 _broadcastPort;
164 
168  epics::pvData::int32 _serverPort;
169 
173  epics::pvData::int32 _receiveBufferSize;
174 
175  epics::pvData::Timer::shared_pointer _timer;
176 
180  BlockingUDPTransportVector _udpTransports;
181 
185  BlockingUDPTransport::shared_pointer _broadcastTransport;
186 
187  BeaconEmitter::shared_pointer _beaconEmitter;
188 
192  BlockingTCPAcceptor::shared_pointer _acceptor;
193 
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 
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
duration< int64_t > seconds