6#include "../../internal/Conf.hpp"
10#include "../../entity/SharedEntity.hpp"
11#include "../../internal/Common.hpp"
12#include "../../internal/Id.hpp"
13#include "../../internal/JavaObjectHandle.hpp"
14#include "./InstrumentProfileCollector.hpp"
19
20
21
22
26 using Ptr = std::shared_ptr<InstrumentProfileConnection>;
29 using Unique = std::unique_ptr<InstrumentProfileConnection>;
32
33
36
37
38
42
43
47
48
52
53
57
58
63 Id<InstrumentProfileConnection> id_;
64 JavaObjectHandle<InstrumentProfileConnection> handle_{};
65 JavaObjectHandle<IpfPropertyChangeListener> stateChangeListenerHandle_{};
66 SimpleHandler<
void(State, State)> onStateChange_{};
68 InstrumentProfileConnection()
noexcept;
73 static std::string stateToString(
State state)
noexcept {
76 return "NOT_CONNECTED";
91
92
93
94
95
96
97
98
99
100
101
102
103
107
108
109
110
111
115
116
117
118
119
120
121
122
126
127
128
129
130
131
132
133
139
140
141
142
143
147
148
149
150
151
153 setUpdatePeriod(updatePeriod.count());
157
158
159
160
164
165
166
167
168
172
173
174
175
179
180
181
185
186
187
188
189
190
191
192
193
194 template <
typename StateChangeListener>
202 return onStateChange_ += listener;
206
207
208
209
210
211
213 onStateChange_ -= listenerId;
217
218
219
220
221
223 return onStateChange_;
227
228
229
230
231
232
236
237
238
239
240
241
243 return waitUntilCompleted(timeout.count());
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:31
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:97
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:94
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:30
#define DXFCPP_EXPORT
Definition api.h:35
auto & onStateChange()
Returns the onStateChange handler that can be used to add or remove listeners.
Definition InstrumentProfileConnection.hpp:222
static Ptr createConnection(const StringLike &address, InstrumentProfileCollector::Ptr collector)
Creates instrument profile connection with a specified address and collector.
Definition InstrumentProfileConnection.cpp:61
bool waitUntilCompleted(std::chrono::milliseconds timeout) const
Synchronously waits for full first snapshot read with the specified timeout.
Definition InstrumentProfileConnection.hpp:242
State getState() const
Returns state of this instrument profile connections.
Definition InstrumentProfileConnection.cpp:91
void removeStateChangeListener(std::size_t listenerId)
Removes listener that is notified about changes in state property.
Definition InstrumentProfileConnection.hpp:212
void close() const
Closes this instrument profile connection.
Definition InstrumentProfileConnection.cpp:103
std::int64_t getLastModified() const
Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown.
Definition InstrumentProfileConnection.cpp:95
State
Instrument profile connection state.
Definition InstrumentProfileConnection.hpp:34
@ CLOSED
Instrument profile connection was closed.
Definition InstrumentProfileConnection.hpp:59
@ COMPLETED
Initial instrument profiles snapshot was fully read (this state is set only once).
Definition InstrumentProfileConnection.hpp:54
@ CONNECTING
Connection is being established.
Definition InstrumentProfileConnection.hpp:44
@ CONNECTED
Connection was established.
Definition InstrumentProfileConnection.hpp:49
@ NOT_CONNECTED
Instrument profile connection is not started yet.
Definition InstrumentProfileConnection.hpp:39
std::string getAddress() const
Returns the address of this instrument profile connection.
Definition InstrumentProfileConnection.cpp:79
std::int64_t getUpdatePeriod() const
Returns update period in milliseconds.
Definition InstrumentProfileConnection.cpp:83
void start() const
Starts this instrument profile connection.
Definition InstrumentProfileConnection.cpp:99
void setUpdatePeriod(std::int64_t updatePeriod) const
Changes the update period in milliseconds.
Definition InstrumentProfileConnection.cpp:87
std::size_t addStateChangeListener(StateChangeListener &&listener)
Adds listener that is notified about changes in state property.
Definition InstrumentProfileConnection.hpp:195
void setUpdatePeriod(std::chrono::milliseconds updatePeriod) const
Changes the update period in milliseconds as chrono::duration.
Definition InstrumentProfileConnection.hpp:152
std::chrono::milliseconds getUpdatePeriodAsDuration() const
Returns update period in milliseconds as chrono::duration It is period of an update check when the in...
Definition InstrumentProfileConnection.hpp:134
bool waitUntilCompleted(std::int64_t timeout) const
Synchronously waits for full first snapshot read with the specified timeout.
Definition InstrumentProfileConnection.cpp:107
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:20
A lightweight wrapper around strings or string-like inputs.
Definition StringUtils.hpp:27