Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / devel / devel.ma / FakePool.cc
1 #include "Tools.h"
2 #include "Tools.h"
3
4 #include <iostream>
5
6 #include <zypp/base/LogControl.h>
7 #include <zypp/base/LogTools.h>
8 #include <zypp/base/String.h>
9 #include <zypp/base/SerialNumber.h>
10 #include <zypp/PathInfo.h>
11 #include <zypp/TmpPath.h>
12 #include "zypp/ResPoolProxy.h"
13
14 using namespace std;
15 using namespace zypp;
16 using namespace zypp::ui;
17
18 bool chst( Selectable::Ptr & sel, Status status )
19 {
20   DBG << "+++ " << sel << endl;
21   Status ostatus( sel->status() );
22   bool res = sel->set_status( status );
23   (res?MIL:WAR) << ostatus << " -> " << status << " ==>(" << res << ") " << sel->status() << endl;
24   DBG << "--- " << sel << endl;
25   return res;
26 }
27
28 /******************************************************************
29 **
30 **      FUNCTION NAME : main
31 **      FUNCTION TYPE : int
32 */
33 int main( int argc, char * argv[] )
34 {
35   INT << "===[START]==========================================" << endl;
36
37   const char *const lines[] = {
38     "@ package",
39     "@ installed",
40     "- foo 1 1 i686",
41     "@ available",
42     "- foo 2 1 i686",
43     "@ fin"
44   };
45
46   debug::addPool( lines, lines+(sizeof(lines)/sizeof(const char *const)) );
47
48   ResPool      pool( getZYpp()->pool() );
49   ResPoolProxy uipool( getZYpp()->poolProxy() );
50
51   USR << pool << endl;
52   USR << uipool << endl;
53
54   //for_each( pool.begin(), pool.end(), Print() );
55
56   Selectable::Ptr sel( *uipool.byKindBegin<Package>() );
57
58 /*    enum Status
59     {
60       S_Protected,           // Keep this unmodified ( have installedObj && S_Protected )
61       S_Taboo,               // Keep this unmodified ( have no installedObj && S_Taboo)
62       // requested by user:
63       S_Del,                 // delete  installedObj ( clears S_Protected if set )
64       S_Update,              // install candidateObj ( have installedObj, clears S_Protected if set )
65       S_Install,             // install candidateObj ( have no installedObj, clears S_Taboo if set )
66       // not requested by user:
67       S_AutoDel,             // delete  installedObj
68       S_AutoUpdate,          // install candidateObj ( have installedObj )
69       S_AutoInstall,         // install candidateObj ( have no installedObj )
70       // no modification:
71       S_KeepInstalled,       // no modification      ( have installedObj && !S_Protected, clears S_Protected if set )
72       S_NoInst,              // no modification      ( have no installedObj && !S_Taboo, clears S_Taboo if set )
73     };
74 */
75   MIL << sel << endl;
76   chst( sel, ui::S_Update );
77   chst( sel, ui::S_Install );
78   chst( sel, ui::S_Protected );
79   chst( sel, ui::S_KeepInstalled );
80
81   INT << "===[END]============================================" << endl
82       << endl;
83   return 0;
84 }