Skip to content

Commit

Permalink
[MDAPI-83][C++] Implement IndexedTxModel
Browse files Browse the repository at this point in the history
TxModelListenerTag -> TxModelListener
  • Loading branch information
AnatolyKalin committed Nov 18, 2024
1 parent bb0b3d7 commit 34fa39d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ JavaObjectHandle<IndexedTxModel::Builder> withSymbol(const JavaObjectHandle<Inde
// dxfg_indexed_tx_model_builder_t* dxfg_IndexedTxModel_Builder_withListener(graal_isolatethread_t* thread,
// dxfg_indexed_tx_model_builder_t* source, dxfg_tx_model_listener_t* listener);
JavaObjectHandle<IndexedTxModel::Builder> withListener(const JavaObjectHandle<IndexedTxModel::Builder> &builder,
const JavaObjectHandle<TxModelListenerTag> &listener);
const JavaObjectHandle<TxModelListener> &listener);

// dxfg_indexed_tx_model_builder_t* dxfg_IndexedTxModel_Builder_withExecutor(graal_isolatethread_t* thread,
// dxfg_indexed_tx_model_builder_t* source, dxfg_executor_t* executor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ JavaObjectHandle<TimeSeriesTxModel::Builder> withSymbol(const JavaObjectHandle<T
// dxfg_time_series_tx_model_builder_t* dxfg_TimeSeriesTxModel_Builder_withListener(graal_isolatethread_t* thread,
// dxfg_time_series_tx_model_builder_t* source, dxfg_tx_model_listener_t* listener);
JavaObjectHandle<TimeSeriesTxModel::Builder> withListener(const JavaObjectHandle<TimeSeriesTxModel::Builder> &builder,
const JavaObjectHandle<TxModelListenerTag> &listener);
const JavaObjectHandle<TxModelListener> &listener);

// dxfg_time_series_tx_model_builder_t* dxfg_TimeSeriesTxModel_Builder_withExecutor(graal_isolatethread_t* thread,
// dxfg_time_series_tx_model_builder_t* source, dxfg_executor_t* executor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace isolated::model::IsolatedTxModelListener {
// typedef void (*dxfg_TxModelListener_function_eventsReceived)(graal_isolatethread_t* thread, dxfg_indexed_event_source_t* source, dxfg_event_type_list* events, int32_t /* boolean */ isSnapshot, void* user_data);

// dxfg_tx_model_listener_t* dxfg_TxModelListener_new(graal_isolatethread_t* thread, dxfg_TxModelListener_function_eventsReceived function_eventsReceived, void* user_data);
JavaObjectHandle<TxModelListenerTag> create(void* functionEventsReceived, void* userData);
JavaObjectHandle<TxModelListener> create(void* functionEventsReceived, void* userData);

}

Expand Down
6 changes: 2 additions & 4 deletions include/dxfeed_graal_cpp_api/model/TxModelListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ DXFCPP_BEGIN_NAMESPACE

class IndexedEventSource;

struct TxModelListenerTag {};

struct DXFCPP_EXPORT TxModelListener : RequireMakeShared<TxModelListener> {
explicit TxModelListener(LockExternalConstructionTag);
~TxModelListener() noexcept override;
Expand All @@ -35,11 +33,11 @@ struct DXFCPP_EXPORT TxModelListener : RequireMakeShared<TxModelListener> {
const std::vector<std::shared_ptr<EventType>> & /* events */, bool /* isSnapshot */)>
onEventsReceived);

const JavaObjectHandle<TxModelListenerTag> &getHandle() const;
const JavaObjectHandle<TxModelListener> &getHandle() const;

private:
mutable std::recursive_mutex mutex_{};
JavaObjectHandle<TxModelListenerTag> handle_;
JavaObjectHandle<TxModelListener> handle_;
SimpleHandler<void(const IndexedEventSource & /* source */,
const std::vector<std::shared_ptr<EventType>> & /* events */, bool /* isSnapshot */)>
onEventsReceived_{};
Expand Down
2 changes: 1 addition & 1 deletion src/internal/JavaObjectHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ template struct JavaObjectHandle<TimePeriod>;

template struct JavaObjectHandle<AuthToken>;

template struct JavaObjectHandle<TxModelListenerTag>;
template struct JavaObjectHandle<TxModelListener>;
template struct JavaObjectHandle<IndexedTxModel>;
template struct JavaObjectHandle<IndexedTxModel::Builder>;
template struct JavaObjectHandle<TimeSeriesTxModel>;
Expand Down
2 changes: 1 addition & 1 deletion src/isolated/model/IsolatedIndexedTxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ JavaObjectHandle<IndexedTxModel::Builder> withSymbol(const JavaObjectHandle<Inde
// dxfg_indexed_tx_model_builder_t* dxfg_IndexedTxModel_Builder_withListener(graal_isolatethread_t* thread,
// dxfg_indexed_tx_model_builder_t* source, dxfg_tx_model_listener_t* listener);
JavaObjectHandle<IndexedTxModel::Builder> withListener(const JavaObjectHandle<IndexedTxModel::Builder> &builder,
const JavaObjectHandle<TxModelListenerTag> &listener) {
const JavaObjectHandle<TxModelListener> &listener) {
if (!builder) {
throw InvalidArgumentException("Unable to execute function `dxfg_IndexedTxModel_Builder_withListener`. The "
"`builder` handle is invalid");
Expand Down
2 changes: 1 addition & 1 deletion src/isolated/model/IsolatedTimeSeriesTxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ JavaObjectHandle<TimeSeriesTxModel::Builder> withSymbol(const JavaObjectHandle<T
// dxfg_time_series_tx_model_builder_t* dxfg_TimeSeriesTxModel_Builder_withListener(graal_isolatethread_t* thread,
// dxfg_time_series_tx_model_builder_t* source, dxfg_tx_model_listener_t* listener);
JavaObjectHandle<TimeSeriesTxModel::Builder> withListener(const JavaObjectHandle<TimeSeriesTxModel::Builder> &builder,
const JavaObjectHandle<TxModelListenerTag> &listener) {
const JavaObjectHandle<TxModelListener> &listener) {
if (!builder) {
throw InvalidArgumentException("Unable to execute function `dxfg_TimeSeriesTxModel_Builder_withListener`. The "
"`builder` handle is invalid");
Expand Down
4 changes: 2 additions & 2 deletions src/isolated/model/IsolatedTxModelListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ namespace isolated::model::IsolatedTxModelListener {

// dxfg_tx_model_listener_t* dxfg_TxModelListener_new(graal_isolatethread_t* thread,
// dxfg_TxModelListener_function_eventsReceived function_eventsReceived, void* user_data);
JavaObjectHandle<TxModelListenerTag> create(void *functionEventsReceived, void *userData) {
JavaObjectHandle<TxModelListener> create(void *functionEventsReceived, void *userData) {
if (!functionEventsReceived) {
throw InvalidArgumentException(
"Unable to execute function `dxfg_TxModelListener_new`. The `functionEventsReceived` is nullptr");
}

return JavaObjectHandle<TxModelListenerTag>{runGraalFunctionAndThrowIfNullptr(
return JavaObjectHandle<TxModelListener>{runGraalFunctionAndThrowIfNullptr(
dxfg_TxModelListener_new,
dxfcpp::bit_cast<dxfg_TxModelListener_function_eventsReceived>(functionEventsReceived), userData)};
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/TxModelListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::shared_ptr<TxModelListener> TxModelListener::create(
return listener;
}

const JavaObjectHandle<TxModelListenerTag> &TxModelListener::getHandle() const {
const JavaObjectHandle<TxModelListener> &TxModelListener::getHandle() const {
std::lock_guard guard{mutex_};

return handle_;
Expand Down

0 comments on commit 34fa39d

Please sign in to comment.