Skip to content

Commit 902f7d4

Browse files
committed
Use StatusWrapper with late status
1 parent 4261ffe commit 902f7d4

15 files changed

Lines changed: 39 additions & 90 deletions

src/fb-cpp/Attachment.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ Attachment::Attachment(Client& client, const std::string& uri, const AttachmentO
3535
{
3636
const auto master = client.getMaster();
3737

38-
const auto status = client.newStatus();
39-
StatusWrapper statusWrapper{client, status.get()};
38+
StatusWrapper statusWrapper{client};
4039

4140
auto dpbBuilder = fbUnique(master->getUtilInterface()->getXpbBuilder(&statusWrapper, fb::IXpbBuilder::DPB,
4241
reinterpret_cast<const std::uint8_t*>(options.getDpb().data()),
@@ -74,8 +73,7 @@ void Attachment::disconnectOrDrop(bool drop)
7473
{
7574
assert(isValid());
7675

77-
const auto status = client->newStatus();
78-
StatusWrapper statusWrapper{*client, status.get()};
76+
StatusWrapper statusWrapper{*client};
7977

8078
if (drop)
8179
handle->dropDatabase(&statusWrapper);

src/fb-cpp/Batch.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ using namespace fbcpp::impl;
3636

3737
BatchCompletionState::BatchCompletionState(Client& client, FbUniquePtr<fb::IBatchCompletionState> handle) noexcept
3838
: client{&client},
39-
status{client.newStatus()},
40-
statusWrapper{client, status.get()},
39+
statusWrapper{client},
4140
handle{std::move(handle)}
4241
{
4342
}
4443

4544
BatchCompletionState::BatchCompletionState(BatchCompletionState&& o) noexcept
4645
: client{o.client},
47-
status{std::move(o.status)},
4846
statusWrapper{std::move(o.statusWrapper)},
4947
handle{std::move(o.handle)}
5048
{
@@ -102,8 +100,7 @@ Batch::Batch(Statement& statement, Transaction& transaction, const BatchOptions&
102100
: client{&statement.getAttachment().getClient()},
103101
transaction{&transaction},
104102
statement{&statement},
105-
status{client->newStatus()},
106-
statusWrapper{*client, status.get()}
103+
statusWrapper{*client}
107104
{
108105
assert(statement.isValid());
109106
assert(transaction.isValid());
@@ -118,8 +115,7 @@ Batch::Batch(Attachment& attachment, Transaction& transaction, std::string_view
118115
const BatchOptions& options)
119116
: client{&attachment.getClient()},
120117
transaction{&transaction},
121-
status{client->newStatus()},
122-
statusWrapper{*client, status.get()}
118+
statusWrapper{*client}
123119
{
124120
assert(attachment.isValid());
125121
assert(transaction.isValid());
@@ -135,7 +131,6 @@ Batch::Batch(Batch&& o) noexcept
135131
: client{o.client},
136132
transaction{o.transaction},
137133
statement{o.statement},
138-
status{std::move(o.status)},
139134
statusWrapper{std::move(o.statusWrapper)},
140135
handle{std::move(o.handle)}
141136
{

src/fb-cpp/Batch.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ namespace fbcpp
250250

251251
private:
252252
Client* client;
253-
FbUniquePtr<fb::IStatus> status;
254253
impl::StatusWrapper statusWrapper;
255254
FbUniquePtr<fb::IBatchCompletionState> handle;
256255
};
@@ -447,7 +446,6 @@ namespace fbcpp
447446
Client* client;
448447
Transaction* transaction;
449448
Statement* statement = nullptr;
450-
FbUniquePtr<fb::IStatus> status;
451449
impl::StatusWrapper statusWrapper;
452450
FbRef<fb::IBatch> handle;
453451
std::vector<Descriptor> inputDescriptors;

src/fb-cpp/Blob.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ using namespace fbcpp::impl;
3838
Blob::Blob(Attachment& attachment, Transaction& transaction, const BlobOptions& options)
3939
: attachment{attachment},
4040
transaction{transaction},
41-
status{attachment.getClient().newStatus()},
42-
statusWrapper{attachment.getClient(), status.get()}
41+
statusWrapper{attachment.getClient()}
4342
{
4443
assert(attachment.isValid());
4544
assert(transaction.isValid());
@@ -54,8 +53,7 @@ Blob::Blob(Attachment& attachment, Transaction& transaction, const BlobId& blobI
5453
: attachment{attachment},
5554
transaction{transaction},
5655
id{blobId},
57-
status{attachment.getClient().newStatus()},
58-
statusWrapper{attachment.getClient(), status.get()}
56+
statusWrapper{attachment.getClient()}
5957
{
6058
assert(attachment.isValid());
6159
assert(transaction.isValid());

src/fb-cpp/Blob.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ namespace fbcpp
284284
: attachment{o.attachment},
285285
transaction{o.transaction},
286286
id{o.id},
287-
status{std::move(o.status)},
288287
statusWrapper{std::move(o.statusWrapper)},
289288
handle{std::move(o.handle)}
290289
{
@@ -427,7 +426,6 @@ namespace fbcpp
427426
Attachment& attachment;
428427
Transaction& transaction;
429428
BlobId id;
430-
FbUniquePtr<fb::IStatus> status;
431429
impl::StatusWrapper statusWrapper;
432430
FbRef<fb::IBlob> handle;
433431
};

src/fb-cpp/Client.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ void Client::shutdown()
3535
assert(isValid());
3636

3737
auto dispatcher = fbRef(master->getDispatcher());
38-
const auto status = newStatus();
39-
StatusWrapper statusWrapper{*this, status.get()};
38+
StatusWrapper statusWrapper{*this};
4039

4140
dispatcher->shutdown(&statusWrapper, 0, fb_shutrsn_app_stopped);
4241

src/fb-cpp/EventListener.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ EventListener::EventListener(Attachment& attachment, const std::vector<std::stri
104104
listening = true;
105105
running = true;
106106

107-
const auto status = client.newStatus();
108-
StatusWrapper statusWrapper{client, status.get()};
107+
StatusWrapper statusWrapper{client};
109108

110109
eventsHandle.reset(attachment.getHandle()->queEvents(
111110
&statusWrapper, &firebirdCallback, static_cast<unsigned>(eventBuffer.size()), eventBuffer.data()));
@@ -249,8 +248,7 @@ void EventListener::handleEvent(unsigned length, const std::uint8_t* events)
249248
return;
250249
}
251250

252-
const auto status = client.newStatus();
253-
StatusWrapper statusWrapper{client, status.get()};
251+
StatusWrapper statusWrapper{client};
254252
FbRef<fb::IEvents> newHandle;
255253

256254
try
@@ -351,8 +349,7 @@ void EventListener::cancelEventsHandle()
351349
if (!handle)
352350
return;
353351

354-
const auto status = client.newStatus();
355-
StatusWrapper statusWrapper{client, status.get()};
352+
StatusWrapper statusWrapper{client};
356353

357354
handle->cancel(&statusWrapper);
358355
}

src/fb-cpp/RowSet.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ using namespace fbcpp::impl;
3131

3232

3333
RowSet::RowSet(Statement& statement, unsigned maxRows)
34-
: status{statement.getAttachment().getClient().newStatus()},
35-
statusWrapper{statement.getAttachment().getClient(), status.get()},
34+
: statusWrapper{statement.getAttachment().getClient()},
3635
numericConverter{statement.getAttachment().getClient(), &statusWrapper},
3736
calendarConverter{statement.getAttachment().getClient(), &statusWrapper}
3837
{

src/fb-cpp/RowSet.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ namespace fbcpp
7474
messageLength{o.messageLength},
7575
buffer{std::move(o.buffer)},
7676
descriptors{std::move(o.descriptors)},
77-
status{std::move(o.status)},
7877
statusWrapper{std::move(o.statusWrapper)},
7978
numericConverter{std::move(o.numericConverter)},
8079
calendarConverter{std::move(o.calendarConverter)}
@@ -91,7 +90,6 @@ namespace fbcpp
9190
messageLength = o.messageLength;
9291
buffer = std::move(o.buffer);
9392
descriptors = std::move(o.descriptors);
94-
status = std::move(o.status);
9593
statusWrapper = std::move(o.statusWrapper);
9694
numericConverter = std::move(o.numericConverter);
9795
calendarConverter = std::move(o.calendarConverter);
@@ -157,7 +155,6 @@ namespace fbcpp
157155
unsigned messageLength = 0;
158156
std::vector<std::byte> buffer;
159157
std::vector<Descriptor> descriptors;
160-
FbUniquePtr<Firebird::IStatus> status;
161158
impl::StatusWrapper statusWrapper;
162159
impl::NumericConverter numericConverter;
163160
impl::CalendarConverter calendarConverter;

src/fb-cpp/Statement.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ using namespace fbcpp::impl;
3434
Statement::Statement(
3535
Attachment& attachment, Transaction& transaction, std::string_view sql, const StatementOptions& options)
3636
: attachment{&attachment},
37-
status{attachment.getClient().newStatus()},
38-
statusWrapper{attachment.getClient(), status.get()},
37+
statusWrapper{attachment.getClient()},
3938
calendarConverter{attachment.getClient(), &statusWrapper},
4039
numericConverter{attachment.getClient(), &statusWrapper}
4140
{

0 commit comments

Comments
 (0)