libcamera: camera: Move private data members to private implementation

Use the d-pointer idiom ([1], [2]) to hide the private data members from
the Camera class interface. This will ease maintaining ABI
compatibility, and prepares for the implementation of the Camera class
threading model.

The FrameBufferAllocator class accesses the Camera private data members
directly. In order to hide them, this pattern is replaced with new
private member functions in the Camera class, and the
FrameBufferAllocator is updated accordingly.

[1] https://wiki.qt.io/D-Pointer
[2] https://en.cppreference.com/w/cpp/language/pimpl

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart 2020-01-19 21:42:09 +02:00
parent a0295fdaf8
commit a4be7bb5ff
3 changed files with 161 additions and 134 deletions

View file

@ -98,34 +98,22 @@ public:
int stop();
private:
enum State {
CameraAvailable,
CameraAcquired,
CameraConfigured,
CameraRunning,
};
Camera(PipelineHandler *pipe, const std::string &name);
Camera(PipelineHandler *pipe, const std::string &name,
const std::set<Stream *> &streams);
~Camera();
bool stateBetween(State low, State high) const;
bool stateIs(State state) const;
class Private;
std::unique_ptr<Private> p_;
friend class PipelineHandler;
void disconnect();
void requestComplete(Request *request);
std::shared_ptr<PipelineHandler> pipe_;
std::string name_;
std::set<Stream *> streams_;
std::set<Stream *> activeStreams_;
bool disconnected_;
State state_;
/* Needed to update allocator_ and to read state_ and activeStreams_. */
friend class FrameBufferAllocator;
int exportFrameBuffers(Stream *stream,
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
int freeFrameBuffers(Stream *stream);
/* \todo Remove allocator_ from the exposed API */
FrameBufferAllocator *allocator_;
};