Author: dmacvicar
Date: Sun May 6 18:04:53 2007
New Revision: 5496
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5496&view=rev
Log:
r5237@piscolita: duncan | 2007-05-02 17:38:30 +0200
- make test compile
Modified:
trunk/ (props changed)
trunk/libzypp/devel/devel.ma/Parse.cc
trunk/libzypp/tests/parser/yum/RepomdFileReader_test.cc
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/ProgressData.cc
trunk/libzypp/zypp/ProgressData.h
trunk/libzypp/zypp/data/ResolvableData.h
trunk/libzypp/zypp/parser/TagParser.cc
trunk/libzypp/zypp/parser/TagParser.h
trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc
Modified: trunk/libzypp/devel/devel.ma/Parse.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Parse.cc?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Parse.cc (original)
+++ trunk/libzypp/devel/devel.ma/Parse.cc Sun May 6 18:04:53 2007
@@ -23,7 +23,6 @@
#include "zypp/parser/tagfile/TagFileParser.h"
#include "zypp/parser/TagParser.h"
-#include "zypp/parser/susetags/PackagesFileReader.h"
using namespace std;
using namespace zypp;
@@ -119,41 +118,6 @@
}
-#include "zypp/ProgressData.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace susetags
- { /////////////////////////////////////////////////////////////////
-
- bool exampleReceiver( ProgressData::value_type v )
- {
- WAR << "got ->" << v << "%" << endl;
- return true;
- }
-
-
-
- /////////////////////////////////////////////////////////////////
- } // namespace susetags
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-using namespace zypp::parser::susetags;
-
-#include "zypp2/cache/CacheStore.h"
-
/******************************************************************
**
** FUNCTION NAME : main
@@ -164,45 +128,6 @@
//zypp::base::LogControl::instance().logfile( "log.restrict" );
INT << "===[START]==========================================" << endl;
- //try
- {
- //cache::CacheStore( "./store" );
- cache::CacheStore( "/home/ma/zypp-trunk/BUILD/libzypp/devel/devel.ma/store" );
- }
-
-#if 0
- try
- {
- ZYpp::Ptr z = getZYpp();
-
- Pathname dbfile( "data.db" );
- cache::CacheStore store(getenv("PWD"));
-
- data::RecordId catalog_id = store.lookupOrAppendCatalog( Url("http://www.google.com"), "/");
-
- PackagesParser parser( catalog_id, store);
- Measure m;
- parser.start(argv[1], &progress_function);
- m.elapsed();
- }
- catch ( const Exception &e )
- {
- cout << "ups! " << e.msg() << std::endl;
- }
-#endif
-
- INT << "===[END]============================================" << endl << endl;
- zypp::base::LogControl::instance().logNothing();
- return 0;
-
-
-
-
-
-
-
-
-
//Pathname p( "lmd/suse/setup/descr/packages" );
Pathname p( "packages" );
@@ -214,28 +139,28 @@
tp.parse( p );
}
- if ( 0 ) {
+ if ( 1 ) {
Pathname p( "p" );
Measure x( p.basename() );
- PackagesFileReader tp;
+ TagParser tp;
tp.parse( p );
}
- if ( 0 ) {
+ if ( 1 ) {
Pathname p( "p.gz" );
Measure x( p.basename() );
- PackagesFileReader tp;
+ TagParser tp;
tp.parse( p );
}
- if ( 0 ) {
+ if ( 1 ) {
Pathname p( "packages" );
Measure x( p.basename() );
- PackagesFileReader tp;
+ TagParser tp;
tp.parse( p );
}
if ( 1 ) {
Pathname p( "packages.gz" );
Measure x( p.basename() );
- PackagesFileReader tp;
+ TagParser tp;
tp.parse( p );
}
Modified: trunk/libzypp/tests/parser/yum/RepomdFileReader_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/yum/RepomdFileReader_test.cc?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/tests/parser/yum/RepomdFileReader_test.cc (original)
+++ trunk/libzypp/tests/parser/yum/RepomdFileReader_test.cc Sun May 6 18:04:53 2007
@@ -17,7 +17,8 @@
using namespace zypp;
using namespace boost::unit_test;
-using namespace zypp::source::yum;
+using namespace zypp::parser::yum;
+using source::yum::YUMResourceType;
class Collector
{
@@ -25,15 +26,15 @@
Collector()
{}
- bool callback( const OnMediaLocation &loc, const string &dtype )
+ bool callback( const OnMediaLocation &loc, const YUMResourceType &t )
{
- items.push_back( make_pair( dtype, loc ) );
+ items.push_back( make_pair( t, loc ) );
//items.push_back(loc);
//cout << items.size() << endl;
return true;
}
- vector > items;
+ vector > items;
//vector<OnMediaLocation> items;
};
@@ -64,7 +65,7 @@
string loc;
getline(ifs, dtype);
- BOOST_CHECK_EQUAL( collect.items[count].first, dtype);
+ BOOST_CHECK_EQUAL( collect.items[count].first, YUMResourceType(dtype));
getline(ifs, checksum_type);
getline(ifs, checksum);
BOOST_CHECK_EQUAL( collect.items[count].second.checksum(), CheckSum(checksum_type, checksum) );
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
(empty)
Modified: trunk/libzypp/zypp/ProgressData.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ProgressData.cc?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/zypp/ProgressData.cc (original)
+++ trunk/libzypp/zypp/ProgressData.cc Sun May 6 18:04:53 2007
@@ -27,67 +27,39 @@
// METHOD NAME : ProgressData::report
// METHOD TYPE : void
//
- bool ProgressData::report()
+ void ProgressData::report()
{
- // DISABLED to get DBG output from 'if ( doReport )'
- //if ( ! _d->_receiver )
- // return true;
-
- bool goOn = true; // continue per default
- bool doReport = false;
-
- // compute value and check whether to report it
if ( hasRange() )
{
value_type newVal = _d->_val * 100;
newVal /= ( _d->_max - _d->_min );
- if ( newVal - _d->_last_val > 20 || Date::now() - _d->_last_send > 1 || _d->_state == END )
+ if ( newVal - _d->_last_val > 5 || Date::now() - _d->_last_send > 1 || _d->_state == END )
{
+ DBG << str::form( "{%u|%s}(%d%%)",
+ numericId(), name().c_str(), newVal ) << endl;
_d->_last_val = newVal;
_d->_last_send = Date::now();
- doReport = true;
+ if ( _d->_state == INIT )
+ {
+ _d->_state = RUN;
+ }
}
}
else
{
if ( Date::now() - _d->_last_send > 1 || _d->_state == END )
{
+ DBG << str::form( "{%u|%s}(%d!)",
+ numericId(), name().c_str(), _d->_val ) << endl;
_d->_last_val = _d->_val;
_d->_last_send = Date::now();
- doReport = true;
- }
- }
-
- // report if necessary
- if ( doReport )
- {
- if ( _d->_state == INIT )
- {
- _d->_state = RUN;
+ if ( _d->_state == INIT )
+ {
+ _d->_state = RUN;
+ }
}
-
- if ( _d->_receiver )
- {
- goOn = _d->_receiver( _d->_last_val );
- }
- else
- {
- DBG << str::form( "{#%u|%s}(%lld%s)",
- numericId(), name().c_str(),
- _d->_last_val, ( hasRange() ? "%" : "!" ) ) << endl;
- }
- }
-
- // log abort request and return
- if ( ! goOn && _d->_state != END )
- {
- WAR << "User request to ABORT pending action. "
- << str::form( "{#%u|%s}(%lld%s)",
- numericId(), name().c_str(),
- _d->_last_val, ( hasRange() ? "%" : "!" ) ) << endl;
}
- return goOn;
}
/******************************************************************
Modified: trunk/libzypp/zypp/ProgressData.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ProgressData.h?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/zypp/ProgressData.h (original)
+++ trunk/libzypp/zypp/ProgressData.h Sun May 6 18:04:53 2007
@@ -16,7 +16,6 @@
#include <string>
#include "zypp/base/PtrTypes.h"
-#include "zypp/base/Function.h"
#include "zypp/base/ProvideNumericId.h"
#include "zypp/Date.h"
@@ -42,108 +41,15 @@
* Each ProgressData object provides a unique numeric id and you may assign
* it a name.
*
- * \code
- * bool exampleReceiver( ProgressData::value_type v )
- * {
- * DBG << "got ->" << v << endl;
- * return( v <= 100 ); // Abort if ( v > 100 )
- * }
- *
- * class Example
- * {
- * public:
- *
- * Example( const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() )
- * : _fnc( fnc_r )
- * {}
- *
- * void SendTo( const ProgressData::ReceiverFnc & fnc_r )
- * { _fnc = fnc_r; }
- *
- * public:
- *
- * void action()
- * {
- * ProgressData tics( 10 ); // Expect range 0 -> 10
- * tics.name( "test ticks" ); // Some arbitrary name
- * tics.sendTo( _fnc ); // Send reports to _fnc
- * tics.toMin(); // start sending min (0)
- *
- * for ( int i = 0; i < 10; ++i )
- * {
- * if ( ! tics.set( i ) )
- * return; // user requested abort
- * }
- *
- * tics.toMax(); // take care 100% are reported on success
- * }
- *
- * void action2()
- * {
- * ProgressData tics; // Just send 'still alive' messages
- * tics.name( "test ticks" ); // Some arbitrary name
- * tics.sendTo( _fnc ); // Send reports to _fnc
- * tics.toMin(); // start sending min (0)
- *
- * for ( int i = 0; i < 10; ++i )
- * {
- * if ( ! tics.set( i ) )
- * return; // user requested abort
- * }
- *
- * tics.toMax(); //
- * }
- *
- * private:
- * ProgressData::ReceiverFnc _fnc;
- * };
- * \endcode
- * \code
- * Example t( exampleReceiver );
- * DBG << "Reporting %:" << endl;
- * t.action();
- * DBG << "Reporting 'still alive':" << endl;
- * t.action2();
- * \endcode
- * \code
- * Reporting %:
- * got ->0
- * got ->10
- * got ->20
- * got ->30
- * got ->40
- * got ->50
- * got ->60
- * got ->70
- * got ->80
- * got ->90
- * got ->100
- * got ->100
- * Reporting 'still alive':
- * got ->0
- * got ->9
- * \endcode
- *
- * The different ammount of triggers is due to different rules for sending
- * percent or 'still alive' messages.
- *
- * \todo Complete the progess sending.
- * \todo Tell recipient whether percentage or keepalive is sent,
- * the id and name might be helpfull, and maybe tell whether task
- * is abortable or not; i.e extend the ReceiverFnc signature.
+ * \todo complete the progess sending.
*/
class ProgressData : public base::ProvideNumericId
{
public:
typedef long long value_type;
- /** Most simple version of progress reporting - a single value.
- * The percentage in most cases. Sometimes just keepalive.
- */
- typedef function ReceiverFnc;
-
- private:
enum State { INIT, RUN, END };
+ private:
class Data
{
public:
@@ -153,15 +59,14 @@
{}
public:
- State _state;
+ State _state;
std::string _name;
- value_type _min;
- value_type _max;
- value_type _val;
-
- ReceiverFnc _receiver;
- value_type _last_val;
- Date _last_send;
+ value_type _min;
+ value_type _max;
+ value_type _val;
+
+ value_type _last_val;
+ Date _last_send;
private:
/** clone for RWCOW_pointer */
@@ -200,6 +105,27 @@
}
public:
+ /** @return Current \c min value. */
+ value_type min() const
+ { return _d->_min; }
+
+ /** @return Current \c max value. */
+ value_type max() const
+ { return _d->_max; }
+
+ /** @return Current counter \c value. */
+ value_type val() const
+ { return _d->_val; }
+
+ /** @return Wheter <tt>[min,max]</tt> defines a nonempty range. */
+ bool hasRange() const
+ { return min() != max(); }
+
+ /** @return The counters name. */
+ const std::string & name() const
+ { return _d->_name; }
+
+ public:
/** Set new \c min value. */
void min( value_type min_r )
{ _d->_min = min_r; }
@@ -221,87 +147,41 @@
{ min( min_r ); max( max_r ); }
public:
- /** Set counter name. */
- void name( const std::string & name_r )
- { _d->_name = name_r; }
-
- /** Set ReceiverFnc. */
- void sendTo( const ReceiverFnc & fnc_r )
- { _d->_receiver = fnc_r; }
-
- /** Set no ReceiverFnc. */
- void noSend()
- { _d->_receiver = ReceiverFnc(); }
-
- public:
- /** \name Progress reporting.
- *
- * These methods may actually cause a progress report to be sent.
- *
- * All methods return \c bool, because a progress receiver may
- * return \c false to indicate the desire to abort the pending
- * action. The incident is logged, but it's finaly up to the caller
- * to honor this.
- */
- //@{
-
/** Set new counter \c value. */
- bool set( value_type val_r )
+ void set( value_type val_r )
{
_d->_val = val_r;
- return report();
+ report();
}
/** Increment counter \c value (default by 1). */
- bool incr( value_type val_r = 1 )
- { return set( val() + val_r ); }
+ void incr( value_type val_r = 1 )
+ { set( val() + val_r ); }
/** Decrement counter \c value (default by 1). */
- bool decr( value_type val_r = 1 )
- { return set( val() - val_r ); }
+ void decr( value_type val_r = 1 )
+ { set( val() - val_r ); }
/** Set counter value to current \c min value. */
- bool toMin()
- { return set( min() ); }
+ void toMin()
+ { set( min() ); }
/** Set counter value to current \c max value (unless no range). */
- bool toMax()
- { return set( hasRange() ? max() : val() ); }
+ void toMax()
+ { if ( hasRange() ) set( max() ); }
/** Leave counter value unchanged (still alive). */
- bool tick()
- { return set( val() ); }
-
- //@}
+ void tick()
+ { set( val() ); }
public:
- /** @return Current \c min value. */
- value_type min() const
- { return _d->_min; }
-
- /** @return Current \c max value. */
- value_type max() const
- { return _d->_max; }
-
- /** @return Current counter \c value. */
- value_type val() const
- { return _d->_val; }
-
- /** @return Wheter <tt>[min,max]</tt> defines a nonempty range. */
- bool hasRange() const
- { return min() != max(); }
-
- /** @return The counters name. */
- const std::string & name() const
- { return _d->_name; }
-
- /** @return The ReceiverFnc. */
- const ReceiverFnc & receiver() const
- { return _d->_receiver; }
+ /** Set counter name. */
+ void name( const std::string & name_r )
+ { _d->_name = name_r; }
private:
/** Send report if necessary. */
- bool report();
+ void report();
/** Pointer to data. */
RWCOW_pointer<Data> _d;
Modified: trunk/libzypp/zypp/data/ResolvableData.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/data/ResolvableData.h?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/zypp/data/ResolvableData.h (original)
+++ trunk/libzypp/zypp/data/ResolvableData.h Sun May 6 18:04:53 2007
@@ -75,6 +75,7 @@
std::string vendor;
/** Installed size. \see zypp::ResObject::size() */
+ /** Installed size. \see zypp::ResObject::size() */
ByteCount size;
/** RPM package size. \see zypp::ResObject::archive_size() */
ByteCount archive_size;
@@ -93,10 +94,6 @@
virtual std::ostream & dumpOn( std::ostream & str ) const;
};
- ///////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(AtomBase);
-
class AtomBase : public ResObject
{
public:
Modified: trunk/libzypp/zypp/parser/TagParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/TagParser.cc?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/TagParser.cc (original)
+++ trunk/libzypp/zypp/parser/TagParser.cc Sun May 6 18:04:53 2007
@@ -15,8 +15,6 @@
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
#include "zypp/base/IOStream.h"
-#include "zypp/base/UserRequestException.h"
-#include "zypp/parser/tagfile/ParseException.h"
#include "zypp/parser/TagParser.h"
#include "zypp/ProgressData.h"
@@ -95,9 +93,6 @@
void TagParser::endParse()
{}
- void TagParser::userRequestedAbort( unsigned lineNo_r )
- { ZYPP_THROW( AbortRequestException( errPrefix( lineNo_r ) ) ); }
-
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : TagParser::errPrefix
@@ -195,16 +190,14 @@
// METHOD NAME : TagParser::parse
// METHOD TYPE : void
//
- void TagParser::parse( const InputStream & input_r, const ProgressData::ReceiverFnc & fnc_r )
+ void TagParser::parse( const InputStream & input_r )
{
MIL << "Start parsing " << input_r << endl;
_inputname = input_r.name();
beginParse();
ProgressData ticks( makeProgressData( input_r ) );
- ticks.sendTo( fnc_r );
- if ( ! ticks.toMin() )
- userRequestedAbort( 0 );
+ ticks.toMin();
iostr::EachLine line( input_r );
for( ; line; line.next() )
@@ -324,13 +317,10 @@
break;
}
-
- if ( ! ticks.set( input_r.stream().tellg() ) )
- userRequestedAbort( line.lineNo() );
+ ticks.set( input_r.stream().tellg() );
}
- if ( ! ticks.toMax() )
- userRequestedAbort( line.lineNo() );
+ ticks.toMax();
endParse();
_inputname.clear();
Modified: trunk/libzypp/zypp/parser/TagParser.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/TagParser.h?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/TagParser.h (original)
+++ trunk/libzypp/zypp/parser/TagParser.h Sun May 6 18:04:53 2007
@@ -20,7 +20,7 @@
#include "zypp/base/NonCopyable.h"
#include "zypp/base/InputStream.h"
-#include "zypp/ProgressData.h"
+#include "zypp/parser/tagfile/ParseException.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -29,6 +29,8 @@
namespace parser
{ /////////////////////////////////////////////////////////////////
+ using tagfile::ParseException;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : TagParser
@@ -82,15 +84,13 @@
/** Dtor */
virtual ~TagParser();
/** Parse the stream.
- * \throw ParseExcetion on errors.
- * \throws AbortRequestException on user request.
- * Invokes \ref consume for each tag. \ref consume might throw
- * other exceptions as well.
+ * \throw ParseExcetion on errors. Invoke \ref consume
+ * for each tag. \ref consume might throw other exceptions
+ * as well.
*/
- virtual void parse( const InputStream & imput_r,
- const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() );
+ void parse( const InputStream & imput_r );
- protected:
+ public:
/** Called when start parsing. */
virtual void beginParse();
/** Called when a single-tag is found. */
@@ -100,13 +100,7 @@
/** Called when the parse is done. */
virtual void endParse();
- protected:
- /** Called when user(callback) request to abort.
- * \throws AbortRequestException unless overloaded.
- */
- virtual void userRequestedAbort( unsigned lineNo_r );
-
- protected:
+ public:
/** Prefix exception message with line and tag information. */
std::string errPrefix( unsigned lineNo_r,
const std::string & msg_r = std::string() ) const;
@@ -122,6 +116,7 @@
private:
std::string _inputname;
+ //ProgressData _ticks;
};
///////////////////////////////////////////////////////////////////
@@ -134,14 +129,6 @@
/** \relates TagParser::MultiTag Stream output. */
std::ostream & operator<<( std::ostream & str, const TagParser::MultiTag & obj );
- template<class _D>
- inline std::ostream & operator<<( std::ostream & str, const shared_ptr<_D> & obj )
- {
- if ( obj )
- return str << *obj;
- return str << std::string("NULL");
- }
-
/////////////////////////////////////////////////////////////////
} // namespace parser
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc?rev=5496&r1=5495&r2=5496&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/yum/PrimaryFileReader.cc Sun May 6 18:04:53 2007
@@ -110,7 +110,7 @@
if (reader_r->name() == "packager")
{
_package->packager = reader_r.nodeText().asString();
-// DBG << "packager: " << _package->packager << endl;
+// DBG << "packager: " << _package->packager << endl;
return true;
}
@@ -134,10 +134,12 @@
// reader_r->getAttribute("archive").asString();
// installed size
- _package->size = str::strtonumByteCount::SizeType( reader_r->getAttribute("installed").asString() );
+ ByteCount size(str::strtonum<long long>(reader_r->getAttribute("installed").asString()), Unit());
+ _package->size = size;
// rpm package size
- _package->archive_size = str::strtonumByteCount::SizeType( reader_r->getAttribute("package").asString() );
+ ByteCount size_rpm(str::strtonum<long long>(reader_r->getAttribute("package").asString()), Unit());
+ _package->archive_size = size_rpm;
return true;
}
@@ -308,7 +310,7 @@
_expect_rpm_entry = true;
return true;
}
-
+
if (reader_r->name() == "file")
{
// TODO figure out how to read files
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org