Skip to content

Commit 0d4a732

Browse files
author
Andrei Popescu
authored
Rvalue issue in PrefetchTilesRequest fixed. (#810)
Because of two WithTileKeys overloads using a copy parameter input, and accordingly rvalue reference input, users were not able to move efficiently any TileKey list as it would result in a compilation error due to the ambiguous nature of the two overloads. This is now fixed and users should be able to move efficiently any give vector into the request structure by using WithTileKeys. Relates-To: OLPEDGE-1838 Signed-off-by: Andrei Popescu <andrei.popescu@here.com>
1 parent dfd4c9d commit 0d4a732

File tree

3 files changed

+68
-15
lines changed

3 files changed

+68
-15
lines changed

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/PrefetchTilesRequest.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,20 +66,6 @@ class DATASERVICE_READ_API PrefetchTilesRequest final {
6666
return *this;
6767
}
6868

69-
/**
70-
* @brief Sets the vector of the root tile keys for the request.
71-
*
72-
* @param tile_keys The rvalue reference to the vector with the root tile keys
73-
* of the prefetch.
74-
*
75-
* @return A reference to the updated `PrefetchTilesRequest` instance.
76-
*/
77-
inline PrefetchTilesRequest& WithTileKeys(
78-
std::vector<geo::TileKey>&& tile_keys) {
79-
tile_keys_ = std::move(tile_keys);
80-
return *this;
81-
}
82-
8369
/**
8470
* @brief Gets the minimum tiles level to prefetch.
8571
*

olp-cpp-sdk-dataservice-read/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(OLP_SDK_DATASERVICE_READ_TEST_SOURCES
2323
ParserTest.cpp
2424
PartitionsRepositoryTest.cpp
2525
PrefetchRepositoryTest.cpp
26+
PrefetchTilesRequestTest.cpp
2627
QueryApiTest.cpp
2728
SerializerTest.cpp
2829
StreamApiTest.cpp
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
#include <vector>
21+
22+
#include <gmock/gmock.h>
23+
#include <olp/core/geo/tiling/TileKey.h>
24+
#include <olp/dataservice/read/PrefetchTilesRequest.h>
25+
26+
using namespace ::testing;
27+
using namespace olp::geo;
28+
using namespace olp::dataservice::read;
29+
using TileKeys = std::vector<TileKey>;
30+
31+
namespace {
32+
33+
TEST(PrefetchTilesRequestTest, TileKeys) {
34+
{
35+
SCOPED_TRACE("lvalue test");
36+
37+
PrefetchTilesRequest request;
38+
const TileKeys expected_tiles = {TileKey::FromHereTile("1234"),
39+
TileKey::FromHereTile("12345")};
40+
41+
request.WithTileKeys(expected_tiles);
42+
43+
EXPECT_EQ(expected_tiles, request.GetTileKeys());
44+
}
45+
{
46+
SCOPED_TRACE("rvalue test");
47+
48+
PrefetchTilesRequest request;
49+
const TileKeys expected_tiles = {TileKey::FromHereTile("1234"),
50+
TileKey::FromHereTile("12345")};
51+
const TileKeys expected_tiles2 = {TileKey::FromHereTile("12346"),
52+
TileKey::FromHereTile("123456")};
53+
54+
auto tile_keys = expected_tiles;
55+
request.WithTileKeys(std::move(tile_keys));
56+
57+
EXPECT_EQ(expected_tiles, request.GetTileKeys());
58+
59+
request.WithTileKeys(
60+
{TileKey::FromHereTile("12346"), TileKey::FromHereTile("123456")});
61+
62+
EXPECT_EQ(expected_tiles2, request.GetTileKeys());
63+
}
64+
}
65+
66+
} // namespace

0 commit comments

Comments
 (0)