30#ifndef INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
31#define INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
36#include <ola/network/TCPSocket.h>
38#include <ola/AutoStart.h>
40#include <ola/client/OlaClient.h>
41#include <ola/io/SelectServer.h>
95 std::auto_ptr<ola::network::TCPSocket> m_socket;
99 std::auto_ptr<CloseCallback> m_close_callback;
101 virtual void CreateClient() = 0;
102 virtual bool StartupClient() = 0;
103 virtual void InitSocket() = 0;
110template <
typename ClientClass>
115 m_auto_start(auto_start) {
122 ClientClass *
GetClient()
const {
return m_client.get(); }
125 std::auto_ptr<ClientClass> m_client;
128 void CreateClient() {
129 if (!m_client.get()) {
130 m_client.reset(
new ClientClass(m_socket.get()));
134 bool StartupClient() {
135 bool ok = m_client->Setup();
136 m_client->SetCloseHandler(
146 m_socket.reset(ola::network::TCPSocket::Connect(
151 if (m_socket.get()) {
152 m_socket->SetNoDelay();
Represents Socket Addresses.
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
The base Client Wrapper class.
Definition ClientWrapper.h:53
bool Cleanup()
Reset the connection to the server.
Definition OlaClientWrapper.cpp:62
ola::io::SelectServer * GetSelectServer()
Get the SelectServer used by this client.
Definition ClientWrapper.h:74
void SetCloseCallback(CloseCallback *callback)
Set the callback to be run when the client socket is closed.
Definition OlaClientWrapper.cpp:39
void SocketClosed()
Called internally when the client socket is closed.
Definition OlaClientWrapper.cpp:70
bool Setup()
Setup the client.
Definition OlaClientWrapper.cpp:43
A templatized ClientWrapper.
Definition ClientWrapper.h:111
ClientClass * GetClient() const
Return the underlying client object.
Definition ClientWrapper.h:122
A single threaded I/O event management system.
Definition SelectServer.h:63
static IPV4Address Loopback()
Returns the loopback address (127.0.0.1).
Definition IPV4Address.cpp:165
An IPv4 SocketAddress.
Definition SocketAddress.h:78
SingleUseCallback0< ReturnType > * NewSingleCallback(ReturnType(*callback)())
A helper function to create a new SingleUseCallback with 0 create-time arguments and 0 execution time...
Definition Callback.h:194
GenericClientWrapper< OlaClient > OlaClientWrapper
A ClientWrapper that uses the OlaClient.
Definition ClientWrapper.h:160
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
static const int OLA_DEFAULT_PORT
The default port which olad listens on for incoming RPC connections.
Definition Constants.h:68