Resolvertestcase:
[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 #include "zypp/CapSet.h"
23 #include "zypp/ResPool.h"
24
25 /////////////////////////////////////////////////////////////////////////
26 namespace zypp
27 { ///////////////////////////////////////////////////////////////////////
28   ///////////////////////////////////////////////////////////////////////
29   namespace solver
30   { /////////////////////////////////////////////////////////////////////
31     /////////////////////////////////////////////////////////////////////
32     namespace detail
33     { ///////////////////////////////////////////////////////////////////
34
35
36 template<class T>
37 std::string helixXML( const T &obj ); //undefined
38
39 template<> 
40 std::string helixXML( const Edition &edition );
41
42 template<> 
43 std::string helixXML( const Arch &arch );
44
45 template<> 
46 std::string helixXML( const Capability &cap );
47
48 template<> 
49 std::string helixXML( const CapSet &caps );
50
51 template<> 
52 std::string helixXML( const Dependencies &dep );
53         
54 template<> 
55 std::string helixXML( const PoolItem_Ref &item );
56
57
58 ///////////////////////////////////////////////////////////////////
59 //
60 //      CLASS NAME : HelixResolvable
61 /**
62  * Creates a file in helix format which includes all available
63  * or installed packages,patches,selections.....
64  **/
65 class  HelixResolvable : public base::ReferenceCounted, private base::NonCopyable{
66
67   private:
68     std::string dumpFile; // Path of the generated testcase
69     std::ofstream *file;    
70
71   public:
72     HelixResolvable (const std::string & path);
73     ~HelixResolvable ();
74
75     void addResolvable (const PoolItem_Ref item);
76     std::string filename () { return dumpFile; }
77 };
78
79 DEFINE_PTR_TYPE(HelixResolvable);
80 typedef std::map<Repository, HelixResolvable_Ptr> RepositoryTable;
81
82 ///////////////////////////////////////////////////////////////////
83 //
84 //      CLASS NAME : HelixControl
85 /**
86  * Creates a file in helix format which contains all controll
87  * action of a testcase ( file is known as *-test.xml)
88  **/
89 class  HelixControl {
90
91   private:
92     std::string dumpFile; // Path of the generated testcase
93     std::ofstream *file;
94
95   public:
96     HelixControl (const std::string & controlPath,
97                   const RepositoryTable & sourceTable,
98                   const Arch & systemArchitecture,
99                   const PoolItemList &languages,                  
100                   const std::string & systemPath = "solver-system.xml");
101     HelixControl ();    
102     ~HelixControl ();
103
104     void installResolvable (const ResObject::constPtr &resObject);
105     void lockResolvable (const ResObject::constPtr &resObject);
106     void keepResolvable (const ResObject::constPtr &resObject);        
107     void deleteResolvable (const ResObject::constPtr &resObject);
108     void addDependencies (const CapSet &capRequire, const CapSet &capConflict);
109     std::string filename () { return dumpFile; }
110 };
111         
112
113
114         
115 ///////////////////////////////////////////////////////////////////
116 //
117 //      CLASS NAME : Testcase
118 /**
119  * Generating a testcase of the current pool and solver state
120  **/
121 class Testcase {
122
123   private:
124     std::string dumpPath; // Path of the generated testcase
125
126   public:
127     Testcase (const std::string & path);
128     Testcase ();    
129     ~Testcase ();
130
131     bool createTestcase (Resolver & resolver);
132
133 };
134
135
136 ///////////////////////////////////////////////////////////////////
137     };// namespace detail
138     /////////////////////////////////////////////////////////////////////
139     /////////////////////////////////////////////////////////////////////
140   };// namespace solver
141   ///////////////////////////////////////////////////////////////////////
142   ///////////////////////////////////////////////////////////////////////
143 };// namespace zypp
144 /////////////////////////////////////////////////////////////////////////
145
146 #endif // ZYPP_SOLVER_DETAIL_TESTCASE_H