bool GroupManager::removeGroup( String &name )
{
	boost::mutex::scoped_lock lock( guard );
	FRL_EXCEPT_GUARD();
	GroupElemNamesMap::iterator name_it = names_map.find( name );
	if( name_it == names_map.end() )
		FRL_THROW_S_CLASS( NotExistGroup );
	name_it->second->isDeleted( True );
	OPCHANDLE tmp_handle = name_it->second->getServerHandle();
	names_map.erase( name_it );
	
	GroupElemHandlesMap::iterator handle_it = handles_map.find( tmp_handle );
	if( handle_it == handles_map.end() )
		FRL_THROW_S_CLASS( NotExistGroup );
	Group *ptr = handle_it->second.get();
	ptr->AddRef();
	handles_map.erase( handle_it );
	return ptr->Release() == 0;
}
Exemple #2
0
STDMETHODIMP EnumGroup::Next( ULONG celt, IUnknown** rgelt, ULONG* pceltFetched )
{
	if( pceltFetched )
	{
		*pceltFetched = 0;
	}

	if( rgelt == NULL || ( celt != 1 && pceltFetched == NULL) )
	{
		return E_POINTER;
	}

	if( currentIndex >= groupList.size() )
		return S_FALSE;

	Group *pGroup;
	size_t i = currentIndex;
	size_t j = 0;
	for( ; i < groupList.size() && j < celt; ++i, ++j )
	{
		pGroup = groupList[i].get();
		rgelt[j] = reinterpret_cast< IUnknown*>( pGroup );
		if( pGroup != NULL  )
			pGroup->AddRef();
		if( pceltFetched )
			++(*pceltFetched);
	}

	if( j < celt )
	{
		currentIndex = groupList.size();
		return S_FALSE;
	}
	currentIndex = i;
	return S_OK;
}