/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated by dumpstate_hal_config.xsd
// TODO(egranata): could we build xsdc from AOSP such that
// one could generate this file instead of having a hardcoded copy?

#ifndef DUMPSTATE_HAL_CONFIGURATION_V1_0_H
#define DUMPSTATE_HAL_CONFIGURATION_V1_0_H

#include <array>
#include <map>
#include <optional>
#include <string>
#include <vector>

#include <libxml/parser.h>
#include <libxml/xinclude.h>

namespace dumpstate {
namespace hal {
namespace configuration {
namespace V1_0 {
class Service;
class Services;
class SystemLogs;
class DumpstateHalConfiguration;
std::optional<DumpstateHalConfiguration> readFile(const char* configFile);
std::optional<DumpstateHalConfiguration> readBuffer(const std::string& xml);

class Service {
  private:
    const std::string name_;
    const std::string command_;

  public:
    Service(std::string name, std::string command);
    const std::string& getName() const;
    bool hasName() const;
    const std::string& getCommand() const;
    bool hasCommand() const;
    static Service read(xmlNode* root);
};

class Services {
  private:
    const std::vector<Service> service_;

  public:
    explicit Services(std::vector<Service> service);
    const std::vector<Service>& getService() const;
    bool hasService() const;
    const Service* getFirstService() const;
    static Services read(xmlNode* root);
};

class SystemLogs {
  private:
    const std::vector<Service> service_;

  public:
    explicit SystemLogs(std::vector<Service> service);
    const std::vector<Service>& getService() const;
    bool hasService() const;
    const Service* getFirstService() const;
    static SystemLogs read(xmlNode* root);
};

class DumpstateHalConfiguration {
  private:
    const std::vector<Services> services_;
    const std::vector<SystemLogs> systemLogs_;
    const float version_;

  public:
    DumpstateHalConfiguration(std::vector<Services> services, std::vector<SystemLogs> systemLogs,
                              float version);
    const std::vector<Services>& getServices() const;
    bool hasServices() const;
    const Services* getFirstServices() const;
    const std::vector<SystemLogs>& getSystemLogs() const;
    bool hasSystemLogs() const;
    const SystemLogs* getFirstSystemLogs() const;
    const float& getVersion() const;
    bool hasVersion() const;
    static DumpstateHalConfiguration read(xmlNode* root);
};

}  // namespace V1_0
}  // namespace configuration
}  // namespace hal
}  // namespace dumpstate
#endif  // DUMPSTATE_HAL_CONFIGURATION_V1_0_H
