Imported Upstream version 17.25.4
[platform/upstream/libzypp.git] / zypp / misc / LoadTestcase.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/misc/LoadTestcase.h
10  *
11 */
12 #ifndef ZYPP_MISC_LOADTESTCASE_H
13 #define ZYPP_MISC_LOADTESTCASE_H
14
15 #include <zypp/Pathname.h>
16 #include <zypp/Url.h>
17 #include <zypp/base/PtrTypes.h>
18 #include <zypp/base/NonCopyable.h>
19 #include <zypp/misc/TestcaseSetup.h>
20
21 #include <optional>
22 #include <memory>
23
24 namespace zypp::misc::testcase {
25
26   struct TestcaseTrial
27   {
28     struct Node {
29       struct Impl;
30
31       Node();
32       ~Node();
33       const std::string &name  () const;
34       std::string &name  ();
35       const std::string &value () const;
36       std::string &value ();
37
38       const std::string &getProp( const std::string &name, const std::string &def = std::string() ) const;
39       const std::map<std::string, std::string> &properties() const;
40       std::map<std::string, std::string> &properties();
41       const std::vector<std::shared_ptr<Node>> &children() const;
42       std::vector<std::shared_ptr<Node>> &children();
43
44     private:
45       RWCOW_pointer<Impl> _pimpl;
46
47     };
48
49     TestcaseTrial();
50     ~TestcaseTrial();
51     const std::vector<Node> &nodes () const;
52     std::vector<Node> &nodes ();
53   private:
54     struct Impl;
55     RWCOW_pointer<Impl> _pimpl;
56   };
57
58   class LoadTestcase : private zypp::base::NonCopyable
59   {
60   public:
61     struct Impl;
62
63     enum Type {
64       None,
65       Helix,
66       Yaml
67     };
68
69     LoadTestcase();
70     ~LoadTestcase();
71
72     bool loadTestcaseAt ( const zypp::Pathname &path, std::string *err );
73     static Type testcaseTypeAt ( const zypp::Pathname &path );
74
75     const TestcaseSetup &setupInfo() const;
76     const std::vector<TestcaseTrial> &trialInfo() const;
77
78   private:
79     std::unique_ptr<Impl> _pimpl;
80   };
81
82 }
83
84
85 #endif // ZYPP_MISC_LOADTESTCASE_H