libcamera: device_enumerator: add factory for DeviceEnumerators
Provide a factory for DeviceEnumerator objects. Depending on which libraries are available there will be different ways to enumerate information in the system. This factory hides this from the rest of the library. Currently udev enumeration is the only supported implementation, a sysfs implementation is another method that surely will be added in the future. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
4db38e82a3
commit
06e2ac2e2f
2 changed files with 21 additions and 0 deletions
|
@ -121,6 +121,25 @@ bool DeviceMatch::match(const DeviceInfo *info) const
|
|||
* Enumerator Base
|
||||
*/
|
||||
|
||||
DeviceEnumerator *DeviceEnumerator::create()
|
||||
{
|
||||
DeviceEnumerator *enumerator;
|
||||
|
||||
/* TODO: add compile time checks to only try udev enumerator if libudev is available */
|
||||
enumerator = new DeviceEnumeratorUdev();
|
||||
if (!enumerator->init())
|
||||
return enumerator;
|
||||
|
||||
/*
|
||||
* NOTE: Either udev is not available or initialization of it
|
||||
* failed, use/fallback on sysfs enumerator
|
||||
*/
|
||||
|
||||
/* TODO: add a sysfs based enumerator */
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DeviceEnumerator::~DeviceEnumerator()
|
||||
{
|
||||
for (DeviceInfo *dev : devices_) {
|
||||
|
|
|
@ -56,6 +56,8 @@ private:
|
|||
class DeviceEnumerator
|
||||
{
|
||||
public:
|
||||
static DeviceEnumerator *create();
|
||||
|
||||
virtual ~DeviceEnumerator();
|
||||
|
||||
virtual int init() = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue