Message ID | 20200902130846.55910-2-jacopo@jmondi.org |
---|---|
State | Superseded, archived |
Delegated to: | Jacopo Mondi |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, On 02/09/2020 14:08, Jacopo Mondi wrote: > When adding a new StreamConfiguration to a CameraConfiguration instance > it might be useful to know how what is the index of the newly added item > to be able to retrieve it later. > > Return the index of the newly inserted item, which corresponds to the > 0-indexed number of items in the CameraConfiguration::config_ vector, > from CameraConfiguration::addConfiguration(). > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> From the department of "doh - why didn't I think of this, while I was struggling with this code": (I tried/failed returning the added cfg rather than the index ...) Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > include/libcamera/camera.h | 2 +- > src/libcamera/camera.cpp | 5 ++++- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h > index 272c12c3c473..53c32afa23a5 100644 > --- a/include/libcamera/camera.h > +++ b/include/libcamera/camera.h > @@ -39,7 +39,7 @@ public: > > virtual ~CameraConfiguration(); > > - void addConfiguration(const StreamConfiguration &cfg); > + int addConfiguration(const StreamConfiguration &cfg); > virtual Status validate() = 0; > > StreamConfiguration &at(unsigned int index); > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp > index 4a9c19c33cfb..9a8923620e24 100644 > --- a/src/libcamera/camera.cpp > +++ b/src/libcamera/camera.cpp > @@ -104,10 +104,13 @@ CameraConfiguration::~CameraConfiguration() > /** > * \brief Add a stream configuration to the camera configuration > * \param[in] cfg The stream configuration > + * \return The index of the newly added stream configuration > */ > -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) > +int CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) > { > config_.push_back(cfg); > + > + return config_.size() - 1; > } > > /** >
Hi Jacopo, Thanks for your work. On 2020-09-02 15:08:40 +0200, Jacopo Mondi wrote: > When adding a new StreamConfiguration to a CameraConfiguration instance > it might be useful to know how what is the index of the newly added item > to be able to retrieve it later. > > Return the index of the newly inserted item, which corresponds to the > 0-indexed number of items in the CameraConfiguration::config_ vector, > from CameraConfiguration::addConfiguration(). > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > include/libcamera/camera.h | 2 +- > src/libcamera/camera.cpp | 5 ++++- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h > index 272c12c3c473..53c32afa23a5 100644 > --- a/include/libcamera/camera.h > +++ b/include/libcamera/camera.h > @@ -39,7 +39,7 @@ public: > > virtual ~CameraConfiguration(); > > - void addConfiguration(const StreamConfiguration &cfg); > + int addConfiguration(const StreamConfiguration &cfg); > virtual Status validate() = 0; > > StreamConfiguration &at(unsigned int index); > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp > index 4a9c19c33cfb..9a8923620e24 100644 > --- a/src/libcamera/camera.cpp > +++ b/src/libcamera/camera.cpp > @@ -104,10 +104,13 @@ CameraConfiguration::~CameraConfiguration() > /** > * \brief Add a stream configuration to the camera configuration > * \param[in] cfg The stream configuration > + * \return The index of the newly added stream configuration > */ > -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) > +int CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) > { > config_.push_back(cfg); > + > + return config_.size() - 1; > } > > /** > -- > 2.28.0 > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 272c12c3c473..53c32afa23a5 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -39,7 +39,7 @@ public: virtual ~CameraConfiguration(); - void addConfiguration(const StreamConfiguration &cfg); + int addConfiguration(const StreamConfiguration &cfg); virtual Status validate() = 0; StreamConfiguration &at(unsigned int index); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 4a9c19c33cfb..9a8923620e24 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -104,10 +104,13 @@ CameraConfiguration::~CameraConfiguration() /** * \brief Add a stream configuration to the camera configuration * \param[in] cfg The stream configuration + * \return The index of the newly added stream configuration */ -void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) +int CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) { config_.push_back(cfg); + + return config_.size() - 1; } /**
When adding a new StreamConfiguration to a CameraConfiguration instance it might be useful to know how what is the index of the newly added item to be able to retrieve it later. Return the index of the newly inserted item, which corresponds to the 0-indexed number of items in the CameraConfiguration::config_ vector, from CameraConfiguration::addConfiguration(). Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- include/libcamera/camera.h | 2 +- src/libcamera/camera.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)