1 /*
2  * Copyright (C) 2020 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 // Autogenerated by dumpstate_hal_config.xsd
18 // TODO(egranata): could we build xsdc from AOSP such that
19 // one could generate this file instead of having a hardcoded copy?
20 
21 #ifndef DUMPSTATE_HAL_CONFIGURATION_V1_0_H
22 #define DUMPSTATE_HAL_CONFIGURATION_V1_0_H
23 
24 #include <array>
25 #include <map>
26 #include <optional>
27 #include <string>
28 #include <vector>
29 
30 #include <libxml/parser.h>
31 #include <libxml/xinclude.h>
32 
33 namespace dumpstate {
34 namespace hal {
35 namespace configuration {
36 namespace V1_0 {
37 class Service;
38 class Services;
39 class SystemLogs;
40 class DumpstateHalConfiguration;
41 std::optional<DumpstateHalConfiguration> readFile(const char* configFile);
42 std::optional<DumpstateHalConfiguration> readBuffer(const std::string& xml);
43 
44 class Service {
45   private:
46     const std::string name_;
47     const std::string command_;
48 
49   public:
50     Service(std::string name, std::string command);
51     const std::string& getName() const;
52     bool hasName() const;
53     const std::string& getCommand() const;
54     bool hasCommand() const;
55     static Service read(xmlNode* root);
56 };
57 
58 class Services {
59   private:
60     const std::vector<Service> service_;
61 
62   public:
63     explicit Services(std::vector<Service> service);
64     const std::vector<Service>& getService() const;
65     bool hasService() const;
66     const Service* getFirstService() const;
67     static Services read(xmlNode* root);
68 };
69 
70 class SystemLogs {
71   private:
72     const std::vector<Service> service_;
73 
74   public:
75     explicit SystemLogs(std::vector<Service> service);
76     const std::vector<Service>& getService() const;
77     bool hasService() const;
78     const Service* getFirstService() const;
79     static SystemLogs read(xmlNode* root);
80 };
81 
82 class DumpstateHalConfiguration {
83   private:
84     const std::vector<Services> services_;
85     const std::vector<SystemLogs> systemLogs_;
86     const float version_;
87 
88   public:
89     DumpstateHalConfiguration(std::vector<Services> services, std::vector<SystemLogs> systemLogs,
90                               float version);
91     const std::vector<Services>& getServices() const;
92     bool hasServices() const;
93     const Services* getFirstServices() const;
94     const std::vector<SystemLogs>& getSystemLogs() const;
95     bool hasSystemLogs() const;
96     const SystemLogs* getFirstSystemLogs() const;
97     const float& getVersion() const;
98     bool hasVersion() const;
99     static DumpstateHalConfiguration read(xmlNode* root);
100 };
101 
102 }  // namespace V1_0
103 }  // namespace configuration
104 }  // namespace hal
105 }  // namespace dumpstate
106 #endif  // DUMPSTATE_HAL_CONFIGURATION_V1_0_H
107