Add static Target::distributionLabel to return the baseproducts shortName and summary...
authorMichael Andres <ma@suse.de>
Tue, 23 Mar 2010 15:55:47 +0000 (16:55 +0100)
committerMichael Andres <ma@suse.de>
Tue, 23 Mar 2010 16:04:35 +0000 (17:04 +0100)
zypp/Target.cc
zypp/Target.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index 411cc24..d4f965a 100644 (file)
@@ -57,6 +57,12 @@ namespace zypp
     return _nullimpl;
   }
 
+  std::ostream & operator<<( std::ostream & str, const Target::DistributionLabel & obj )
+  {
+    str << "summary=" << obj.summary << endl;
+    str << "shortName=" << obj.shortName << endl;
+    return str;
+  }
 
   ///////////////////////////////////////////////////////////////////
   //
@@ -107,6 +113,11 @@ namespace zypp
   std::string Target::targetDistributionRelease( const Pathname & root_r )
   { return target::TargetImpl::targetDistributionRelease( root_r ); }
 
+  Target::DistributionLabel Target::distributionLabel() const
+  { return _pimpl->distributionLabel(); }
+  Target::DistributionLabel Target::distributionLabel( const Pathname & root_r )
+  { return target::TargetImpl::distributionLabel( root_r ); }
+
   std::string Target::distributionVersion() const
   { return _pimpl->distributionVersion(); }
   std::string Target::distributionVersion( const Pathname & root_r )
index b7c7694..0bffb98 100644 (file)
@@ -142,6 +142,14 @@ namespace zypp
     /** \overload */
     static std::string targetDistributionRelease( const Pathname & root_r );
 
+    struct DistributionLabel { std::string shortName; std::string summary; };
+    /** This is \c shortName and \c summary attribute of the installed base product.
+     * Used e.g. for the bootloader menu.
+     */
+    DistributionLabel distributionLabel() const;
+    /** \overload */
+    static DistributionLabel distributionLabel( const Pathname & root_r );
+
     /** This is \c version attribute of the installed base product.
      * For example http://download.opensue.org/update/11.0
      * The 11.0 corresponds to the base product version.
@@ -204,6 +212,14 @@ namespace zypp
   inline std::ostream & operator<<( std::ostream & str, const Target & obj )
   { return obj.dumpOn( str ); }
 
+  /** \relates Target::DistributionLabel Stream output.
+   * Write out the content as key/value pairs:
+   * \code
+   * summary=Beautiful Name
+   * shortName=BN
+   * \endcode
+   */
+  std::ostream & operator<<( std::ostream & str, const Target::DistributionLabel & obj );
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index 2be8076..c93bbcc 100644 (file)
@@ -1488,13 +1488,29 @@ namespace zypp
     std::string TargetImpl::targetDistribution( const Pathname & root_r )
     { return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
 
-
     std::string TargetImpl::targetDistributionRelease() const
     { return baseproductdata( _root ).registerRelease(); }
     // static version:
     std::string TargetImpl::targetDistributionRelease( const Pathname & root_r )
     { return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
 
+    Target::DistributionLabel TargetImpl::distributionLabel() const
+    {
+      Target::DistributionLabel ret;
+      parser::ProductFileData pdata( baseproductdata( _root ) );
+      ret.shortName = pdata.shortName();
+      ret.summary = pdata.summary();
+      return ret;
+    }
+    // static version:
+    Target::DistributionLabel TargetImpl::distributionLabel( const Pathname & root_r )
+    {
+      Target::DistributionLabel ret;
+      parser::ProductFileData pdata( baseproductdata( staticGuessRoot(root_r) ) );
+      ret.shortName = pdata.shortName();
+      ret.summary = pdata.summary();
+      return ret;
+    }
 
     std::string TargetImpl::distributionVersion() const
     {
index 63fdc14..3de2af9 100644 (file)
@@ -163,6 +163,11 @@ namespace zypp
       static std::string targetDistributionRelease( const Pathname & root_r );
 
       /** \copydoc Target::distributionVersion()*/
+      Target::DistributionLabel distributionLabel() const;
+      /** \overload */
+      static Target::DistributionLabel distributionLabel( const Pathname & root_r );
+
+      /** \copydoc Target::distributionVersion()*/
       std::string distributionVersion() const;
       /** \overload */
       static std::string distributionVersion( const Pathname & root_r );