Element writeSoftwareRadio( RadioRepresentation &swrDesc) { Element e("softwareradio"); //Write all the controllers vector<ControllerDescription> controllers = swrDesc.getControllers(); vector<ControllerDescription>::iterator conIt; for(conIt=controllers.begin();conIt!=controllers.end();conIt++) { Element currentController = writeController(*conIt); e.InsertEndChild(currentController); } //Write all the engines vector<EngineDescription> engines = swrDesc.getEngines(); vector<EngineDescription>::iterator engIt; for(engIt=engines.begin();engIt!=engines.end();engIt++) { Element currentEngine = writeEngine(*engIt); e.InsertEndChild(currentEngine); } //Write all the links vector<LinkDescription> links = swrDesc.getLinks(); vector<LinkDescription>::iterator linkIt; for(linkIt=links.begin();linkIt!=links.end();linkIt++) { Element currentLink = writeLink(*linkIt); e.InsertEndChild(currentLink); } return e; }
void EngineManager::loadRadio(RadioRepresentation rad) { //Set the current radio representation radioRep_ = rad; //Set the controller repositories in the ControllerManager controllerManager_.addRepository(reps_.contRepository); //Load the controllers vector<ControllerDescription> conts = rad.getControllers(); vector<ControllerDescription>::iterator contIt; for(contIt=conts.begin(); contIt!=conts.end(); ++contIt) { controllerManager_.loadController(contIt->type); } engineGraph_ = rad.getEngineGraph(); //Create the engines EngVertexIterator i, iend; for(b::tie(i,iend) = vertices(engineGraph_); i != iend; ++i) { //Get the engine description EngineDescription current = engineGraph_[*i]; //Add the engine to our vector engines_.push_back(createEngine(current)); } //Do a topological sort of the graph deque<unsigned> topoOrder; topological_sort(engineGraph_, front_inserter(topoOrder), b::vertex_index_map(b::identity_property_map())); //Go through graph in topological order and set buffers for(deque<unsigned>::iterator i = topoOrder.begin(); i != topoOrder.end(); ++i) { //Get input buffers vector< b::shared_ptr< DataBufferBase > > inputBuffers, outputBuffers; EngInEdgeIterator edgeIt, edgeItEnd; for(b::tie(edgeIt, edgeItEnd) = in_edges(*i, engineGraph_); edgeIt != edgeItEnd; ++edgeIt) { inputBuffers.push_back(engineGraph_[*edgeIt].theBuffer); } //Load the engine, passing in the input buffers outputBuffers = engines_[*i].loadEngine(engineGraph_[*i], inputBuffers); //Set the ouput buffers in the graph edges EngOutEdgeIterator outEdgeIt, outEdgeItEnd; for(b::tie(outEdgeIt, outEdgeItEnd) = out_edges(*i, engineGraph_); outEdgeIt != outEdgeItEnd; ++outEdgeIt) { for(vector< b::shared_ptr< DataBufferBase > >::iterator it = outputBuffers.begin(); it != outputBuffers.end(); ++it) { LinkDescription first = (*it)->getLinkDescription(); LinkDescription second = engineGraph_[*outEdgeIt]; if(sameLink(first, second)) { engineGraph_[*outEdgeIt].theBuffer = *it; engineGraph_[*outEdgeIt].theBuffer->setLinkDescription( second ); } } } } }