• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpenLightingProject / ola / 20179851591

12 Dec 2025 09:05PM UTC coverage: 45.048% (-0.7%) from 45.72%
20179851591

Pull #2027

github

web-flow
Bump actions/upload-artifact from 4 to 6

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #2027: Bump actions/upload-artifact from 4 to 6

8554 of 19812 branches covered (43.18%)

22094 of 49046 relevant lines covered (45.05%)

50.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.09
/include/ola/client/ClientWrapper.h
1
/*
2
 * This library is free software; you can redistribute it and/or
3
 * modify it under the terms of the GNU Lesser General Public
4
 * License as published by the Free Software Foundation; either
5
 * version 2.1 of the License, or (at your option) any later version.
6
 *
7
 * This library is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10
 * Lesser General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU Lesser General Public
13
 * License along with this library; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
 *
16
 * ClientWrapper.h
17
 * This provides a helpful wrapper for the OlaClient & OlaCallbackClient
18
 * classes.
19
 * Copyright (C) 2005 Simon Newton
20
 *
21
 * The OlaClientWrapper classes takes care of setting up the socket, select
22
 * server and client for you.
23
 */
24

25
/**
26
 * @file ClientWrapper.h
27
 * @brief Helper classes for managing OLA clients.
28
 */
29

30
#ifndef INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
31
#define INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
32

33
// On MinGW, SocketAddress.h pulls in WinSock2.h, which needs to be after
34
// WinSock2.h, hence this order
35
#include <ola/network/SocketAddress.h>
36
#include <ola/network/TCPSocket.h>
37

38
#include <ola/AutoStart.h>
39
#include <ola/Callback.h>
40
#include <ola/client/OlaClient.h>
41
#include <ola/io/SelectServer.h>
42

43
#include <memory>
44

45
namespace ola {
46
namespace client {
47

48
/**
49
 * @brief The base Client Wrapper class.
50
 *
51
 * This encapsulates the calls required to setup a connection to olad.
52
 */
53
class BaseClientWrapper {
54
 public:
55
  typedef Callback0<void> CloseCallback;
56

57
  BaseClientWrapper();
58
  virtual ~BaseClientWrapper();
59

60
  /**
61
   * @brief Set the callback to be run when the client socket is closed.
62
   *
63
   * The default action is to terminate the SelectServer. By setting a callback
64
   * you can override this behavior.
65
   *
66
   * @param callback the Callback to run, ownership is transferred.
67
   */
68
  void SetCloseCallback(CloseCallback *callback);
69

70
  /**
71
   * @brief Get the SelectServer used by this client.
72
   * @returns A pointer to a SelectServer, ownership isn't transferred.
73
   */
74
  ola::io::SelectServer *GetSelectServer() { return &m_ss; }
×
75

76
  /**
77
   * @brief Setup the client.
78
   * @returns true on success, false on failure.
79
   */
80
  bool Setup();
81

82
  /**
83
   * @brief Reset the connection to the server.
84
   * @returns true if the reset succeeded, false otherwise.
85
   */
86
  bool Cleanup();
87

88
  /**
89
   * @brief Called internally when the client socket is closed.
90
   * @internal
91
   */
92
  void SocketClosed();
93

94
 protected:
95
  std::auto_ptr<ola::network::TCPSocket> m_socket;
96

97
 private:
98
  ola::io::SelectServer m_ss;
99
  std::auto_ptr<CloseCallback> m_close_callback;
100

101
  virtual void CreateClient() = 0;
102
  virtual bool StartupClient() = 0;
103
  virtual void InitSocket() = 0;
104
};
105

106

107
/**
108
 * @brief A templatized ClientWrapper.
109
 */
110
template <typename ClientClass>
111
class GenericClientWrapper: public BaseClientWrapper {
112
 public:
113
  explicit GenericClientWrapper(bool auto_start = true):
6✔
114
      BaseClientWrapper(),
115
      m_auto_start(auto_start) {
6✔
116
  }
117
  ~GenericClientWrapper() {}
×
118

119
  /**
120
   * @brief Return the underlying client object
121
   */
122
  ClientClass *GetClient() const { return m_client.get(); }
×
123

124
 private:
125
  std::auto_ptr<ClientClass> m_client;
126
  bool m_auto_start;
127

128
  void CreateClient() {
×
129
    if (!m_client.get()) {
×
130
      m_client.reset(new ClientClass(m_socket.get()));
×
131
    }
132
  }
×
133

134
  bool StartupClient() {
×
135
    bool ok = m_client->Setup();
×
136
    m_client->SetCloseHandler(
×
137
      ola::NewSingleCallback(static_cast<BaseClientWrapper*>(this),
138
                             &BaseClientWrapper::SocketClosed));
139
    return ok;
×
140
  }
141

142
  void InitSocket() {
×
143
    if (m_auto_start) {
×
144
      m_socket.reset(ola::client::ConnectToServer(OLA_DEFAULT_PORT));
×
145
    } else {
146
      m_socket.reset(ola::network::TCPSocket::Connect(
×
147
          ola::network::IPV4SocketAddress(
×
148
            ola::network::IPV4Address::Loopback(),
×
149
           OLA_DEFAULT_PORT)));
150
    }
151
    if (m_socket.get()) {
×
152
      m_socket->SetNoDelay();
×
153
    }
154
  }
×
155
};
156

157
/**
158
 * @brief A ClientWrapper that uses the OlaClient.
159
 */
160
typedef GenericClientWrapper<OlaClient> OlaClientWrapper;
161

162
}  // namespace client
163
}  // namespace ola
164
#endif  // INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc