fixed some of the text casees
authorJiri Srain <jsrain@suse.cz>
Fri, 18 Nov 2005 15:24:45 +0000 (15:24 +0000)
committerJiri Srain <jsrain@suse.cz>
Fri, 18 Nov 2005 15:24:45 +0000 (15:24 +0000)
test/devel.jsrain/Main.cc [deleted file]
test/devel.jsrain/Makefile.am
test/devel.jsrain/Msg.cc
test/devel.jsrain/Patch.cc
test/devel.jsrain/PatchRead.cc
test/devel.jsrain/PatchSelect.cc
test/devel.jsrain/Script.cc

diff --git a/test/devel.jsrain/Main.cc b/test/devel.jsrain/Main.cc
deleted file mode 100644 (file)
index 34e8000..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <iostream>
-#include <string>
-#include <zypp/base/Logger.h>
-#include <zypp/detail/PackageImpl.h>
-#include <zypp/Package.h>
-
-using namespace std;
-using namespace zypp;
-using namespace base;
-
-/******************************************************************
-**
-**
-**     FUNCTION NAME : main
-**     FUNCTION TYPE : int
-**
-**     DESCRIPTION :
-*/
-int main( int argc, char * argv[] )
-{
-  INT << "===[START]==========================================" << endl;
-
-  std::string _name( "foo" );
-  Edition     _edition( "1.0", "42" );
-  Arch        _arch( "i386" );
-
-
-  detail::PackageImplPtr pi( new detail::PackageImpl(_name,_edition,_arch) );
-  DBG << pi << endl;
-  DBG << *pi << endl;
-  constPackagePtr foo( new Package( pi ) );
-  DBG << foo << endl;
-  DBG << *foo << endl;
-
-
-  detail::constPackageImplPtr c( pi );
-  detail::PackageImplPtr cc( const_pointer_cast<detail::PackageImpl>(c) );
-
-
-  INT << "===[END]============================================" << endl;
-  return 0;
-}
index 45f1784..6b674d9 100644 (file)
@@ -3,7 +3,7 @@
 
 SUBDIRS = yum
 
-noinst_PROGRAMS =      Main Main.debug Msg Msg.debug Patch Patch.debug Script Script.debug PatchSelect PatchSelect.debug PatchRead PatchRead.debug
+noinst_PROGRAMS =      Msg Msg.debug Patch Patch.debug Script Script.debug PatchSelect PatchSelect.debug PatchRead PatchRead.debug
 
 
 ## ##################################################
@@ -18,11 +18,6 @@ LDADD =              $(top_srcdir)/zypp/lib@PACKAGE@.la
 
 ## ##################################################
 
-Main_SOURCES =                 Main.cc
-
-Main_debug_SOURCES =   $(Main_SOURCES)
-Main_debug_LDFLAGS =   -static
-
 Msg_SOURCES =          Msg.cc
 
 Msg_debug_SOURCES =    $(Msg_SOURCES)
index b72f298..bc49bf6 100644 (file)
@@ -1,6 +1,7 @@
 #include <iostream>
 #include <zypp/base/Logger.h>
 #include <zypp/detail/MessageImpl.h>
+#include <zypp/Message.h>
 
 
 using namespace std;
@@ -10,9 +11,6 @@ class MyMessageImpl : public detail::MessageImpl
 {
   public:
     MyMessageImpl (std::string text)
-    : MessageImpl ("message1",
-                  Edition (),
-                  Arch ("noarch"))
     {
       _text = text;
     }
@@ -30,10 +28,15 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  MyMessageImpl p ("My message to be shown to user");
+  std::string text = "My message to be shown to user";
+  std::string _name( "msg1" );
+  Edition _edition( "1.0", "42" );
+  Arch    _arch( "noarch" );
+  base::shared_ptr<detail::MessageImpl> mp1(new MyMessageImpl(text));
+  Message::Ptr m( detail::makeResolvableFromImpl( _name, _edition, _arch, mp1));
 
-  DBG << p << endl;
-  DBG << "  \"" << p.text() << "\"" << endl;
+  DBG << *m << endl;
+  DBG << "  \"" << m->text() << "\"" << endl;
 
   INT << "===[END]============================================" << endl;
   return 0;
index 5cc825d..45b5f36 100644 (file)
@@ -7,6 +7,7 @@
 #include <zypp/detail/MessageImpl.h>
 #include <zypp/detail/PatchImpl.h>
 #include <zypp/Package.h>
+#include <zypp/Patch.h>
 #include <zypp/detail/PackageImpl.h>
 
 
@@ -16,10 +17,7 @@ using namespace zypp;
 class MyPatchImpl : public detail::PatchImpl
 {
   public:
-    MyPatchImpl (std::string name, std::list<ResolvablePtr> atoms)
-    : PatchImpl (name,
-                Edition (),
-                Arch ("noarch"))
+    MyPatchImpl (detail::PatchImpl::AtomList atoms)
     {
       _reboot_needed = false;
       _atoms = atoms;
@@ -38,27 +36,28 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  atom_list atoms;
+  detail::PatchImpl::AtomList atoms;
 
   std::string _name( "foo" );
   Edition _edition( "1.0", "42" );
   Arch    _arch( "i386" );
-  detail::PackageImplPtr pi( new detail::PackageImpl(_name,_edition,_arch) );
-  PackagePtr p (new Package (pi));
+  base::shared_ptr<detail::PackageImpl> pi( new detail::PackageImpl );
+  Package::Ptr p( detail::makeResolvableFromImpl( _name, _edition, _arch, pi ));
   atoms.push_back (p);
 
   std::string _name2( "bar" );
   Edition _edition2( "1.0", "43" );
   Arch    _arch2( "noarch" );
-  detail::PackageImplPtr pi2(new detail::PackageImpl(_name2,_edition2,_arch2));
-  PackagePtr p2 (new Package (pi2));
+  base::shared_ptr<detail::PackageImpl> pi2(new detail::PackageImpl);
+  Package::Ptr p2( detail::makeResolvableFromImpl( _name, _edition, _arch, pi2));
   atoms.push_back (p2);
 
-  MyPatchImpl q ("patch1", atoms);
-  DBG << q << endl;
-  DBG << "  Interactive: " << q.interactive () << endl;
-  atom_list a = q.all_atoms ();
-  for (atom_list::iterator it = a.begin (); it != a.end (); it++)
+  base::shared_ptr<detail::PatchImpl> pt1(new MyPatchImpl(atoms));
+  Patch::Ptr q( detail::makeResolvableFromImpl( std::string("patch1"), _edition, _arch, pt1));
+  DBG << *q << endl;
+  DBG << "  Interactive: " << q->interactive () << endl;
+  Patch::AtomList a = q->atoms ();
+  for (Patch::AtomList::iterator it = a.begin (); it != a.end (); it++)
   {
     DBG << "  " << **it << endl;
   }
@@ -66,16 +65,19 @@ int main( int argc, char * argv[] )
   INT << "====================================================" << endl;
 
   std::string _name3( "msg" );
+  Edition _ed3( "1.0", "42" );
   Arch    _arch3( "noarch" );
-  detail::MessageImplPtr mi(new detail::MessageImpl(_name3,Edition (),_arch3));
-  MessagePtr m (new Message (mi));
+  base::shared_ptr<detail::MessageImpl> mi(new detail::MessageImpl);
+  Message::Ptr m (detail::makeResolvableFromImpl( _name3, _ed3, _arch3, mi));
+
   atoms.push_back (m);
 
-  MyPatchImpl q2 ("patch2", atoms);
-  DBG << q2 << endl;
-  DBG << "  Interactive: " << q2.interactive () << endl;
-  a = q2.all_atoms ();
-  for (atom_list::iterator it = a.begin (); it != a.end (); it++)
+  base::shared_ptr<detail::PatchImpl> pt2(new MyPatchImpl(atoms));
+  Patch::Ptr q2( detail::makeResolvableFromImpl( std::string("patch2"), _edition, _arch, pt2));
+  DBG << *q2 << endl;
+  DBG << "  Interactive: " << q2->interactive () << endl;
+  a = q2->atoms ();
+  for (Patch::AtomList::iterator it = a.begin (); it != a.end (); it++)
   {
     DBG << "  " << **it << endl;
   }
index 633efb1..b35d117 100644 (file)
@@ -18,6 +18,8 @@
 #include <zypp/parser/yum/YUMParser.h>
 #include <zypp/base/Logger.h>
 #include <zypp/source/yum/YUMScriptImpl.h>
+#include <zypp/source/yum/YUMMessageImpl.h>
+#include <zypp/source/yum/YUMPackageImpl.h>
 
 
 #include <map>
@@ -35,21 +37,6 @@ using namespace zypp::source::YUM;
 
 CapFactory _f;
 
-DEFINE_PTR_TYPE(MyMessageImpl)
-class MyMessageImpl : public detail::MessageImpl
-{
-  public:
-    MyMessageImpl (string name, string type, std::string text)
-    : MessageImpl (name,
-                  Edition (),
-                  Arch ("noarch"))
-    {
-      _text = text;
-      _type = type;
-    }
-};
-IMPL_PTR_TYPE(MyMessageImpl)
-
 void AddDependency (detail::ResolvableImplPtr res, Capability& cap) {
   Dependencies deps = res->deps();
   CapSet req = deps.requires();
@@ -81,7 +68,7 @@ class MyPatchImpl : public detail::PatchImpl
       Capability cap( _f.parse( p.name, ResKind( "patch" )));
 
       // Process atoms
-      atom_list atoms;
+      detail::PatchImpl::AtomList atoms;
 
       for (std::list<YUMPatchAtom>::iterator it = p.atoms.begin();
        it != p.atoms.end();
@@ -96,43 +83,31 @@ class MyPatchImpl : public detail::PatchImpl
          cout << script->deps() << endl;
          atoms.push_back(script);
        }
+       else if (it->type == "message")
+       {
+         MessageImplPtr impl = new YUMMessageImpl( *it->message );
+         AddDependency(impl, cap);
+         MessagePtr message = new Message(impl);
+         cout << *message << endl;
+         cout << message->deps() << endl;
+         atoms.push_back(message);
+       }
+       else if (it->type == "package")
+       {
+         PackageImplPtr impl = new YUMPackageImpl( *it->package );
+         AddDependency(impl, cap);
+         PackagePtr package = new Package(impl);
+         cout << *package << endl;
+         cout << package->deps() << endl;
+         atoms.push_back(package);
+       }
       }
 
-/*      for (list<PACKAGE>::iterator it = p.pack.begin();
-           it != p.pack.end();
-           it++)
-      {
-       detail::PackageImplPtr pi( new detail::PackageImpl(
-         it->name,
-         Edition( it->version, it->release ),
-         Arch( it->arch )));
-       AddDependency( pi, cap );
-       AddAllRequires( pi, it->requires );
-       PackagePtr p( new Package( pi ));
-       DBG << *p << endl;
-       DBG << p->deps() << endl;
-       atoms.push_back( p );
-      }
-      for (list<MESSAGE>::iterator it = p.msg.begin();
-           it != p.msg.end();
-           it++)
-      {
-       detail::MessageImplPtr pi( new MyMessageImpl(
-         it->name,
-         it->type,
-         it->text));
-       AddDependency( pi, cap );
-       MessagePtr p( new Message( pi ));
-       DBG << *p << endl;
-       DBG << p->deps() << endl;
-       atoms.push_back( p );
-      }
-*/
       // FIXME mve this piece of code after solutions are selected
       // this orders the atoms of a patch
       ResolvablePtr previous;
       bool first = true;
-      for (atom_list::iterator it = atoms.begin();
+      for (detail::PatchImpl::AtomList::iterator it = atoms.begin();
            it != atoms.end();
           it++)
       {
@@ -169,53 +144,6 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-// filling structures
-/*
-PACKAGE foo;
-foo.name = "foo";
-foo.version = "3.0";
-foo.release = "5";
-foo.arch = "noarch";
-
-PACKAGE foocomp;
-foocomp.name = "foo-compat";
-foocomp.version = "3.0";
-foocomp.release = "5";
-foocomp.arch = "noarch";
-foocomp.requires.push_back( Capability( _f.parse( "foo", ResKind( "package" ))));
-
-PACKAGE bar;
-bar.name = "bar";
-bar.version = "2.8";
-bar.release = "2";
-bar.arch = "noarch";
-
-MESSAGE msg;
-msg.name = "msg";
-msg.type = "OK";
-msg.text = "Hello World";
-
-SCRIPT scr;
-scr.name = "scr";
-scr.do_script = "/bin/bash";
-scr.undo_script = "/bin/unbash";
-
-list<PACKAGE> pkgs;
-list<MESSAGE> msgs;
-list<SCRIPT> scrs;
-
-pkgs.push_back( foo );
-pkgs.push_back( foocomp );
-pkgs.push_back( bar );
-msgs.push_back( msg );
-scrs.push_back( scr );
-
-PATCH ptch;
-ptch.name = "patch";
-ptch.pack = pkgs;
-ptch.msg = msgs;
-ptch.scr = scrs;
-*/
 PatchPtr patch1;
 YUMPatchParser iter(cin,"");
 for (;
@@ -233,8 +161,8 @@ if (iter.errorStatus())
 
 DBG << patch1 << endl;
 DBG << *patch1 << endl;
-atom_list at = patch1->atoms();
-for (atom_list::iterator it = at.begin();
+Patch::AtomList at = patch1->atoms();
+for (Patch::AtomList::iterator it = at.begin();
      it != at.end();
      it++)
 {
index 213c1f4..b19f3d5 100644 (file)
@@ -49,7 +49,7 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  atom_list atoms;
+  PatchImpl::AtomList atoms;
 
   std::string _name( "foo" );
   Edition _edition( "1.0", "42" );
@@ -68,7 +68,7 @@ int main( int argc, char * argv[] )
   MyPatchImplPtr q (new MyPatchImpl ("patch1", atoms, "recommended"));
   PatchPtr patch1 (new Patch (q));
 
-  atom_list atoms2;
+  PatchImpl::AtomList atoms2;
   std::string _name3( "msg" );
   Arch    _arch3( "noarch" );
   detail::MessageImplPtr mi(new detail::MessageImpl(_name3,Edition (),_arch3));
index 7c2984b..4147635 100644 (file)
@@ -1,6 +1,7 @@
 #include <iostream>
 #include <zypp/base/Logger.h>
 #include <zypp/detail/ScriptImpl.h>
+#include <zypp/Script.h>
 
 
 using namespace std;
@@ -10,9 +11,6 @@ class MyScriptImpl : public detail::ScriptImpl
 {
   public:
     MyScriptImpl (std::string do_script, std::string undo_script = "") 
-    : ScriptImpl ("script1",
-                 Edition (),
-                 Arch ("noarch"))
     {
       _do_script = do_script;
       _undo_script = undo_script;
@@ -31,21 +29,28 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  MyScriptImpl p ("#!/bin/bash\ndo_script");
+  std::string do_script = "#!/bin/bash\ndo_script";
+  std::string undo_script = "#!/bin/bash\nundo_script";
+  std::string _name( "script1" );
+  Edition _edition( "1.0", "42" );
+  Arch    _arch( "noarch" );
+  base::shared_ptr<detail::ScriptImpl> sp1(new MyScriptImpl(do_script));
+  Script::Ptr s( detail::makeResolvableFromImpl( _name, _edition, _arch, sp1));
 
-  DBG << p << endl;
-  DBG << "  \"" << p.do_script() << "\"" << endl;
-  DBG << "  \"" << p.undo_script() << "\"" << endl;
-  DBG << "  " << p.undo_available() << endl;
+  DBG << *s << endl;
+  DBG << "  \"" << s->do_script() << "\"" << endl;
+  DBG << "  \"" << s->undo_script() << "\"" << endl;
+  DBG << "  " << s->undo_available() << endl;
 
   INT << "====================================================" << endl;
 
-  MyScriptImpl q ("#!/bin/bash\ndo_script", "#!/bin/bash\nundo_script");
+  base::shared_ptr<detail::ScriptImpl> sp2(new MyScriptImpl(do_script, undo_script));
+  Script::Ptr s2( detail::makeResolvableFromImpl( _name, _edition, _arch, sp2));
 
-  DBG << q << endl;
-  DBG << "  \"" << q.do_script() << "\"" << endl;
-  DBG << "  \"" << q.undo_script() << "\"" << endl;
-  DBG << "  " << q.undo_available() << endl;
+  DBG << *s2 << endl;
+  DBG << "  \"" << s2->do_script() << "\"" << endl;
+  DBG << "  \"" << s2->undo_script() << "\"" << endl;
+  DBG << "  " << s2->undo_available() << endl;
 
   INT << "===[END]============================================" << endl;
   return 0;