ResPoolManager.h\
Package.h \
Pathname.h \
- Selection.h \
Source.h \
SourceFactory.h \
SourceManager.h \
ResPoolManager.cc\
Package.cc \
Pathname.cc \
- Selection.cc \
Source.cc \
SourceFactory.cc\
SourceManager.cc\
void Source::disable()
{ _pimpl->disable(); }
- string Source::name (void) const
- { _pimpl->name(); }
+ string Source::alias (void) const
+ { _pimpl->alias(); }
/////////////////////////////////////////////////////////////////
void disable();
- std::string name (void) const;
+ std::string alias (void) const;
};
///////////////////////////////////////////////////////////////////
media->close();
}
- Source SourceFactory::createFrom( const Url & url_r, const Pathname & path_r )
+ Source SourceFactory::createFrom( const Url & url_r, const Pathname & path_r, const std::string & alias_r )
{
if (! url_r.isValid())
ZYPP_THROW( Exception("Empty URL passed to SourceFactory") );
try
{
MIL << "Trying the YUM source" << endl;
- Source::Impl_Ptr impl = new yum::YUMSourceImpl(media, path_r);
+ Source::Impl_Ptr impl = new yum::YUMSourceImpl(media, path_r, alias_r);
MIL << "Found the YUM source" << endl;
return Source(impl);
}
try
{
MIL << "Trying the SUSE tags source" << endl;
- Source::Impl_Ptr impl = new susetags::SuseTagsImpl(media, path_r);
+ Source::Impl_Ptr impl = new susetags::SuseTagsImpl(media, path_r, alias_r);
MIL << "Found the SUSE tags source" << endl;
return Source(impl);
}
#define ZYPP_SOURCEFACTORY_H
#include <iosfwd>
+#include <string>
#include "zypp/base/PtrTypes.h"
/** Construct source from an implementation.
* \throw EXCEPTION on fail
*/
- Source createFrom( const Url & url_r, const Pathname & path_r = "/" );
+ Source createFrom( const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "" );
private:
/** Implementation */
SourceManager::~SourceManager()
{}
- unsigned SourceManager::addSource(const Url & url_r, const Pathname & path_r)
+ unsigned SourceManager::addSource(const Url & url_r, const Pathname & path_r, const std::string & name_r)
{
- Source src = SourceFactory().createFrom(url_r, path_r);
+ Source src = SourceFactory().createFrom(url_r, path_r, name_r);
RW_pointer<Source> src_ptr = RW_pointer<Source>(new Source(src));
_sources[_next_id] = src_ptr;
return _next_id++;
}
}
+ void SourceManager::removeSource(const std::string & alias_r)
+ {
+ for (SourceMap::iterator it = _sources.begin(); it != _sources.end(); ++it)
+ {
+ if (it->second->alias() == alias_r) {
+ _sources.erase(it);
+ break;
+ }
+ }
+ }
+
void SourceManager::disableAllSources()
{
for( SourceMap::iterator it = _sources.begin(); it != _sources.end(); it++)
return *(it->second);
}
+ Source & SourceManager::findSource(const std::string & alias_r)
+ {
+ SourceMap::iterator it;
+ for (it = _sources.begin(); it != _sources.end(); ++it)
+ {
+ if (it->second->alias() == alias_r) {
+ return *(it->second);
+ break;
+ }
+
+ }
+ ZYPP_THROW(Exception("Unknown source name '"+alias_r+"'"));
+ /*NOTREACHED*/
+ return *(it->second); // just to keep gcc happy
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Source & findSource(const unsigned id);
/**
+ * Find a source with a specified alias
+ *
+ * \throws Exception
+ */
+ Source & findSource(const std::string & alias_r);
+
+ /**
* Add a new source
*
* \throws Exception
*/
- unsigned addSource(const Url & url_r, const Pathname & path_r = "/");
+ unsigned addSource(const Url & url_r, const Pathname & path_r = "/", const std::string & name_r = "");
/**
* Add a new source
unsigned addSource(Source & source_r);
/**
- * Remove an existing source
+ * Remove an existing source by ID
*
* \throws Exception
*/
void removeSource(const unsigned id);
/**
+ * Remove an existing source by Alias
+ *
+ * \throws Exception
+ */
+ void removeSource(const std::string & alias_r);
+
+ /**
* Disable all registered sources
*/
#warning: this could be done by providing iterator-like methods
{
static std::ostream & outStr( getenv("ZYPP_NOLOG") ? noStream()
: std::cerr );
- return outStr
+ return cerr
<< str::form( "<%d> [%s] %s(%s):%d ",
level_r, group_r,
file_r, func_r, line_r );
//
SourceImpl::SourceImpl(media::MediaAccess::Ptr & media_r,
const Pathname & path_r,
- const std::string & name_r)
+ const std::string & alias_r)
: _media(media_r)
, _path(path_r)
, _enabled(true)
, _res_store_initialized(false)
- , _name (name_r)
+ , _alias (alias_r)
{}
///////////////////////////////////////////////////////////////////
/** Ctor. */
SourceImpl(media::MediaAccess::Ptr & media_r,
const Pathname & path_r = "/",
- const std::string & name = "");
+ const std::string & alias = "");
/** Dtor. */
virtual ~SourceImpl();
void disable()
{ _enabled = false; }
- std::string name (void) const
- { return _name; }
+ std::string alias (void) const
+ { return _alias; }
/** Overload to realize stream output. */
virtual std::ostream & dumpOn( std::ostream & str ) const
Pathname _path;
/** The source is enabled */
bool _enabled;
- /** (user defined) name of the source */
- std::string _name;
+ /** (user defined) alias of the source */
+ std::string _alias;
private:
/** Null implementation */
static SourceImpl_Ptr _nullimpl;
// METHOD NAME : SuseTagsImpl::SuseTagsImpl
// METHOD TYPE : Ctor
//
- SuseTagsImpl::SuseTagsImpl( media::MediaAccess::Ptr & media_r, const Pathname & path_r )
- : SourceImpl(media_r, path_r)
+ SuseTagsImpl::SuseTagsImpl( media::MediaAccess::Ptr & media_r, const Pathname & path_r, const std::string & alias_r )
+ : SourceImpl(media_r, path_r, alias_r)
{
#warning TODO check if the source is of this type
}
#define ZYPP_SOURCE_SUSETAGS_SUSETAGSIMPL_H
#include <iosfwd>
+#include <string>
#include "zypp/Pathname.h"
#include "zypp/source/SourceImpl.h"
*/
SuseTagsImpl( const Pathname & localDir_r );
/** Factory ctor */
- SuseTagsImpl( media::MediaAccess::Ptr & media_r, const Pathname & path_r = "/" );
+ SuseTagsImpl( media::MediaAccess::Ptr & media_r, const Pathname & path_r = "/", const std::string & alias_r = "");
/** Dtor */
~SuseTagsImpl();
/** Default ctor
*/
YUMSourceImpl::YUMSourceImpl(media::MediaAccess::Ptr & media_r,
- const Pathname & path_r)
- : SourceImpl(media_r, path_r)
+ const Pathname & path_r,
+ const std::string & alias_r)
+ : SourceImpl(media_r, path_r, alias_r)
{
try {
// first read list of all files in the reposotory
YUMSourceImpl()
{}
/** Default ctor */
- YUMSourceImpl(media::MediaAccess::Ptr & media_r, const Pathname & path_r = "/");
+ YUMSourceImpl(media::MediaAccess::Ptr & media_r, const Pathname & path_r = "/", const std::string & alias_r = "");
virtual void createResolvables(Source & source_r);