Archived
This forum has been archived. Please start a new discussion on GitHub.
How to get all contacts in phonebook demo?
I test phonebook in Ice-3.0.1\demo\Freeze\phonebook,It used index,It can find someone's contacts ,
any ideas?Thanks!
But if I want to find all contacts ,how to do it?It seems like there is no the function in the index class of slice2freeze,Contacts
PhoneBookI::findContacts(const string& name, const Ice::Current& c) const
{
try
{
vector<Ice::Identity> identities = _index->find(name);
Contacts contacts;
contacts.reserve(identities.size());
transform(identities.begin(), identities.end(), back_inserter(contacts), IdentityToContact(c.adapter));
return contacts;
}
catch(const Freeze::DatabaseException& ex)
{
DatabaseException e;
e.message = ex.message;
throw e;
}
}
any ideas?Thanks!
0
Comments
-
You can use an iterator and iterate over the entire content of the phonebook. However, in general this isn't a very good idea since the database could contain millions of entries.0
-
which container should I search?
Thanks matthew,but I dont see,which container should I search?Could u show me which container I should search?
Regards
ewiniar0 -
Why?
in Ice-3.0.1\demo\Freeze\phonebook,It used index,I wonder how to list all contacts ,if I must define map in PhoneBook.ice?If not,then ,which container should I search?or other solution?Thanks!
Regards0 -
You create an iterator on the evictor. See Evictor::getIterator. This will return an iterator that you can use to get all of the identities that are managed by the evictor. Once you have the identities you can do whatever you can create a proxy to the object using the identity and do whatever you like.0
-
Thanks
Thanks matthew,I should investigate more carefully Ice manual,
Thans more!
Regards0