{
MIL << "Going to delete repo " << alias << endl;
- const Service& service = getService( alias );
+ const Service & service = getService( alias );
Pathname location = service.location();
if( location.empty() )
parser::ServiceFileReader reader( location,
bind(&Impl::ServiceCollector::collect,collector,_1) );
- if ( tmpSet.size() == 1 ) //only one record
+ // only one service definition in the file
+ if ( tmpSet.size() == 1 )
{
if ( filesystem::unlink(location) != 0 )
{
MIL << alias << " sucessfully deleted from file " << location << endl;
}
- //now remove all repositories added by this service
+ // now remove all repositories added by this service
+ RepoCollector rcollector;
getRepositoriesInService( alias,
boost::make_function_output_iterator(
- bind(&RepoManager::removeRepository, this, _1, ProgressData::ReceiverFnc()) ) );
+ bind( &RepoCollector::collect, &rcollector, _1 ) ) );
+ // cannot do this directly in getRepositoriesInService - would invalidate iterators
+ for_(rit, rcollector.repos.begin(), rcollector.repos.end())
+ removeRepository(*rit);
}
+ void RepoManager::removeService( const Service & service )
+ { removeService(service.alias()); }
+
+
void RepoManager::Impl::saveService( const Service & service ) const
{
filesystem::assert_dir( options.knownServicesPath );
Service RepoManager::getService( const std::string & alias ) const
{
- ServiceConstIterator it = _pimpl->services.find(alias);
- if ( it == serviceEnd() )
- return Service::noService;
- else
- return *it;
+ for_ (it, serviceBegin(), serviceEnd())
+ if ( it->alias() == alias )
+ return *it;
+ return Service::noService;
}
bool RepoManager::serviceEmpty() const { return _pimpl->services.empty(); }
*/
void removeService( const std::string & alias );
+ void removeService( const Service & service );
+
/**
* Gets true if no service is in RepoManager (so no one in specified location)
*
};
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.
- * \param name service name
- * \param out output iterator which get all repositories in Service
+ *
+ * \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) {}
- * void doIt( RepoInfo info ) { info.setPriority(priority); } //missing rewrite priority back via RepoManager::modifyRepo
+ * 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,getRepositoriesInService( name, boost::make_function_output_iterator(bind(&ChangePriority::doIt, &changer, _1))));
+ * getRepositoriesInService(name,
+ * boost::make_function_output_iterator(
+ * bind(&ChangePriority::doIt, &changer, _1)));
* \endcode
*/
-
template<typename OutputIterator>
void getRepositoriesInService( const std::string & alias,
OutputIterator out ) const
{
MatchServiceAlias filter(alias);
- std::copy(boost::make_filter_iterator(bind(&MatchServiceAlias::match,
- filter, _1),repoBegin(),repoEnd()), boost::make_filter_iterator(
+ 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 );
+ out);
}
protected: