libcamera  v0.0.0
Supporting cameras in Linux since 2019
ipa_proxy.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * ipa_proxy.h - Image Processing Algorithm proxy
6  */
7 #ifndef __LIBCAMERA_INTERNAL_IPA_PROXY_H__
8 #define __LIBCAMERA_INTERNAL_IPA_PROXY_H__
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
15 
16 namespace libcamera {
17 
18 class IPAModule;
19 
20 class IPAProxy : public IPAInterface
21 {
22 public:
23  IPAProxy(IPAModule *ipam);
24  ~IPAProxy();
25 
26  bool isValid() const { return valid_; }
27 
28  std::string configurationFile(const std::string &file) const;
29 
30 protected:
31  std::string resolvePath(const std::string &file) const;
32 
33  bool valid_;
34 
35 private:
36  IPAModule *ipam_;
37 };
38 
40 {
41 public:
42  IPAProxyFactory(const char *name);
43  virtual ~IPAProxyFactory() {}
44 
45  virtual std::unique_ptr<IPAProxy> create(IPAModule *ipam) = 0;
46 
47  const std::string &name() const { return name_; }
48 
49  static void registerType(IPAProxyFactory *factory);
50  static std::vector<IPAProxyFactory *> &factories();
51 
52 private:
53  std::string name_;
54 };
55 
56 #define REGISTER_IPA_PROXY(proxy) \
57 class proxy##Factory final : public IPAProxyFactory \
58 { \
59 public: \
60  proxy##Factory() : IPAProxyFactory(#proxy) {} \
61  std::unique_ptr<IPAProxy> create(IPAModule *ipam) \
62  { \
63  return std::make_unique<proxy>(ipam); \
64  } \
65 }; \
66 static proxy##Factory global_##proxy##Factory;
67 
68 } /* namespace libcamera */
69 
70 #endif /* __LIBCAMERA_INTERNAL_IPA_PROXY_H__ */
C++ Interface for IPA implementation.
Definition: ipa_interface.h:151
Wrapper around IPA module shared object.
Definition: ipa_module.h:23
Registration of IPAProxy classes and creation of instances.
Definition: ipa_proxy.h:40
static std::vector< IPAProxyFactory * > & factories()
Retrieve the list of all IPAProxy factories.
Definition: ipa_proxy.cpp:292
IPAProxyFactory(const char *name)
Construct a IPAProxy factory.
Definition: ipa_proxy.cpp:243
const std::string & name() const
Retrieve the factory name.
Definition: ipa_proxy.h:47
static void registerType(IPAProxyFactory *factory)
Add a IPAProxy class to the registry.
Definition: ipa_proxy.cpp:274
virtual std::unique_ptr< IPAProxy > create(IPAModule *ipam)=0
Create an instance of the IPAProxy corresponding to the factory.
IPA Proxy.
Definition: ipa_proxy.h:21
IPAProxy(IPAModule *ipam)
Construct an IPAProxy instance.
Definition: ipa_proxy.cpp:45
bool valid_
Flag to indicate if the IPAProxy instance is valid.
Definition: ipa_proxy.h:33
std::string resolvePath(const std::string &file) const
Find a valid full path for a proxy worker for a given executable name.
Definition: ipa_proxy.cpp:162
std::string configurationFile(const std::string &file) const
Retrieve the absolute path to an IPA configuration file.
Definition: ipa_proxy.cpp:87
bool isValid() const
Check if the IPAProxy instance is valid.
Definition: ipa_proxy.h:26
Image Processing Algorithm interface.