Fixed bug in smart pointer comparison.
[platform/upstream/libzypp.git] / devel / devel.ma / Main.cc
1 #include <iostream>
2
3 #include "zypp/base/Easy.h"
4 #include "zypp/base/LogTools.h"
5 #include "zypp/base/InputStream.h"
6 #include "zypp/base/ReferenceCounted.h"
7 #include "zypp/base/NonCopyable.h"
8 #include "zypp/base/PtrTypes.h"
9
10 #include "zypp/TmpPath.h"
11 #include "zypp/RepoManager.h"
12
13 using std::endl;
14 using namespace zypp;
15
16 ///////////////////////////////////////////////////////////////////
17
18 RepoManager makeRepoManager( const Pathname & mgrdir_r )
19 {
20
21   RepoManagerOptions mgropt;
22   mgropt.repoCachePath    = mgrdir_r/"cache";
23   mgropt.repoRawCachePath = mgrdir_r/"raw_cache";
24   mgropt.knownReposPath   = mgrdir_r/"repos";
25
26   return RepoManager( mgropt );
27 }
28
29 struct Impl : public base::ReferenceCounted
30 {
31   Impl() : i(13) {}
32   int i;
33 };
34 DEFINE_PTR_TYPE(Impl);
35 IMPL_PTR_TYPE(Impl);
36
37 inline std::ostream & operator<<( std::ostream & str, const Impl & obj )
38 { return str << &obj; }
39
40 #define TCODE \
41   SEC << endl; \
42   MIL << "n " << _nimpl << endl; \
43   MIL << "n " << (_nimpl?1:0) << endl; \
44   MIL << "p " << _pimpl << endl; \
45   MIL << "p " << (_pimpl?1:0) << endl; \
46   MIL << "P " << _Pimpl << endl; \
47   MIL << "P " << (_Pimpl?1:0) << endl; \
48   MIL << "= " << (_nimpl == _pimpl) << endl; \
49   MIL << "! " << (_nimpl != _pimpl) << endl; \
50   MIL << "= " << (_Pimpl == _pimpl) << endl; \
51   MIL << "! " << (_Pimpl != _pimpl) << endl; \
52   MIL << "= " << (_pimpl == _pimpl) << endl; \
53   MIL << "! " << (_pimpl != _pimpl) << endl;
54
55 /******************************************************************
56 **
57 **      FUNCTION NAME : main
58 **      FUNCTION TYPE : int
59 */
60 int main( int argc, char * argv[] )
61 {
62   INT << "===[START]==========================================" << endl;
63
64   {
65     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _nimpl;
66     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl(new Impl);
67     RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _Pimpl(new Impl);
68     TCODE;
69   }
70   {
71     RW_pointer<Impl,rw_pointer::Shared<Impl> >    _nimpl;
72     RW_pointer<Impl,rw_pointer::Shared<Impl> >    _pimpl(new Impl);
73     RW_pointer<Impl,rw_pointer::Shared<Impl> >    _Pimpl(new Impl);
74    TCODE;
75   }
76   {
77     RW_pointer<Impl,rw_pointer::Scoped<Impl> >    _nimpl;
78     RW_pointer<Impl,rw_pointer::Scoped<Impl> >    _pimpl(new Impl);
79     RW_pointer<Impl,rw_pointer::Scoped<Impl> >    _Pimpl(new Impl);
80     TCODE;
81   }
82
83   INT << "===[END]============================================" << endl << endl;
84   return 0;
85
86   RepoManager repoManager( makeRepoManager( "/ROOT" ) );
87   RepoInfoList repos = repoManager.knownRepositories();
88   SEC << repos << endl;
89
90   if ( repos.empty() )
91   {
92     RepoInfo nrepo;
93     nrepo
94         .setAlias( "factorytest" )
95         .setName( "Test Repo for factory." )
96         .setEnabled( true )
97         .setAutorefresh( false )
98         .addBaseUrl( Url("ftp://dist.suse.de/install/stable-x86/") );
99
100     repoManager.addRepository( nrepo );
101     repos = repoManager.knownRepositories();
102     SEC << repos << endl;
103
104 //    SEC << "refreshMetadat" << endl;
105 //    repoManager.refreshMetadata( nrepo );
106 //    SEC << "buildCache" << endl;
107 //    repoManager.buildCache( nrepo );
108 //    SEC << "------" << endl;
109   }
110
111   INT << "===[END]============================================" << endl << endl;
112   return 0;
113 }