bool operator()( PoolItem_Ref p)
{
Source_Ref s = p->source();
+
if (s.alias() != source.alias()) {
return true;
}
print_pool (const string & prefix = "")
{
SortItem info;
-
+ cout << "Current pool:" << endl;
invokeOnEach( God->pool().begin( ),
God->pool().end ( ),
functor::functorRef<bool,PoolItem> (info) );
int count = 0;
try {
+ Url url("file://");
+
media::MediaManager mmgr;
- media::MediaId mediaid = mmgr.open(Url("file://"));
- Source_Ref::Impl_Ptr impl = new HelixSourceImpl (mediaid, pathname, alias);
- SourceFactory _f;
- Source_Ref s = _f.createFrom( impl );
-
- if (s != Source_Ref::noSource) {
- count = impl->resolvables (s).size();
- unsigned snum = manager->addSource (s);
- cout << "Added source '" << alias << "' as #" << snum << ":[" << s.alias() << "]" << endl;
- God->addResolvables( impl->resolvables (s), (alias == "@system") );
- print_pool ();
- }
+ media::MediaId mediaid = mmgr.open(url);
+ HelixSourceImpl *impl = new HelixSourceImpl ();
+ impl->factoryCtor (mediaid, pathname, alias);
+ Source_Ref src( SourceFactory().createFrom(impl) );
+
+ unsigned snum = manager->addSource (src);
+
+ count = src.resolvables().size();
+ cout << "Added source '" << alias << "' as #" << snum << ":[" << src.alias() << "] with " << count << " resolvables" << endl;
+ God->addResolvables( src.resolvables(), (alias == "@system") );
+ print_pool ();
+
cout << "Loaded " << count << " package(s) from " << pathname << endl;
}
catch ( Exception & excpt_r ) {
//---------------------------------------------------------------------------
-HelixSourceImpl::HelixSourceImpl(media::MediaId & mediaid_r, const Pathname & path_r, const std::string & alias_r)
- : SourceImpl (mediaid_r, path_r, alias_r)
- , _source (Source_Ref::noSource)
- , _pathname (path_r)
+HelixSourceImpl::HelixSourceImpl()
{
+ MIL << "HelixSourceImpl::HelixSourceImpl()" << endl;
}
void
-HelixSourceImpl::createResolvables(Source_Ref source_r)
+HelixSourceImpl::factoryInit()
{
- _source = source_r;
- MIL << "HelixSourceImpl::createResolvables()" << endl;
+ MIL << "HelixSourceImpl::factoryInit()" << endl;
+
+ try {
+ media::MediaManager media_mgr;
+ MIL << "Adding no media verifier" << endl;
+ media_mgr.delVerifier(_media);
+ media_mgr.addVerifier(_media, media::MediaVerifierRef(new media::NoVerifier()));
+ }
+ catch (const Exception & excpt_r)
+ {
+#warning FIXME: If media data is not set, verifier is not set. Should the media be refused instead?
+ ZYPP_CAUGHT(excpt_r);
+ WAR << "Verifier not found" << endl;
+ }
+ return;
+}
+
+void
+HelixSourceImpl::factoryCtor( const media::MediaId & media_r, const Pathname & path_r, const std::string & alias_r, const Pathname cache_dir_r)
+{
+ MIL << "HelixSourceImpl::factoryCtor(<media>, " << path_r << ", " << alias_r << ", " << cache_dir_r << ")" << endl;
+ _media = media_r;
+ _pathname = path_r;
+ _alias = alias_r;
+ _cache_dir = cache_dir_r;
+}
+
+
+void
+HelixSourceImpl::createResolvables(Source_Ref source)
+{
+ _source = source;
+
+ MIL << "HelixSourceImpl::createResolvables(" << _pathname << ", for source " << source.alias() << ")" << endl;
extractHelixFile (_pathname.asString(), this);
}
public:
/** Default ctor */
- HelixSourceImpl(media::MediaId & mediaid_r, const Pathname & path_r = "/", const std::string & alias_r = "");
+ HelixSourceImpl();
+
+ private:
+ /** Ctor substitute.
+ * Actually get the metadata.
+ * \throw EXCEPTION on fail
+ */
+ virtual void factoryInit();
+
+
+ public:
+ void factoryCtor( const media::MediaId & media_r,
+ const Pathname & path_r = "/",
+ const std::string & alias_r = "",
+ const Pathname cache_dir_r = "");
virtual const bool valid() const
{ return true; }
private:
Source_Ref _source;
- const Pathname _pathname;
+ Pathname _pathname;
void createResolvables(Source_Ref source_r);
};
INT << "===[START]==========================================" << endl;
Pathname p = argv[1];
+ Url url("file://");
+ string alias("helixparse");
+
+#if 0 // old SourceManager
media::MediaManager mmgr;
media::MediaId mediaid = mmgr.open(Url("file://"));
Source_Ref::Impl_Ptr impl = new HelixSourceImpl (mediaid, p);
SourceFactory _f;
- Source_Ref s = _f.createFrom( impl );
- ResStore store = s.resolvables();
+#endif
+#if 0 // via SourceFactory
+ Pathname cache_dir("");
+ Source_Ref src( SourceFactory().createFrom(url, p, alias, cache_dir) );
+#endif
+
+ // via HelixSourceImpl
+
+ media::MediaManager mmgr;
+ media::MediaId mediaid = mmgr.open(url);
+ HelixSourceImpl *impl = new HelixSourceImpl ();
+ MIL << "Calling factoryCtor()" << endl;
+ impl->factoryCtor (mediaid, p, alias);
+ MIL << "Calling createFromImpl()" << endl;
+ Source_Ref src( SourceFactory().createFrom(impl) );
+
+ ResStore store = src.resolvables();
for (ResStore::const_iterator it = store.begin();
it != store.end(); it++)
{