struct _MsgTypeDef {
enum Enum { info, warning, error };
};
- typedef base::EnumClass<_MsgTypeDef> MsgType; ///< 'enum class MsgType'
- // virtual bool start()
- // virtual bool progress()
- // virtual bool problem()
- // virtual bool finish()
+ typedef base::EnumClass<_MsgTypeDef> MsgType; ///< 'enum class MsgType'
/** Send a ready to show message text. */
virtual bool message( MsgType type_r, const std::string & msg_r ) const { return true; }
- /** \overload */
- bool info( const std::string & msg_r ) const { return message( MsgType::info, msg_r ); }
- /** \overload */
- bool warning( const std::string & msg_r ) const { return message( MsgType::warning, msg_r ); }
- /** \overload */
- bool error( const std::string & msg_r ) const { return message( MsgType::error, msg_r ); }
+
+
+ /** \name Static sender instance */
+ //@{
+ /** Singleton sender instance */
+ static callback::SendReport<JobReport> & instance(); // impl in ZYppImpl.cc
+
+ /** send message text */
+ static bool info( const std::string & msg_r ) { return instance()->message( MsgType::info, msg_r ); }
+ /** send warning text */
+ static bool warning( const std::string & msg_r ) { return instance()->message( MsgType::warning, msg_r ); }
+ /** send error text */
+ static bool error( const std::string & msg_r ) { return instance()->message( MsgType::error, msg_r ); }
+ //@}
};
return;
HistoryLog historylog;
- callback::SendReport<JobReport> report;
Pathname noRootScriptDir( filesystem::TmpDir::defaultLocation() / tmpDir().basename() );
str::Str msg;
msg << "Output of " << pkgident << " %posttrans script:\n" << scriptmsg;
historylog.comment( msg, true /*timestamp*/);
- report->info( msg );
+ JobReport::info( msg );
}
if ( ret != 0 )
msg << pkgident << " %posttrans script failed (returned " << ret << ")";
WAR << msg << endl;
historylog.comment( msg, true /*timestamp*/);
- report->warning( msg );
+ JobReport::warning( msg );
}
}
}
return;
HistoryLog historylog;
- callback::SendReport<JobReport> report;
str::Str msg;
msg << "%posttrans scripts skipped while aborting:\n";
}
historylog.comment( msg, true /*timestamp*/);
- report->warning( msg );
+ JobReport::warning( msg );
_scripts.clear();
}
#include "zypp/sat/Pool.h"
#include "zypp/PoolItem.h"
+#include "zypp/ZYppCallbacks.h" // JobReport::instance
+
using std::endl;
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+
+ callback::SendReport<JobReport> & JobReport::instance()
+ {
+ static callback::SendReport<JobReport> _report;
+ return _report;
+ }
+
///////////////////////////////////////////////////////////////////
namespace zypp_detail
{ /////////////////////////////////////////////////////////////////