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