void Streams::unsubscribe(const Client& client,UInt32 id,const string& name) { Publications::Iterator it = publications(name); if(it == publications.end()) { DEBUG("The stream '%s' doesn't exists, unsubscribe useless",name.c_str()); return; } Publication& publication(*it->second); publication.removeListener(client,id); if(publication.publisherId()==0 && publication.listeners.count()==0) publications.destroy(it); }
void Streams::unpublish(const Client& client,UInt32 id,const string& name) { Publications::Iterator it = publications(name); if(it == publications.end()) { DEBUG("The stream '%s' with a %u id doesn't exist, unpublish useless",name.c_str(),id); return; } Publication& publication(*it->second); publication.stop(client,id); if(publication.publisherId()==0 && publication.listeners.count()==0) publications.destroy(it); }
int main() { Library UWLibrary; ifstream patrons("data4patrons.txt"); ifstream actions("data4commands.txt"); ifstream publications("data4books.txt"); if(!publications) { cout << "File not found" << endl; return 1; } UWLibrary.buildPatrons(patrons); UWLibrary.displayPatrons(); UWLibrary.buildShelf(publications); UWLibrary.displayShelf(); UWLibrary.buildLibrarian(actions); UWLibrary.runLibrarian(); UWLibrary.displayShelf(); return 0; };