#include #include #include #include "inputFile.h" #include "ouvinteInput.h" InputFile::InputFile(char* path) { this->path = path; this->ouvintes = new list(); finished = false; } InputFile::~InputFile(){ if (ouvintes) { ouvintes->clear(); delete ouvintes; } } void InputFile::initialize(){ printf("InputFile::initialize()\n"); ifstream filein(path, ifstream::binary); if (filein.is_open()) { char buffer [MAX_SIZE_PACKET]; while (!filein.eof()) { filein.read(buffer, MAX_SIZE_PACKET); unsigned char* packet = (unsigned char*) buffer; notificaOuvintes(packet); } filein.close(); finished = true; } else { finished = true; printf("\n# Erro! verifique se existe algum problema com o arquivo: %s\n\n", path); } } bool InputFile::isFinished(){ return this->finished; } void InputFile::registraOuvinte(OuvinteInput* ouvinte){ this->ouvintes->push_back(ouvinte); } void InputFile::removeOuvinte(OuvinteInput* ouvinte) { this->ouvintes->remove(ouvinte); } void InputFile::notificaOuvintes(unsigned char* pacote){ //printf("InputFile::notificaOuvintes"); for(list::iterator it = this->ouvintes->begin(); it != this->ouvintes->end(); it++){ (*it)->chegouInput(pacote); } } /*void InputFile::notificaQuantidadeGlosas(int quantidade){ //printf("InputFile::notificaOuvintes"); for(list::iterator it = this->ouvintes->begin(); it != this->ouvintes->end(); it++){ (*it)->finalizouInput(); } }*/