generating testcases from the pool
[platform/upstream/libzypp.git] / zypp / solver / detail / Testcase.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/solver/detail/Testcase.h
10  *
11 */
12
13 #ifndef ZYPP_SOLVER_DETAIL_TESTCASE_H
14 #define ZYPP_SOLVER_DETAIL_TESTCASE_H
15
16 #include <iosfwd>
17 #include <string>
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/NonCopyable.h"
20 #include "zypp/base/PtrTypes.h"
21 #include "zypp/solver/detail/Resolver.h"
22
23
24 /////////////////////////////////////////////////////////////////////////
25 namespace zypp
26 { ///////////////////////////////////////////////////////////////////////
27   ///////////////////////////////////////////////////////////////////////
28   namespace solver
29   { /////////////////////////////////////////////////////////////////////
30     /////////////////////////////////////////////////////////////////////
31     namespace detail
32     { ///////////////////////////////////////////////////////////////////
33
34
35 template<class T>
36 std::string helixXML( const T &obj ); //undefined
37
38 template<> 
39 std::string helixXML( const Edition &edition );
40
41 template<> 
42 std::string helixXML( const Arch &arch );
43
44 template<> 
45 std::string helixXML( const Capability &cap );
46
47 template<> 
48 std::string helixXML( const CapSet &caps );
49
50 template<> 
51 std::string helixXML( const Dependencies &dep );
52         
53 template<> 
54 std::string helixXML( const Resolvable::constPtr &resolvable );
55
56
57 ///////////////////////////////////////////////////////////////////
58 //
59 //      CLASS NAME : HelixResolvable
60 /**
61  * Creates a file in helix format which includes all available
62  * or installed packages,patches,selections.....
63  **/
64 class  HelixResolvable : public base::ReferenceCounted, private base::NonCopyable{
65
66   private:
67     std::string dumpFile; // Path of the generated testcase
68     std::ofstream *file;    
69
70   public:
71     HelixResolvable (const std::string & path);
72     ~HelixResolvable ();
73
74     void addResolvable (const Resolvable::constPtr &resolvable);
75     std::string filename () { return dumpFile; }
76 };
77
78 DEFINE_PTR_TYPE(HelixResolvable);
79 typedef std::map<Source_Ref, HelixResolvable_Ptr> SourceTable;
80
81 ///////////////////////////////////////////////////////////////////
82 //
83 //      CLASS NAME : HelixControl
84 /**
85  * Creates a file in helix format which contains all controll
86  * action of a testcase ( file is known as *-test.xml)
87  **/
88 class  HelixControl {
89
90   private:
91     std::string dumpFile; // Path of the generated testcase
92     std::ofstream *file;
93
94   public:
95     HelixControl (const std::string & controlPath,
96                   const SourceTable & sourceTable,
97                   const std::string & systemPath = "solver-system.xml");
98     HelixControl ();    
99     ~HelixControl ();
100
101     void installResolvable (const ResObject::constPtr &resObject);
102     void deleteResolvable (const ResObject::constPtr &resObject);
103     std::string filename () { return dumpFile; }
104 };
105         
106
107
108         
109 ///////////////////////////////////////////////////////////////////
110 //
111 //      CLASS NAME : Testcase
112 /**
113  * Generating a testcase of the current pool and solver state
114  **/
115 class Testcase {
116
117   private:
118     std::string dumpPath; // Path of the generated testcase
119
120   public:
121     Testcase (const std::string & path);
122     Testcase ();    
123     ~Testcase ();
124
125     bool createTestcase (Resolver & resolver);
126
127 };
128
129
130 ///////////////////////////////////////////////////////////////////
131     };// namespace detail
132     /////////////////////////////////////////////////////////////////////
133     /////////////////////////////////////////////////////////////////////
134   };// namespace solver
135   ///////////////////////////////////////////////////////////////////////
136   ///////////////////////////////////////////////////////////////////////
137 };// namespace zypp
138 /////////////////////////////////////////////////////////////////////////
139
140 #endif // ZYPP_SOLVER_DETAIL_TESTCASE_H