///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- class Service; //predef
+ class ServiceInfo; //predef
/**
* Parses \a repo_file and returns a list of \ref RepoInfo objects
Pathname knownReposPath;
Pathname knownServicesPath;
bool probe;
+ /**
+ * Target distro ID to be used when refreshing repo index services.
+ * Repositories not maching this ID will be skipped/removed.
+ *
+ * The value is initialized upon construction to
+ * \ref Target::targetDistribution() if the Target is already initialized,
+ * otherwise the value is initially empty.
+ *
+ * If empty, no repositories contained in the index will be skipped.
+ */
+ std::string servicesTargetDistro;
};
class Impl;
/** service typedefs */
- typedef std::set<Service> ServiceSet;
+ typedef std::set<ServiceInfo> ServiceSet;
typedef ServiceSet::const_iterator ServiceConstIterator;
typedef ServiceSet::size_type ServiceSizeType;
- //RepoInfo typedefs
+ /** RepoInfo typedefs */
typedef std::set<RepoInfo> RepoSet;
typedef RepoSet::const_iterator RepoConstIterator;
typedef RepoSet::size_type RepoSizeType;
* The known repositories are read from
* \ref RepoManagerOptions::knownReposPath passed on the Ctor.
* Which defaults to ZYpp global settings.
- * \deprecated use iterator instead which read only one time directory
* \return found list<RepoInfo>
*/
- ZYPP_DEPRECATED std::list<RepoInfo> knownRepositories() const;
+ std::list<RepoInfo> knownRepositories() const;
bool repoEmpty() const;
RepoSizeType repoSize() const;
*
* \throws repo::RepoAlreadyExistsException If the repo clash some
* unique attribute like alias
- * \throws RepoUnknownType If repository type can't be determined
- * \throws RepoException If the access to the url fails (while probing).
+ * \throws RepoUnknownType
+ * If RepoManagerOptions::probe is true
+ * and repository type can't be determined.
+ * \throws RepoException
+ * If RepoManagerOptions::probe is true and access to the url fails.
* \throws Exception On other errors.
*/
void addRepository( const RepoInfo &info,
* \param url Url of the repo file
*
* \throws repo::RepoAlreadyExistsException If the repo clash some
- * unique attribute like alias
- *
- * \throws RepoAlreadyExistsException
+ * unique attribute like alias
* \throws MediaException If the access to the url fails
* \throws ParseException If the file parsing fails
* \throws RepoUnknownType If repository type can't be determined
const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
- void addService( const std::string& name, const Url& url );
- void addService( const Service& name );
+ /**
+ * Adds new service by it's alias and url
+ *
+ * \param alias unique identifier of the service
+ * \param url url to service
+ *
+ * \throws FIXME RepoAlreadyExistException and as reponame is service name
+ */
+ void addService( const std::string & alias, const Url& url );
+
+ /**
+ * Adds new service
+ *
+ * \param service service info
+ *
+ * \throws FIXME RepoAlreadyExistException and as reponame is service name
+ */
+ void addService( const ServiceInfo & service );
+
+ /**
+ * Removes service specified by its name
+ *
+ * \param alias unique indientifier of the service to remove
+ *
+ * \throws RepoException if service is not found or file with ServiceInfo cannot be deleted
+ * \throws Exception if file contain more services and rewrite file failed
+ */
+ void removeService( const std::string & alias );
- void removeService( const std::string& name );
+ void removeService( const ServiceInfo & service );
+ /**
+ * Gets true if no service is in RepoManager (so no one in specified location)
+ *
+ * \return true if any ServiceInfo is in RepoManager
+ */
bool serviceEmpty() const;
+ /**
+ * Gets count of service in RepoManager (in specified location)
+ *
+ * \return count of service
+ */
ServiceSizeType serviceSize() const;
+ /**
+ * Iterator to first service in internal storage.
+ * \note Iterator is immutable, so you cannot change pointed ServiceInfo
+ * \return Iterator to first service
+ */
ServiceConstIterator serviceBegin() const;
+ /**
+ * Iterator to place behind last service in internal storage.
+ * \return iterator to end
+ */
ServiceConstIterator serviceEnd() const;
- const Service& getService( const std::string& name ) const;
+ /**
+ * Finds ServiceInfo by alias or return noService
+ *
+ * \param alias unique identifier of service
+ * \return information about service
+ */
+ ServiceInfo getService( const std::string & alias ) const;
+ /**
+ * Refreshes all enabled services.
+ *
+ * \see refreshService(ServiceInfo)
+ */
void refreshServices();
- void refreshService( const Service& name );
+ /**
+ * Refresh specific service.
+ *
+ * \param name service structure
+ * \throws MediaException If there's a problem downloading the repo index file.
+ */
+ void refreshService( const ServiceInfo & service );
/**
- * modify service
+ * Modifies service file (rewrites it with new values) and underlying
+ * repositories if needed.
+ *
+ * Modifications of a service can lead to rewrite of all .repo files of
+ * contained repositories. Particularily, disabling a service (changing
+ * ServiceInfo::enabled() from true to false) will disable all contained
+ * repositories. Renaming of a service will modify the "service" key
+ * of all contained repositories.
+ *
+ * \param oldAlias Old alias of the service
+ * \param service ServiceInfo object containing new data
+ *
+ * \throws RepoException if sservice with oldAlias is not known
+ * \throws Exception if have problems with files
*/
- void modifyService(const std::string& oldName, const Service& service);
+ void modifyService(const std::string & oldAlias, const ServiceInfo & service);
- struct MatchServiceName {
+ private:
+ /**
+ * Functor thats filter RepoInfo by service which belongs to.
+ */
+ struct MatchServiceAlias
+ {
private:
- std::string name;
+ std::string alias;
public:
- MatchServiceName( const std::string& name_ ) : name(name_) {}
- bool match( const RepoInfo& info ) { return info.service()==name; }
+ MatchServiceAlias( const std::string & alias_ ) : alias(alias_) {}
+ bool match( const RepoInfo & info ) { return info.service() == alias; }
};
- /**
- * fill to output iterator repositories in service name
- */
+ public:
+ /**
+ * fill to output iterator repositories in service name. This output iterator can perform
+ * any action on with Repo or service Container, because it is sets and it isn't dynamic recreate.
+ *
+ * \note Don't use this function with RepoManager::removeRepository(), it will lead to segfaults
+ * due to invalidated internal iterators. FIXME can this be solved (using STL) so that this
+ * warning would not be needed?
+ *
+ * \param alias service alias
+ * \param out output iterator which get all the repositories belonging to
+ * specified service
+ *
+ * example how set priority for each RepoInfo in this service:
+ * \code
+ * //functor
+ * class ChangePriority
+ * {
+ * private:
+ * int priority;
+ * public:
+ * ChangePriority(int prio) : priority(prio) {}
+ * // missing rewrite priority back via RepoManager::modifyRepo
+ * void doIt( RepoInfo info ) { info.setPriority(priority); }
+ * }
+ *
+ * //somewhere in code
+ * ChangePriority changer(10);
+ * getRepositoriesInService(name,
+ * boost::make_function_output_iterator(
+ * bind(&ChangePriority::doIt, &changer, _1)));
+ * \endcode
+ */
template<typename OutputIterator>
- void getRepositoriesInService( const std::string& name, OutputIterator out ) const
+ void getRepositoriesInService( const std::string & alias,
+ OutputIterator out ) const
{
- MatchServiceName filter(name);
-
- std::copy(boost::make_filter_iterator(bind(&MatchServiceName::match,
- filter, _1),repoBegin(),repoEnd()), boost::make_filter_iterator(
- bind(&MatchServiceName::match, filter, _1),repoEnd(),repoEnd()),
- out );
+ MatchServiceAlias filter(alias);
+
+ std::copy(
+ boost::make_filter_iterator(
+ bind(&MatchServiceAlias::match, filter, _1), repoBegin(), repoEnd()),
+ boost::make_filter_iterator(
+ bind(&MatchServiceAlias::match, filter, _1), repoEnd(), repoEnd()),
+ out);
}
protected: