Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-2009

Please add cbegin and cend to afw tables

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: afw
    • Labels:
      None
    • Story Points:
      2
    • Sprint:
      DRP S17-5, DRP S17-6
    • Team:
      Data Release Production

      Description

      It would be helpful if afw tables had the C++11 iterator methods cbegin and cend that return iterators-to-const.

        Attachments

          Activity

          Hide
          pgee Perry Gee added a comment -

          @jbosch, I could use your guidance here.

          This ticket asks for cbegin, cend on tables, but I am assuming that it really wants such on catalogs. Is that the case?

          If so, Catalog already has begin, end which return both iterators and const_iterators. However,
          since the _internal of the Catalog is a std::vector<Ptr(RecordT)>, its const_iterators only protect the pointer, not the contents of the pointer.

          This ticket wants the latter, which I think means that we need a different kind of const_iterator which points at the RecordT itself. I can write such an iterator, but this all seems like a rather odd design – to have two types of iterators on the same object. Suggestions?

          Show
          pgee Perry Gee added a comment - @jbosch, I could use your guidance here. This ticket asks for cbegin, cend on tables, but I am assuming that it really wants such on catalogs. Is that the case? If so, Catalog already has begin, end which return both iterators and const_iterators. However, since the _internal of the Catalog is a std::vector<Ptr(RecordT)>, its const_iterators only protect the pointer, not the contents of the pointer. This ticket wants the latter, which I think means that we need a different kind of const_iterator which points at the RecordT itself. I can write such an iterator, but this all seems like a rather odd design – to have two types of iterators on the same object. Suggestions?
          Hide
          pgee Perry Gee added a comment -

          Russell Owen Since you put this in, perhaps you could save how you would like it to work. I could build an interator which casts the internal pointer, perhaps.

          Show
          pgee Perry Gee added a comment - Russell Owen Since you put this in, perhaps you could save how you would like it to work. I could build an interator which casts the internal pointer, perhaps.
          Hide
          jbosch Jim Bosch added a comment -

          You're right that CatalogT::const_iterator doesn't behave like a regular const iterator, but that behavior is consistent with a lot of other aspects of CatalogT: the records returned are always const if the record template parameter is const and are not const otherwise. Because CatalogT's copy constructor is shallow I think that is the only sensible behavior.

          So for this ticket, I think we just want to make it return the same const_iterator that is already defined. I'm fairly certain Russell Owen's request is just to allow CatalogT to be used on C++11 algorithms that expect cbegin, cend, and he won't care how const the iterators actually are. (If that's not the case, I don't think we can implement this ticket at all).

          Show
          jbosch Jim Bosch added a comment - You're right that CatalogT::const_iterator doesn't behave like a regular const iterator, but that behavior is consistent with a lot of other aspects of CatalogT : the records returned are always const if the record template parameter is const and are not const otherwise. Because CatalogT 's copy constructor is shallow I think that is the only sensible behavior. So for this ticket, I think we just want to make it return the same const_iterator that is already defined. I'm fairly certain Russell Owen 's request is just to allow CatalogT to be used on C++11 algorithms that expect cbegin , cend , and he won't care how const the iterators actually are. (If that's not the case, I don't think we can implement this ticket at all).
          Hide
          rowen Russell Owen added a comment -

          Jim Bosch exactly!

          Show
          rowen Russell Owen added a comment - Jim Bosch exactly!
          Hide
          pgee Perry Gee added a comment -

          OK, so I'm done!

          Show
          pgee Perry Gee added a comment - OK, so I'm done!
          Hide
          pgee Perry Gee added a comment -

          As requested, Catalogs now have a const_iterator cbegin and cend which just call const_iterator begin and end

          Show
          pgee Perry Gee added a comment - As requested, Catalogs now have a const_iterator cbegin and cend which just call const_iterator begin and end
          Hide
          rowen Russell Owen added a comment -

          Looks good.

          Show
          rowen Russell Owen added a comment - Looks good.

            People

            Assignee:
            pgee Perry Gee
            Reporter:
            rowen Russell Owen
            Reviewers:
            Russell Owen
            Watchers:
            Jim Bosch, John Swinbank, Perry Gee, Russell Owen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins Builds

                No builds found.