// Copyright (C) 1998-1999 Jean-Marc Valin #include "gmm_set.h" #include "ObjectParser.h" using namespace std; namespace FD { DECLARE_TYPE(GMMSet) //@implements GMM int GMMSet::getIDFor(RCPtr cov) { for (int i=0;i GMMSet::getPtrFor(int id) { if (id>=nb_gmms) throw new GeneralException("Invalid gmm ID", __FILE__, __LINE__); return gmms[id]; } void GMMSet::toIDs(GaussianSet & gauss) { for (int i=0;itoIDsUsing(gauss); } } void GMMSet::toPtrs(const GaussianSet & gauss) const { for (int i=0;itoPtrsUsing(gauss); } } void GMMSet::printOn(ostream &out) const { out << "" << endl; out << "" << endl; out << ">\n"; } void GMMSet::readFrom (istream &in) { string tag; while (1) { char ch; in >> ch; if (ch == '>') break; else if (ch != '<') throw new ParsingException ("GMMSet::readFrom : Parse error: '<' expected"); in >> tag; if (tag == "gmms") in >> gmms; else if (tag == "nb_gmms") in >> nb_gmms; else throw new ParsingException ("GMMSet::readFrom : unknown argument: " + tag); if (!in) throw new ParsingException ("GMMSet::readFrom : Parse error trying to build " + tag); in >> tag; if (tag != ">") throw new ParsingException ("GMMSet::readFrom : Parse error: '>' expected "); } } istream &operator >> (istream &in, GMMSet &cov) { if (!isValidType(in, "GMMSet")) return in; cov.readFrom(in); return in; } }//namespace FD