Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-25889

Replace two-step construction with one-step construction (source-incompatible)

    XMLWordPrintable

Details

    • User Story
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • None
    • Sensors
    • None

    Description

      Overview

      The current 2-stage construction is for the benefit of QML and should be removed.

      There should be a factory method that takes whatever information is required (eg. type, driver) and returns a pointer.

      This will be a sub-class of QSensor though the exact details have not been determined yet.

      The class will already be "connected" to a driver. Failure to connect to a driver will result in NULL being returned.

      Creating sensor objects on the heap will not be allowable anymore. Use a scoped pointer for that use-case.

      QAccelerometer *accel = QAcceleroemter::instance(driver);
      

      Implementation Plan

      This should be implemented and unit tested. If the QML C++ classes have already been created, they'll need to be updated.

      Notes

      Using "instance" as the method name will conveniently remove from people's minds the idea that they can have multiple of these. Since we don't really want to support multiple sensors of the same type in an app, this seems like a good side-effect.

      The constructors must be private (or more likely protected, since we want the backend to be a sub-class of the interface class).

      A source-compatible implementation could be done but it would require the use of exceptions or extra code to deal with a "non-functioning sensors object".

      Research Questions

      How can we unit test this?

      How can we document this?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lpotter Lorn Potter
            lramsay Lincoln Ramsay (closed Nokia identity) (Inactive)
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes