const std::vector<std::shared_ptr<ReaderUnit> > ReaderProvider::waitForReaders(std::vector<std::string> readers, double maxwait, bool all) { std::vector<std::shared_ptr<ReaderUnit> > ret; bool notfound = true; time_t timer, current_timer; time(&timer); while (notfound) { ret.clear(); time(¤t_timer); if (maxwait != 0 && difftime(current_timer, timer) > maxwait) return ret; refreshReaderList(); ReaderList rl = getReaderList(); for (ReaderList::iterator it = rl.begin(); it != rl.end(); ++it) { if (std::find(readers.begin(), readers.end(), (*it)->getName()) != readers.end()) ret.push_back(*it); } if ((all == false && ret.size() != 0) || (all == true && ret.size() == readers.size())) notfound = false; else std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } return ret; }
int main(int argc, char *argv[]) { ReaderList readers = ac::CorpusReaderFactory::readersAvailable(); for (ReaderList::const_iterator iter = readers.begin(); iter != readers.end(); ++iter) { std::cout << iter->description << " ( "; std::copy(iter->extensions.begin(), iter->extensions.end(), std::ostream_iterator<std::string>(std::cout, " ")); std::cout << "): "; // Corresponds with CorpusReader::readerAvailable? if (ac::CorpusReaderFactory::readerAvailable(iter->readerType)) std::cout << "OK"; else std::cout << "Error in readerAvailable!"; std::cout << std::endl; } return 0; }