libcamera/test/list.cpp
Laurent Pinchart 8b0de29c41 libcamera: camera_manager: Make the class a singleton
There can only be a single camera manager instance in the application.
Creating it as a singleton helps avoiding mistakes. It also allows the
camera manager to be used as a storage of global data, such as the
future event dispatcher.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-08 16:23:16 +02:00

49 lines
629 B
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* list.cpp - camera list tests
*/
#include <iostream>
#include <libcamera/camera_manager.h>
#include "test.h"
using namespace std;
using namespace libcamera;
class ListTest : public Test
{
protected:
int init()
{
cm = CameraManager::instance();
cm->start();
return 0;
}
int run()
{
unsigned int count = 0;
for (auto name : cm->list()) {
cout << "- " << name << endl;
count++;
}
return count ? 0 : -ENODEV;
}
void cleanup()
{
cm->stop();
}
private:
CameraManager *cm;
};
TEST_REGISTER(ListTest)