• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef VENDOR_MODULES_H
18 #define VENDOR_MODULES_H
19 
20 #include <map>
21 #include <vector>
22 #include <string>
23 
24 #include <SharedLibrary.h>
25 
26 using ::android::hardware::drm::V1_0::helper::SharedLibrary;
27 
28 class DrmHalVTSVendorModule;
29 
30 namespace drm_vts {
31 class VendorModules {
32    public:
33     /**
34      * Initialize with a file system path where the shared libraries
35      * are to be found.
36      */
VendorModules(const std::string & dir)37     explicit VendorModules(const std::string& dir) {
38         scanModules(dir);
39     }
~VendorModules()40     ~VendorModules() {}
41 
42     /**
43      * Retrieve a DrmHalVTSVendorModule given its full path.  The
44      * getAPIVersion method can be used to determine the versioned
45      * subclass type.
46      */
47     DrmHalVTSVendorModule* getModule(const std::string& path);
48 
49     /**
50      * Return the list of paths to available vendor modules.
51      */
getPathList()52     std::vector<std::string> getPathList() const {return mPathList;}
53 
54    private:
55     std::vector<std::string> mPathList;
56     std::map<std::string, std::unique_ptr<SharedLibrary>> mOpenLibraries;
57 
58     /**
59      * Scan the list of paths to available vendor modules.
60      */
61     void scanModules(const std::string& dir);
62 
endsWith(const std::string & str,const std::string & suffix)63     inline bool endsWith(const std::string& str, const std::string& suffix) const {
64         if (suffix.size() > str.size()) return false;
65         return std::equal(suffix.rbegin(), suffix.rend(), str.rbegin());
66     }
67 
68     VendorModules(const VendorModules&) = delete;
69     void operator=(const VendorModules&) = delete;
70 };
71 };
72 
73 #endif  // VENDOR_MODULES_H
74