Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edifice deprecations #159

Merged
merged 3 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## Ignition Fuel Tools 5.X to 6.X

### Deprecations

* **Deprecation**: `FuelClient::DeleteModel`
* **Replacement**: `FielClient::DeleteUrl`

* **Deprecation**: `FuelClient` constructor that takes `LocalCache`
* **Replacement**: `FielClient` constructor without `LocalCache`

## Ignition Fuel Tools 4.X to 5.X

### Deprecations

* **Deprecation**: `LocalCache`
* **Replacement**: None

## Ignition Fuel Tools 3.X to 4.X

### Modifications
Expand Down
17 changes: 11 additions & 6 deletions include/ignition/fuel_tools/FuelClient.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ namespace ignition
/// \brief Default constructor.
public: FuelClient();

/// \brief Constructor accepts server and auth configuration
/// \param[in] _config configuration about servers to connect to
/// \param[in] _rest A REST request.
/// \remarks the client saves a copy of the config passed into it
public: FuelClient(const ClientConfig &_config,
const Rest &_rest = Rest());

/// \brief Constructor accepts server and auth configuration
/// \param[in] _config configuration about servers to connect to
/// \param[in] _rest A REST request.
Expand All @@ -62,9 +69,9 @@ namespace ignition
/// destructed. If set to nullptr the client will instantiate
/// it's own cache.
/// \remarks the client saves a copy of the config passed into it
public: FuelClient(const ClientConfig &_config,
const Rest &_rest = Rest(),
LocalCache *_cache = nullptr);
public: IGN_DEPRECATED(6) FuelClient(const ClientConfig &_config,
const Rest &_rest,
LocalCache *_cache);

/// \brief Destructor
public: ~FuelClient();
Expand Down Expand Up @@ -177,9 +184,7 @@ namespace ignition
/// \brief Remove a model from ignition fuel
/// \param[in] _id The model identifier.
/// \return Result of the delete operation
/// Deprecate this function in ign-fuel-tools6. DeleteUrl
/// replaces this function.
public: Result DeleteModel(const ModelIdentifier &_id);
public: Result IGN_DEPRECATED(6) DeleteModel(const ModelIdentifier &_id);

/// \brief Remove a resource, such as a model or world, from Ignition Fuel
/// \param[in] _uri The full URI of the resource, e.g:
Expand Down
29 changes: 17 additions & 12 deletions src/FuelClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,34 +217,31 @@ class ignition::fuel_tools::FuelClientPrivate

//////////////////////////////////////////////////
FuelClient::FuelClient()
: FuelClient(ClientConfig(), Rest(), nullptr)
: FuelClient(ClientConfig(), Rest())
{
}

//////////////////////////////////////////////////
FuelClient::FuelClient(const ClientConfig &_config, const Rest &_rest,
LocalCache *_cache)
: dataPtr(new FuelClientPrivate)
FuelClient::FuelClient(const ClientConfig &_config, const Rest &_rest)
: dataPtr(std::make_unique<FuelClientPrivate>())
{
this->dataPtr->config = _config;
this->dataPtr->rest = _rest;
this->dataPtr->rest.SetUserAgent(this->dataPtr->config.UserAgent());

if (nullptr == _cache)
{
#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#else
# pragma warning(push)
# pragma warning(disable: 4996)
#endif
this->dataPtr->cache.reset(new LocalCache(&(this->dataPtr->config)));
this->dataPtr->cache = std::make_unique<LocalCache>(&(this->dataPtr->config));
#ifndef _WIN32
# pragma GCC diagnostic pop
#else
# pragma warning(pop)
#endif
}
else
{
this->dataPtr->cache.reset(_cache);
}

this->dataPtr->urlModelRegex.reset(new std::regex(
this->dataPtr->kModelUrlRegexStr));
Expand All @@ -258,6 +255,14 @@ FuelClient::FuelClient(const ClientConfig &_config, const Rest &_rest,
this->dataPtr->kCollectionUrlRegexStr));
}

//////////////////////////////////////////////////
FuelClient::FuelClient(const ClientConfig &_config, const Rest &_rest,
LocalCache *_cache) : FuelClient(_config, _rest)
{
if (_cache != nullptr)
this->dataPtr->cache.reset(_cache);
}

//////////////////////////////////////////////////
FuelClient::~FuelClient()
{
Expand Down
7 changes: 7 additions & 0 deletions src/FuelClient_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,14 @@ TEST_F(FuelClientTest, DeleteModelFail)
FuelClient client;
ModelIdentifier modelId;

#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
Result result = client.DeleteModel(modelId);
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif
EXPECT_EQ(ResultType::DELETE_ERROR, result.Type());
}

Expand Down