added comments, several fixes
authorJiri Srain <jsrain@suse.cz>
Thu, 20 Oct 2005 15:20:17 +0000 (15:20 +0000)
committerJiri Srain <jsrain@suse.cz>
Thu, 20 Oct 2005 15:20:17 +0000 (15:20 +0000)
zypp/Message.h
zypp/Patch.cc
zypp/Patch.h
zypp/Script.h
zypp/detail/MessageImpl.h
zypp/detail/PatchImpl.cc
zypp/detail/PatchImpl.h
zypp/detail/ScriptImpl.h

index 09b9add..3829cdd 100644 (file)
@@ -33,7 +33,7 @@ namespace zypp
   //
   //   CLASS NAME : Message
   //
-  /** */
+  /** Class representing the message to be shown during update */
   class Message : public Resolvable
   {
   public:
@@ -42,7 +42,9 @@ namespace zypp
     /** Dtor */
     ~Message();
   public:
+    /** Get the text of the message */
     std::string text ();
+    /** Get the type of the message (YesNo / OK) */
     std::string type ();
   private:
     /** Pointer to implementation */
index c6a5a28..24b54d6 100644 (file)
@@ -43,22 +43,22 @@ namespace zypp
 
   ///////////////////////////////////////////////////////////////////
   //
-  //   METHOD NAME : Patch::interactive
-  //   Check whether patch can be applied only interactivly
+  //   METHOD NAME : Patch::id
+  //   Get the patch id
   //
-  bool Patch::interactive ()
+  std::string Patch::id () const
   {
-    return _pimpl->interactive ();
+    return _pimpl->id ();
   }
 
   ///////////////////////////////////////////////////////////////////
   //
-  //   METHOD NAME : Patch::category
-  //   Get the category of the patch
+  //   METHOD NAME : Patch::id
+  //   Get the patch id
   //
-  std::string Patch::category ()
+  unsigned int Patch::timestamp () const
   {
-    return _pimpl->_category;
+    return _pimpl->timestamp ();
   }
 
   ///////////////////////////////////////////////////////////////////
@@ -66,9 +66,9 @@ namespace zypp
   //   METHOD NAME : Patch::summary
   //   Get the patch summary
   //
-  std::string Patch::summary ()
+  std::string Patch::summary () const
   {
-    return _pimpl->_summary["en"];
+    return _pimpl->summary ();
   }
 
   ///////////////////////////////////////////////////////////////////
@@ -76,9 +76,56 @@ namespace zypp
   //   METHOD NAME : Patch::description
   //   Get the patch description
   //
-  std::string Patch::description ()
+  std::list<std::string> Patch::description () const
+  {
+    return _pimpl->description ();
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Patch::category
+  //   Get the category of the patch
+  //
+  std::string Patch::category () const
+  {
+    return _pimpl->category ();
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Patch::reboot_needed
+  //   Check whether reboot is needed to finish the patch installation
+  //
+  bool Patch::reboot_needed () const {
+    return _pimpl->reboot_needed ();
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Patch::affects_pkg_manager
+  //   Check whether the patch installation affects package manager
+  //    (and it should be restarted after patch installation)
+  //
+  bool Patch::affects_pkg_manager () const {
+    return _pimpl->affects_pkg_manager ();
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Patch::atoms
+  //    Get the list of all atoms building the patch
+  //
+  atom_list Patch::atoms () const {
+    return _pimpl->all_atoms ();
+  }
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   METHOD NAME : Patch::interactive
+  //   Check whether patch can be applied only interactivly
+  //
+  bool Patch::interactive ()
   {
-    return _pimpl->_description["en"];
+    return _pimpl->interactive ();
   }
 
   void Patch::mark_atoms_to_freshen (bool freshen)
index 8da170f..aac32b5 100644 (file)
@@ -13,6 +13,7 @@
 #define ZYPP_PATCH_H
 
 #include <iosfwd>
+#include <list>
 
 #include "zypp/Resolvable.h"
 
@@ -29,11 +30,13 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
   DEFINE_PTR_TYPE(Patch)
 
+  #define atom_list std::list<ResolvablePtr>
+
   ///////////////////////////////////////////////////////////////////
   //
   //   CLASS NAME : Patch
   //
-  /** */
+  /** Class representing a patch */
   class Patch : public Resolvable
   {
   public:
@@ -42,13 +45,25 @@ namespace zypp
     /** Dtor */
     ~Patch();
   public:
+    /** Patch ID */
+    std::string id () const;
+    /** Patch time stamp */
+    unsigned int timestamp () const;
+    /** Patch summary */
+    std::string summary () const;
+    /** Patch description */
+    std::list<std::string> description() const;
+    /** Patch category (recommended, security,...) */
+    std::string category () const;
+    /** Does the system need to reboot to finish the update process? */
+    bool reboot_needed () const;
+    /** Does the patch affect the package manager itself? */
+    bool affects_pkg_manager () const;
+    /** The list of all atoms building the patch */
+    atom_list atoms () const;
+    /** Is the patch installation interactive? (does it need user input?) */
     bool interactive ();
-    std::string do_script ();
-    std::string undo_script ();
-    bool undo_available ();
-    std::string category ();
-    std::string description ();
-    std::string summary ();
+    // TODO add comments and reevaluate the need for functions below
     void mark_atoms_to_freshen (bool freshen);
     bool any_atom_selected ();
     void select (); // TODO parameter to specify select/unselect or another function
index 9fff673..43ef2c7 100644 (file)
@@ -33,7 +33,7 @@ namespace zypp
   //
   //   CLASS NAME : Script
   //
-  /** */
+  /** Class representing an update script */
   class Script : public Resolvable
   {
   public:
@@ -42,8 +42,11 @@ namespace zypp
     /** Dtor */
     ~Script();
   public:
+    /** Get the script to perform the change */
     std::string do_script ();
+    /** Get the script to undo the change */
     std::string undo_script ();
+    /** Check whether script to undo the change is available */
     bool undo_available ();
   private:
     /** Pointer to implementation */
index 9f1e7e0..ecffbe8 100644 (file)
@@ -30,7 +30,7 @@ namespace zypp
     //
     // CLASS NAME : MessageImpl
     //
-    /** */
+    /** Class representing the message to be shown during update */
     class MessageImpl : public ResolvableImpl
     {
     public:
@@ -42,10 +42,14 @@ namespace zypp
       ~MessageImpl();
 
     public:
+      /** Get the text of the message */
       virtual std::string text () const;
+      /** Get the type of the message (YesNo / OK) */
       virtual std::string type () const;
     protected:
+      /** The text of the message */
       std::string _text;
+      /** The type of the message (YesNo / OK) */
       std::string _type;
     };
     ///////////////////////////////////////////////////////////////////
index de2676d..a72a738 100644 (file)
@@ -47,6 +47,40 @@ namespace zypp
     {
     }
 
+    std::string PatchImpl::id () const
+    {
+      return _patch_id;
+    }
+    unsigned int PatchImpl::timestamp () const
+    {
+      return _timestamp;
+    }
+
+    std::string PatchImpl::summary () const
+    {
+      return _summary;
+    }
+
+    std::list<std::string> PatchImpl::description () const
+    {
+      return _description;
+    }
+
+    std::string PatchImpl::category () const
+    {
+      return _category;
+    }
+
+    bool PatchImpl::reboot_needed () const
+    {
+      return _reboot_needed;
+    }
+
+    bool PatchImpl::affects_pkg_manager () const
+    {
+      return _affects_pkg_manager;
+    }
+
     bool PatchImpl::interactive () {
       if (_reboot_needed)
       {
@@ -60,17 +94,20 @@ namespace zypp
       {
        if ((std::string)((*it)->kind ()) == "message")
        {
-         DBG << "Patch contains a message" << endl;
+//       DBG << "Patch contains a message" << endl;
          return true;
        }
        if ((std::string)((*it)->kind ()) == "package")
        {
-         ResolvablePtr r = *it;
-         // FIXME package with license
-//       if (r->licenseToConfirm() != "")
+                                // Resolvable*
+                                 // Resolvable
+                                  // ResolvablePtr
+         Package* p = (Package*)&**it;
+         // FIXME use the condition
+//       if (p->licenseToConfirm() != "")
          if (false)
          {
-           DBG << "Package has a license to be shown to user" << endl;
+//         DBG << "Package has a license to be shown to user" << endl;
            return true;
          }
        }
@@ -78,6 +115,10 @@ namespace zypp
       return false;
     }
 
+    atom_list PatchImpl::all_atoms () {
+      return _atoms;
+    }
+
     atom_list PatchImpl::not_installed_atoms () {
       atom_list ret;
       for (atom_list::iterator it = _atoms.begin ();
@@ -92,6 +133,8 @@ namespace zypp
       return ret;
     }
 
+// TODO check necessarity of functions below
+
     bool PatchImpl::any_atom_selected () {
       for (atom_list::iterator it = _atoms.begin ();
        it != _atoms.end ();
index 4bb6376..712a36a 100644 (file)
@@ -12,7 +12,6 @@
 #ifndef ZYPP_DETAIL_PATCHIMPL_H
 #define ZYPP_DETAIL_PATCHIMPL_H
 
-#include <map>
 #include <list>
 #include <string>
 
@@ -27,14 +26,11 @@ namespace zypp
   namespace detail
   { /////////////////////////////////////////////////////////////////
 
-//    typedef std::list<Resolvable> atom_list;
-    #define atom_list std::list<ResolvablePtr>
-
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : PatchImpl
     //
-    /** */
+    /** Class representing a patch */
     class PatchImpl : public ResolvableImpl
     {
     public:
@@ -46,19 +42,47 @@ namespace zypp
       ~PatchImpl();
 
     public:
-      std::string _category;
-      std::map<std::string,std::string> _summary;
-      std::map<std::string,std::string> _description;
-      int _timestamp;
-      std::string _patch_id;
-      bool _reboot_needed;
-      bool _package_manager;
+      /** Patch ID */
+      std::string id () const;
+      /** Patch time stamp */
+      unsigned int timestamp () const;
+      /** Patch summary */
+      std::string summary () const;
+      /** Patch description */
+      std::list<std::string> description () const;
+      /** Patch category (recommended, security,...) */
+      std::string category () const;
+      /** Does the system need to reboot to finish the update process? */
+      bool reboot_needed () const;
+      /** Does the patch affect the package manager itself? */
+      bool affects_pkg_manager () const;
 
+      /** Is the patch installation interactive? (does it need user input?) */
       bool interactive ();
+      /** The list of all atoms building the patch */
+      atom_list all_atoms ();
+      /** The list of those atoms which have not been installed */
+      atom_list not_installed_atoms ();
+
+// TODO check necessarity of functions below
       bool any_atom_selected ();
       void mark_atoms_to_freshen (bool freshen);
     protected:
-      atom_list not_installed_atoms ();
+      /** Patch ID */
+      std::string _patch_id;
+      /** Patch time stamp */
+      int _timestamp;
+      /** Patch summary */
+      std::string _summary;
+      /** Patch description */
+      std::list<std::string> _description;
+      /** Patch category (recommended, security,...) */
+      std::string _category;
+      /** Does the system need to reboot to finish the update process? */
+      bool _reboot_needed;
+      /** Does the patch affect the package manager itself? */
+      bool _affects_pkg_manager;
+      /** The list of all atoms building the patch */
       atom_list _atoms;
     };
     ///////////////////////////////////////////////////////////////////
index 597b6e5..32970a8 100644 (file)
@@ -30,7 +30,7 @@ namespace zypp
     //
     // CLASS NAME : ScriptImpl
     //
-    /** */
+    /** Class representing an update script */
     class ScriptImpl : public ResolvableImpl
     {
     public:
@@ -42,11 +42,16 @@ namespace zypp
       ~ScriptImpl();
 
     public:
+      /** Get the script to perform the change */
       std::string do_script () const;
+      /** Get the script to undo the change */
       std::string undo_script () const;
-      bool undo_available () const;
+      /** Check whether script to undo the change is available */
+      virtual bool undo_available () const;
     protected:
+      /** The script to perform the change */
       std::string _do_script;
+      /** The script to undo the change */
       std::string _undo_script;
     };
     ///////////////////////////////////////////////////////////////////