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

FuelClient support range-based for-loops #42

Open
osrf-migration opened this issue Mar 5, 2018 · 0 comments
Open

FuelClient support range-based for-loops #42

osrf-migration opened this issue Mar 5, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@osrf-migration
Copy link

Original report (archived issue) by Shane Loretz (Bitbucket: Shane Loretz, GitHub: sloretz).


Currently FuelClient::Models(...) returns an instance ModelIter. Iterating over all models looks like

auto iter = client.Models(server);
for (; iter; ++iter)
{
  Model & model = *iter;
  // ...
}

It would be more convenient to use range based for loops

for (Model & model : client.Models(server))
{
  // ...
}

This can be done by making a function return an object with special methods begin() and end() where begin returns what FuelClient::Models(...) returns now, and end returns an iterator that compares inequal to a valid iterator.

class Models
{
    /// \brief special method to support range-based for-loops; must be lowercase
   public: ModelIter begin();

    /// \brief special method to support range-based for-loops; must be lowercase
   public: ModelIter end();
}

Since fuel-tools has already been released and a function's return type is not part of its signature, tick-tocking this requires changing the name of the function on FuelClient.

     /// old and busted
     public: IGN_DEPRECATED(2) ModelIter Models(const ServerConfig &_server);

     /// new hotness
     public: Models QueryModels(const ServerConfig &_server);
@osrf-migration osrf-migration added minor enhancement New feature or request labels Apr 15, 2020
@chapulina chapulina removed the minor label May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants