diff --git a/src/pipelineService/pv/pipelineServer.h b/src/pipelineService/pv/pipelineServer.h index 968e9f0..8b00033 100644 --- a/src/pipelineService/pv/pipelineServer.h +++ b/src/pipelineService/pv/pipelineServer.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/src/rpcService/pv/rpcServer.h b/src/rpcService/pv/rpcServer.h index b6ead62..4182011 100644 --- a/src/rpcService/pv/rpcServer.h +++ b/src/rpcService/pv/rpcServer.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/src/server/beaconEmitter.cpp b/src/server/beaconEmitter.cpp index dcc79a8..b1b0ea4 100644 --- a/src/server/beaconEmitter.cpp +++ b/src/server/beaconEmitter.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include using namespace std; using namespace epics::pvData; diff --git a/src/server/pv/baseChannelRequester.h b/src/server/pv/baseChannelRequester.h index e38e1f4..5a15d69 100644 --- a/src/server/pv/baseChannelRequester.h +++ b/src/server/pv/baseChannelRequester.h @@ -20,7 +20,7 @@ # undef baseChannelRequesterEpicsExportSharedSymbols #endif -#include +#include #include namespace epics { diff --git a/src/server/pv/serverContext.h b/src/server/pv/serverContext.h index fde37e1..66e23b6 100644 --- a/src/server/pv/serverContext.h +++ b/src/server/pv/serverContext.h @@ -106,353 +106,6 @@ public: }; - -class epicsShareClass ServerContextImpl : - public ServerContext, - public Context, - public std::tr1::enable_shared_from_this -{ -public: - typedef std::tr1::shared_ptr shared_pointer; - typedef std::tr1::shared_ptr const_shared_pointer; -private: - ServerContextImpl(); -public: - static shared_pointer create(); - static shared_pointer create(const Configuration::shared_pointer& conf); - - virtual ~ServerContextImpl(); - - //**************** derived from ServerContext ****************// - const GUID& getGUID(); - const Version& getVersion(); - void initialize(ChannelProviderRegistry::shared_pointer const & channelProviderRegistry); - void run(epics::pvData::int32 seconds); - void shutdown(); - void destroy(); - void printInfo(); - void printInfo(std::ostream& str); - void dispose(); - void setBeaconServerStatusProvider(BeaconServerStatusProvider::shared_pointer const & beaconServerStatusProvider); - //**************** derived from Context ****************// - epics::pvData::Timer::shared_pointer getTimer(); - Channel::shared_pointer getChannel(pvAccessID id); - Transport::shared_pointer getSearchTransport(); - Configuration::shared_pointer getConfiguration(); - TransportRegistry::shared_pointer getTransportRegistry(); - std::map >& getSecurityPlugins(); - - virtual void newServerDetected(); - - - epicsTimeStamp& getStartTime(); - - - /** - * Version. - */ - static const Version VERSION; - - - /** - * Server state enum. - */ - enum State { - /** - * State value of non-initialized context. - */ - NOT_INITIALIZED, - - /** - * State value of initialized context. - */ - INITIALIZED, - - /** - * State value of running context. - */ - RUNNING, - - /** - * State value of shutdown (once running) context. - */ - SHUTDOWN, - - /** - * State value of destroyed context. - */ - DESTROYED - }; - /** - * Names of the enum State - */ - static const char* StateNames[]; - - /** - * Get initialization status. - * @return initialization status. - */ - bool isInitialized(); - - /** - * Get destruction status. - * @return destruction status. - */ - bool isDestroyed(); - - /** - * Get beacon address list. - * @return beacon address list. - */ - std::string getBeaconAddressList(); - - /** - * Get beacon address list auto flag. - * @return beacon address list auto flag. - */ - bool isAutoBeaconAddressList(); - - /** - * Get beacon period (in seconds). - * @return beacon period (in seconds). - */ - float getBeaconPeriod(); - - /** - * Get receiver buffer (payload) size. - * @return max payload size. - */ - epics::pvData::int32 getReceiveBufferSize(); - - /** - * Get server port. - * @return server port. - */ - epics::pvData::int32 getServerPort(); - - /** - * Get broadcast port. - * @return broadcast port. - */ - epics::pvData::int32 getBroadcastPort(); - - /** - * Get ignore search address list. - * @return ignore search address list. - */ - std::string getIgnoreAddressList(); - - /** - * Get registered beacon server status provider. - * @return registered beacon server status provider. - */ - BeaconServerStatusProvider::shared_pointer getBeaconServerStatusProvider(); - - /** - * Get server newtwork (IP) address. - * @return server network (IP) address, NULL if not bounded. - */ - osiSockAddr* getServerInetAddress(); - - /** - * Broadcast (UDP send) transport. - * @return broadcast transport. - */ - BlockingUDPTransport::shared_pointer getBroadcastTransport(); - - /** - * Get channel provider registry implementation used by this instance. - * @return channel provider registry used by this instance. - */ - ChannelProviderRegistry::shared_pointer getChannelProviderRegistry(); - - /** - * Get channel provider name. - * @return channel provider name. - */ - std::string getChannelProviderName(); - - /** - * Set channel provider name. - * This method can only be called before initialize. - */ - void setChannelProviderName(std::string providerName); - - /** - * Get channel providers. - * @return channel providers. - */ - std::vector& getChannelProviders(); - - /** - * Return true if channel provider name is provided by configuration (e.g. system env. var.). - * @return true if channel provider name is provided by configuration (e.g. system env. var.) - */ - bool isChannelProviderNamePreconfigured(); - -private: - - /** - * Server GUID. - */ - GUID _guid; - - /** - * Initialization status. - */ - State _state; - - /** - * A space-separated list of broadcast address which to send beacons. - * Each address must be of the form: ip.number:port or host.name:port - */ - std::string _beaconAddressList; - - /** - * List of used NIF. - */ - IfaceNodeVector _ifaceList; - - osiSockAddr _ifaceAddr; - - /** - * A space-separated list of address from which to ignore name resolution requests. - * Each address must be of the form: ip.number:port or host.name:port - */ - std::string _ignoreAddressList; - - /** - * Define whether or not the network interfaces should be discovered at runtime. - */ - bool _autoBeaconAddressList; - - /** - * Period in second between two beacon signals. - */ - float _beaconPeriod; - - /** - * Broadcast port number to listen to. - */ - epics::pvData::int32 _broadcastPort; - - /** - * Port number for the server to listen to. - */ - epics::pvData::int32 _serverPort; - - /** - * Length in bytes of the maximum buffer (payload) size that may pass through PVA. - */ - epics::pvData::int32 _receiveBufferSize; - - /** - * Timer. - */ - epics::pvData::Timer::shared_pointer _timer; - - /** - * UDP transports needed to receive channel searches. - */ - BlockingUDPTransportVector _udpTransports; - - /** - * UDP socket used to sending. - */ - BlockingUDPTransport::shared_pointer _broadcastTransport; - - /** - * Beacon emitter. - */ - BeaconEmitter::shared_pointer _beaconEmitter; - - /** - * PVAS acceptor (accepts PVA virtual circuit). - */ - BlockingTCPAcceptor::shared_pointer _acceptor; - - /** - * PVA transport (virtual circuit) registry. - * This registry contains all active transports - connections to PVA servers. - */ - TransportRegistry::shared_pointer _transportRegistry; - - /** - * Response handler. - */ - ResponseHandler::shared_pointer _responseHandler; - - /** - * Channel access. - */ - ChannelProviderRegistry::shared_pointer _channelProviderRegistry; - - /** - * Channel provider name. - */ - std::string _channelProviderNames; - - /** - * Channel provider. - */ - std::vector _channelProviders; - - /** - * Run mutex. - */ - epics::pvData::Mutex _mutex; - - /** - * Run event. - */ - epics::pvData::Event _runEvent; - - /** - * Beacon server status provider interface (optional). - */ - BeaconServerStatusProvider::shared_pointer _beaconServerStatusProvider; - - /** - * Generate GUID. - */ - void generateGUID(); - - /** - * Initialize logger. - */ - void initializeLogger(); - - /** - * Load configuration. - */ - void loadConfiguration(); - - /** - * Internal initialization. - */ - void internalInitialize(); - - /** - * Initialize broadcast DP transport (broadcast socket and repeater connection). - */ - void initializeBroadcastTransport(); - - /** - * Internal destroy. - */ - void internalDestroy(); - - /** - * Destroy all transports. - */ - void destroyAllTransports(); - - Configuration::shared_pointer configuration; - - epicsTimeStamp _startTime; - -}; - epicsShareFunc ServerContext::shared_pointer startPVAServer( std::string const & providerNames = PVACCESS_ALL_PROVIDERS, int timeToRun = 0, diff --git a/src/server/pv/serverContextImpl.h b/src/server/pv/serverContextImpl.h new file mode 100644 index 0000000..17ad4d2 --- /dev/null +++ b/src/server/pv/serverContextImpl.h @@ -0,0 +1,358 @@ +#ifndef SERVERCONTEXTIMPL_H +#define SERVERCONTEXTIMPL_H + +#include "serverContext.h" + +namespace epics { +namespace pvAccess { + +class epicsShareClass ServerContextImpl : + public ServerContext, + public Context, + public std::tr1::enable_shared_from_this +{ +public: + typedef std::tr1::shared_ptr shared_pointer; + typedef std::tr1::shared_ptr const_shared_pointer; +private: + ServerContextImpl(); +public: + static shared_pointer create(); + static shared_pointer create(const Configuration::shared_pointer& conf); + + virtual ~ServerContextImpl(); + + //**************** derived from ServerContext ****************// + const GUID& getGUID(); + const Version& getVersion(); + void initialize(ChannelProviderRegistry::shared_pointer const & channelProviderRegistry); + void run(epics::pvData::int32 seconds); + void shutdown(); + void destroy(); + void printInfo(); + void printInfo(std::ostream& str); + void dispose(); + void setBeaconServerStatusProvider(BeaconServerStatusProvider::shared_pointer const & beaconServerStatusProvider); + //**************** derived from Context ****************// + epics::pvData::Timer::shared_pointer getTimer(); + Channel::shared_pointer getChannel(pvAccessID id); + Transport::shared_pointer getSearchTransport(); + Configuration::shared_pointer getConfiguration(); + TransportRegistry::shared_pointer getTransportRegistry(); + std::map >& getSecurityPlugins(); + + virtual void newServerDetected(); + + + epicsTimeStamp& getStartTime(); + + + /** + * Version. + */ + static const Version VERSION; + + + /** + * Server state enum. + */ + enum State { + /** + * State value of non-initialized context. + */ + NOT_INITIALIZED, + + /** + * State value of initialized context. + */ + INITIALIZED, + + /** + * State value of running context. + */ + RUNNING, + + /** + * State value of shutdown (once running) context. + */ + SHUTDOWN, + + /** + * State value of destroyed context. + */ + DESTROYED + }; + /** + * Names of the enum State + */ + static const char* StateNames[]; + + /** + * Get initialization status. + * @return initialization status. + */ + bool isInitialized(); + + /** + * Get destruction status. + * @return destruction status. + */ + bool isDestroyed(); + + /** + * Get beacon address list. + * @return beacon address list. + */ + std::string getBeaconAddressList(); + + /** + * Get beacon address list auto flag. + * @return beacon address list auto flag. + */ + bool isAutoBeaconAddressList(); + + /** + * Get beacon period (in seconds). + * @return beacon period (in seconds). + */ + float getBeaconPeriod(); + + /** + * Get receiver buffer (payload) size. + * @return max payload size. + */ + epics::pvData::int32 getReceiveBufferSize(); + + /** + * Get server port. + * @return server port. + */ + epics::pvData::int32 getServerPort(); + + /** + * Get broadcast port. + * @return broadcast port. + */ + epics::pvData::int32 getBroadcastPort(); + + /** + * Get ignore search address list. + * @return ignore search address list. + */ + std::string getIgnoreAddressList(); + + /** + * Get registered beacon server status provider. + * @return registered beacon server status provider. + */ + BeaconServerStatusProvider::shared_pointer getBeaconServerStatusProvider(); + + /** + * Get server newtwork (IP) address. + * @return server network (IP) address, NULL if not bounded. + */ + osiSockAddr* getServerInetAddress(); + + /** + * Broadcast (UDP send) transport. + * @return broadcast transport. + */ + BlockingUDPTransport::shared_pointer getBroadcastTransport(); + + /** + * Get channel provider registry implementation used by this instance. + * @return channel provider registry used by this instance. + */ + ChannelProviderRegistry::shared_pointer getChannelProviderRegistry(); + + /** + * Get channel provider name. + * @return channel provider name. + */ + std::string getChannelProviderName(); + + /** + * Set channel provider name. + * This method can only be called before initialize. + */ + void setChannelProviderName(std::string providerName); + + /** + * Get channel providers. + * @return channel providers. + */ + std::vector& getChannelProviders(); + + /** + * Return true if channel provider name is provided by configuration (e.g. system env. var.). + * @return true if channel provider name is provided by configuration (e.g. system env. var.) + */ + bool isChannelProviderNamePreconfigured(); + +private: + + /** + * Server GUID. + */ + GUID _guid; + + /** + * Initialization status. + */ + State _state; + + /** + * A space-separated list of broadcast address which to send beacons. + * Each address must be of the form: ip.number:port or host.name:port + */ + std::string _beaconAddressList; + + /** + * List of used NIF. + */ + IfaceNodeVector _ifaceList; + + osiSockAddr _ifaceAddr; + + /** + * A space-separated list of address from which to ignore name resolution requests. + * Each address must be of the form: ip.number:port or host.name:port + */ + std::string _ignoreAddressList; + + /** + * Define whether or not the network interfaces should be discovered at runtime. + */ + bool _autoBeaconAddressList; + + /** + * Period in second between two beacon signals. + */ + float _beaconPeriod; + + /** + * Broadcast port number to listen to. + */ + epics::pvData::int32 _broadcastPort; + + /** + * Port number for the server to listen to. + */ + epics::pvData::int32 _serverPort; + + /** + * Length in bytes of the maximum buffer (payload) size that may pass through PVA. + */ + epics::pvData::int32 _receiveBufferSize; + + /** + * Timer. + */ + epics::pvData::Timer::shared_pointer _timer; + + /** + * UDP transports needed to receive channel searches. + */ + BlockingUDPTransportVector _udpTransports; + + /** + * UDP socket used to sending. + */ + BlockingUDPTransport::shared_pointer _broadcastTransport; + + /** + * Beacon emitter. + */ + BeaconEmitter::shared_pointer _beaconEmitter; + + /** + * PVAS acceptor (accepts PVA virtual circuit). + */ + BlockingTCPAcceptor::shared_pointer _acceptor; + + /** + * PVA transport (virtual circuit) registry. + * This registry contains all active transports - connections to PVA servers. + */ + TransportRegistry::shared_pointer _transportRegistry; + + /** + * Response handler. + */ + ResponseHandler::shared_pointer _responseHandler; + + /** + * Channel access. + */ + ChannelProviderRegistry::shared_pointer _channelProviderRegistry; + + /** + * Channel provider name. + */ + std::string _channelProviderNames; + + /** + * Channel provider. + */ + std::vector _channelProviders; + + /** + * Run mutex. + */ + epics::pvData::Mutex _mutex; + + /** + * Run event. + */ + epics::pvData::Event _runEvent; + + /** + * Beacon server status provider interface (optional). + */ + BeaconServerStatusProvider::shared_pointer _beaconServerStatusProvider; + + /** + * Generate GUID. + */ + void generateGUID(); + + /** + * Initialize logger. + */ + void initializeLogger(); + + /** + * Load configuration. + */ + void loadConfiguration(); + + /** + * Internal initialization. + */ + void internalInitialize(); + + /** + * Initialize broadcast DP transport (broadcast socket and repeater connection). + */ + void initializeBroadcastTransport(); + + /** + * Internal destroy. + */ + void internalDestroy(); + + /** + * Destroy all transports. + */ + void destroyAllTransports(); + + Configuration::shared_pointer configuration; + + epicsTimeStamp _startTime; + +}; + +} +} + +#endif // SERVERCONTEXTIMPL_H diff --git a/testApp/Makefile b/testApp/Makefile index 8b85465..9f9cd10 100644 --- a/testApp/Makefile +++ b/testApp/Makefile @@ -3,6 +3,8 @@ TOP = .. include $(TOP)/configure/CONFIG +USR_CPPFLAGS += -I$(TOP)/src/server/pv + PVACCESS_TEST = $(TOP)/testApp PROD_LIBS += pvAccess pvData $(MBLIB) Com diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 7c7dce1..c191bda 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -9,7 +9,7 @@ // disable buggy boost enable_shared_from_this assert code #define BOOST_DISABLE_ASSERTS -#include +#include #include #include #include diff --git a/testApp/remote/testServerContext.cpp b/testApp/remote/testServerContext.cpp index 697dee3..24332ed 100644 --- a/testApp/remote/testServerContext.cpp +++ b/testApp/remote/testServerContext.cpp @@ -2,7 +2,7 @@ * testServerContext.cpp */ -#include +#include #include using namespace epics::pvAccess;