From 4c1371a5c818034b4d7e92058e03b00b8a85061c Mon Sep 17 00:00:00 2001 From: David Hale Date: Mon, 28 Sep 2026 15:17:44 -0700 Subject: [PATCH] server receives its interface, the daemon's child calls create() --- camerad/camera_server.cpp | 7 ++++--- camerad/camera_server.h | 2 +- camerad/camerad.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/camerad/camera_server.cpp b/camerad/camera_server.cpp index 3c7ba49..cdfe941 100644 --- a/camerad/camera_server.cpp +++ b/camerad/camera_server.cpp @@ -12,15 +12,16 @@ namespace Camera { /***** Camera::Server::Server ***********************************************/ /** * @brief Server constructor + * @param[in] interface the interface this Server holds, created by the caller * */ - Server::Server() : + Server::Server(std::unique_ptr interface) : + interface(std::move(interface)), blkport(-1), id_pool(N_THREADS), cmd_num(0) { - interface=Camera::Interface::create(); // factory funcion creates the appropriate interface type - interface->set_server(this); // pointer back to this Server instance + this->interface->set_server(this); // pointer back to this Server instance } /***** Camera::Server::Server ***********************************************/ diff --git a/camerad/camera_server.h b/camerad/camera_server.h index 8f854f9..55b618a 100644 --- a/camerad/camera_server.h +++ b/camerad/camera_server.h @@ -26,7 +26,7 @@ namespace Camera { class Server { public: - Server(); + explicit Server(std::unique_ptr interface); ~Server(); std::unique_ptr interface; diff --git a/camerad/camerad.cpp b/camerad/camerad.cpp index faf2954..75049d0 100644 --- a/camerad/camerad.cpp +++ b/camerad/camerad.cpp @@ -30,9 +30,9 @@ int main( int argc, char** argv ) { } else logwrite(function, "starting"); - // the child process instantiates a Server object + // the child process obtains the interface and gives it to a Server object // - Camera::Server camerad; + Camera::Server camerad( Camera::Interface::create() ); camerad.foreground = foreground; // read the config file and configure the various components