# HG changeset patch # User Sebastien Jodogne # Date 1680513535 -7200 # Node ID 055428d927721057e4701bd0994c5d973f9fc239 # Parent 19e916dfc767d4954ab82ce0b0f2e5e5d230257b clarifying types of since/limit in IDatabaseWrapper diff -r 19e916dfc767 -r 055428d92772 OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp --- a/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp Mon Apr 03 10:30:15 2023 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp Mon Apr 03 11:18:55 2023 +0200 @@ -565,7 +565,7 @@ std::list* instancesId, const std::vector& lookup, ResourceType queryLevel, - size_t limit) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { if (that_.extensions_.lookupResources == NULL) { @@ -800,8 +800,8 @@ virtual void GetAllPublicIds(std::list& target, ResourceType resourceType, - size_t since, - size_t limit) ORTHANC_OVERRIDE + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { if (that_.extensions_.getAllPublicIdsWithLimit != NULL) { @@ -847,14 +847,14 @@ virtual void GetChanges(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { ResetAnswers(); answerChanges_ = ⌖ answerDone_ = &done; done = false; - CheckSuccess(that_.backend_.getChanges(that_.GetContext(), that_.payload_, since, maxResults)); + CheckSuccess(that_.backend_.getChanges(that_.GetContext(), that_.payload_, since, limit)); } @@ -897,14 +897,14 @@ virtual void GetExportedResources(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { ResetAnswers(); answerExportedResources_ = ⌖ answerDone_ = &done; done = false; - CheckSuccess(that_.backend_.getExportedResources(that_.GetContext(), that_.payload_, since, maxResults)); + CheckSuccess(that_.backend_.getExportedResources(that_.GetContext(), that_.payload_, since, limit)); } diff -r 19e916dfc767 -r 055428d92772 OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp --- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp Mon Apr 03 10:30:15 2023 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp Mon Apr 03 11:18:55 2023 +0200 @@ -388,8 +388,8 @@ virtual void GetAllPublicIds(std::list& target, ResourceType resourceType, - size_t since, - size_t limit) ORTHANC_OVERRIDE + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { CheckSuccess(that_.backend_.getAllPublicIdsWithLimit( transaction_, Plugins::Convert(resourceType), @@ -403,10 +403,10 @@ virtual void GetChanges(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { uint8_t tmpDone = true; - CheckSuccess(that_.backend_.getChanges(transaction_, &tmpDone, since, maxResults)); + CheckSuccess(that_.backend_.getChanges(transaction_, &tmpDone, since, limit)); CheckNoEvent(); done = (tmpDone != 0); @@ -454,10 +454,10 @@ virtual void GetExportedResources(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { uint8_t tmpDone = true; - CheckSuccess(that_.backend_.getExportedResources(transaction_, &tmpDone, since, maxResults)); + CheckSuccess(that_.backend_.getExportedResources(transaction_, &tmpDone, since, limit)); CheckNoEvent(); done = (tmpDone != 0); @@ -797,7 +797,7 @@ std::list* instancesId, // Can be NULL if not needed const std::vector& lookup, ResourceType queryLevel, - size_t limit) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { std::vector constraints; std::vector< std::vector > constraintsValues; diff -r 19e916dfc767 -r 055428d92772 OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp --- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Mon Apr 03 10:30:15 2023 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Mon Apr 03 11:18:55 2023 +0200 @@ -386,8 +386,8 @@ virtual void GetAllPublicIds(std::list& target, ResourceType resourceType, - size_t since, - size_t limit) ORTHANC_OVERRIDE + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { DatabasePluginMessages::TransactionRequest request; request.mutable_get_all_public_ids_with_limits()->set_resource_type(Convert(resourceType)); @@ -408,11 +408,11 @@ virtual void GetChanges(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { DatabasePluginMessages::TransactionRequest request; request.mutable_get_changes()->set_since(since); - request.mutable_get_changes()->set_limit(maxResults); + request.mutable_get_changes()->set_limit(limit); DatabasePluginMessages::TransactionResponse response; ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHANGES, request); @@ -464,11 +464,11 @@ virtual void GetExportedResources(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { DatabasePluginMessages::TransactionRequest request; request.mutable_get_exported_resources()->set_since(since); - request.mutable_get_exported_resources()->set_limit(maxResults); + request.mutable_get_exported_resources()->set_limit(limit); DatabasePluginMessages::TransactionResponse response; ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_EXPORTED_RESOURCES, request); @@ -874,10 +874,8 @@ std::list* instancesId, // Can be NULL if not needed const std::vector& lookup, ResourceType queryLevel, - size_t limit) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { - // TODO => "size_t limit" : uint32_t - DatabasePluginMessages::TransactionRequest request; request.mutable_lookup_resources()->set_query_level(Convert(queryLevel)); request.mutable_lookup_resources()->set_limit(limit); diff -r 19e916dfc767 -r 055428d92772 OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto --- a/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto Mon Apr 03 10:30:15 2023 +0200 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto Mon Apr 03 11:18:55 2023 +0200 @@ -354,7 +354,7 @@ message GetAllPublicIdsWithLimits { message Request { ResourceType resource_type = 1; - uint64 since = 2; + int64 since = 2; uint32 limit = 3; } message Response { diff -r 19e916dfc767 -r 055428d92772 OrthancServer/Sources/Database/IDatabaseWrapper.h --- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Mon Apr 03 10:30:15 2023 +0200 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Mon Apr 03 11:18:55 2023 +0200 @@ -94,13 +94,13 @@ virtual void GetAllPublicIds(std::list& target, ResourceType resourceType, - size_t since, - size_t limit) = 0; + int64_t since, + uint32_t limit) = 0; virtual void GetChanges(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) = 0; + uint32_t limit) = 0; virtual void GetChildrenInternalId(std::list& target, int64_t id) = 0; @@ -111,7 +111,7 @@ virtual void GetExportedResources(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) = 0; + uint32_t limit) = 0; virtual void GetLastChange(std::list& target /*out*/) = 0; @@ -197,7 +197,7 @@ std::list* instancesId, // Can be NULL if not needed const std::vector& lookup, ResourceType queryLevel, - size_t limit) = 0; + uint32_t limit) = 0; // Returns "true" iff. the instance is new and has been inserted // into the database. If "false" is returned, the content of diff -r 19e916dfc767 -r 055428d92772 OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Mon Apr 03 10:30:15 2023 +0200 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Mon Apr 03 11:18:55 2023 +0200 @@ -233,11 +233,11 @@ void GetChangesInternal(std::list& target, bool& done, SQLite::Statement& s, - uint32_t maxResults) + uint32_t limit) { target.clear(); - while (target.size() < maxResults && s.Step()) + while (target.size() < limit && s.Step()) { int64_t seq = s.ColumnInt64(0); ChangeType changeType = static_cast(s.ColumnInt(1)); @@ -250,18 +250,18 @@ target.push_back(ServerIndexChange(seq, changeType, resourceType, publicId, date)); } - done = !(target.size() == maxResults && s.Step()); + done = !(target.size() == limit && s.Step()); } void GetExportedResourcesInternal(std::list& target, bool& done, SQLite::Statement& s, - uint32_t maxResults) + uint32_t limit) { target.clear(); - while (target.size() < maxResults && s.Step()) + while (target.size() < limit && s.Step()) { int64_t seq = s.ColumnInt64(0); ResourceType resourceType = static_cast(s.ColumnInt(1)); @@ -280,7 +280,7 @@ target.push_back(resource); } - done = !(target.size() == maxResults && s.Step()); + done = !(target.size() == limit && s.Step()); } @@ -341,7 +341,7 @@ std::list* instancesId, const std::vector& lookup, ResourceType queryLevel, - size_t limit) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { LookupFormatter formatter; @@ -509,8 +509,8 @@ virtual void GetAllPublicIds(std::list& target, ResourceType resourceType, - size_t since, - size_t limit) ORTHANC_OVERRIDE + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { if (limit == 0) { @@ -536,12 +536,12 @@ virtual void GetChanges(std::list& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes WHERE seq>? ORDER BY seq LIMIT ?"); s.BindInt64(0, since); - s.BindInt(1, maxResults + 1); - GetChangesInternal(target, done, s, maxResults); + s.BindInt(1, limit + 1); + GetChangesInternal(target, done, s, limit); } @@ -588,13 +588,13 @@ virtual void GetExportedResources(std::list& target, bool& done, int64_t since, - uint32_t maxResults) ORTHANC_OVERRIDE + uint32_t limit) ORTHANC_OVERRIDE { SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM ExportedResources WHERE seq>? ORDER BY seq LIMIT ?"); s.BindInt64(0, since); - s.BindInt(1, maxResults + 1); - GetExportedResourcesInternal(target, done, s, maxResults); + s.BindInt(1, limit + 1); + GetExportedResourcesInternal(target, done, s, limit); }