Message ID | 20191012184407.31684-7-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your work. On 2019-10-12 21:43:59 +0300, Laurent Pinchart wrote: > The ControlId class stores a pointer to the control name. This works > fine for statically-defined controls, but requires code that allocates > controls dynamically (for instance based on control discovery on a V4L2 > device) to keep a list of control names in separate storage. To ease > usage of dynamically allocated controls, store a copy of the control > name string in the ControlId class. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > include/libcamera/controls.h | 6 +++--- > src/libcamera/controls.cpp | 2 +- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h > index 12a13aacb198..999fcf7a3a62 100644 > --- a/include/libcamera/controls.h > +++ b/include/libcamera/controls.h > @@ -60,11 +60,11 @@ class ControlId > { > public: > unsigned int id() const { return id_; } > - const char *name() const { return name_; } > + const std::string &name() const { return name_; } > ControlType type() const { return type_; } > > protected: > - ControlId(unsigned int id, const char *name, ControlType type) > + ControlId(unsigned int id, const std::string &name, ControlType type) > : id_(id), name_(name), type_(type) > { > } > @@ -74,7 +74,7 @@ private: > ControlId &operator=(const ControlId &) = delete; > > unsigned int id_; > - const char *name_; > + std::string name_; > ControlType type_; > }; > > diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp > index bfab177fc508..292e48cd6d25 100644 > --- a/src/libcamera/controls.cpp > +++ b/src/libcamera/controls.cpp > @@ -232,7 +232,7 @@ bool ControlValue::operator==(const ControlValue &other) const > */ > > /** > - * \fn ControlId::ControlId(unsigned int id, const char *name, ControlType type) > + * \fn ControlId::ControlId(unsigned int id, const std::string &name, ControlType type) > * \brief Construct a ControlId instance > * \param[in] id The control numerical ID > * \param[in] name The control name > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 12a13aacb198..999fcf7a3a62 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -60,11 +60,11 @@ class ControlId { public: unsigned int id() const { return id_; } - const char *name() const { return name_; } + const std::string &name() const { return name_; } ControlType type() const { return type_; } protected: - ControlId(unsigned int id, const char *name, ControlType type) + ControlId(unsigned int id, const std::string &name, ControlType type) : id_(id), name_(name), type_(type) { } @@ -74,7 +74,7 @@ private: ControlId &operator=(const ControlId &) = delete; unsigned int id_; - const char *name_; + std::string name_; ControlType type_; }; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index bfab177fc508..292e48cd6d25 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -232,7 +232,7 @@ bool ControlValue::operator==(const ControlValue &other) const */ /** - * \fn ControlId::ControlId(unsigned int id, const char *name, ControlType type) + * \fn ControlId::ControlId(unsigned int id, const std::string &name, ControlType type) * \brief Construct a ControlId instance * \param[in] id The control numerical ID * \param[in] name The control name