Exemplo n.º 1
0
void Signal::printOn(ostream &os) const
{
  //os<<getSignalType()<<"@"<<getConsensusPosition()<<":"<<*propagators[propagators[1] ? 1 :0];
  const int n=belongsInWhichQueues().size();
  os<<getSignalType()<<"@"<<getConsensusPosition();
  for(int i=0 ; i<n ; ++i) os<<">"<<*propagators[i];
}
Exemplo n.º 2
0
void jsonifyModule(const Module& module, rapidjson::Value& moduleValue, rapidjson::Document& document){
    moduleValue.SetObject();
    moduleValue.AddMember("name", module.getName().c_str(), document.GetAllocator());
    moduleValue.AddMember("description", module.getDescription().c_str(), document.GetAllocator());
    moduleValue.AddMember("type", module.getType().getName().c_str(), document.GetAllocator());

    //add inputs
    rapidjson::Value inputsValue;
    inputsValue.SetObject();
    for(unsigned int i=0; i<module.getInputSize(); ++i){
        auto inputLink = module.getInput(i);
        auto outputLink = inputLink->getOutputLink();
        //only add connected links
        if(outputLink){
            std::string sourceString = outputLink->getOwner().getName() + "." + outputLink->getModuleOutput().getName();
            rapidjson::Value source(sourceString.c_str(), document.GetAllocator());
            rapidjson::Value inputName(inputLink->getModuleInput().getName().c_str(), document.GetAllocator());
            inputsValue.AddMember(inputName, source, document.GetAllocator());
        } else {
            //add custom unlinked values
            rapidjson::Value vectorValue;
            vectorValue.SetArray();
            auto unlinkedValue = inputLink->getUnlinkedValue();
            for(int j=0; j<unlinkedValue.getSignalType().dimensionality; ++j){
                vectorValue.PushBack(unlinkedValue[j], document.GetAllocator());
            }
            rapidjson::Value inputName(inputLink->getModuleInput().getName().c_str(), document.GetAllocator());
            inputsValue.AddMember(inputName, vectorValue, document.GetAllocator());
        }
    }
    moduleValue.AddMember("inputs", inputsValue, document.GetAllocator());
}
Exemplo n.º 3
0
bool BranchAcceptor::save(ostream &os)
{
  os.precision(8);
  os << "BranchAcceptor" << endl;
  os << getSignalType() << " " << getCutoff() << " " << getStrand() <<endl;
  os << getConsensusOffset() << endl;
  branchPoint->save(os);
  acceptor->save(os);
  return true;
}
Exemplo n.º 4
0
void jsonifyModuleType(const ModuleType& moduleType, rapidjson::Value& moduleTypeValue, rapidjson::Document& document){
    //TODO assert moduleType.isComposite

    moduleTypeValue.SetObject();
    moduleTypeValue.AddMember("name", moduleType.getName().c_str(), document.GetAllocator());
    moduleTypeValue.AddMember("description", moduleType.getDescription().c_str(), document.GetAllocator());

    //handle inputs
    rapidjson::Value inputs;
    inputs.SetArray();
    for(unsigned int i=0; i<moduleType.numInputs(); ++i){
        const ModuleInput* input = moduleType.getInput(i);
        rapidjson::Value inputValue;
        inputValue.SetObject();

        inputValue.AddMember("name", input->getName().c_str(), document.GetAllocator());

        int dimensionality = input->getSignalType().dimensionality;
        std::stringstream ss;
        ss << dimensionality << "f";
        rapidjson::Value typeValue(ss.str().c_str(), document.GetAllocator());
        inputValue.AddMember("type", typeValue, document.GetAllocator());
        inputs.PushBack(inputValue, document.GetAllocator());
    }
    moduleTypeValue.AddMember("inputs", inputs, document.GetAllocator());

    //handle outputs
    rapidjson::Value outputs;
    outputs.SetArray();
    for(unsigned int i=0; i<moduleType.numOutputs(); ++i){
        const ModuleOutput* output = moduleType.getOutput(i);
        const Module* outputsModule = moduleType.getGraph()->getModule("outputs");
        rapidjson::Value outputValue;
        outputValue.SetObject();
        outputValue.AddMember("name", output->getName().c_str(), document.GetAllocator());
        auto inputLink = outputsModule->getInput(i);
        auto outputLink = outputsModule->getInput(i)->getOutputLink();
        if(outputLink!=nullptr){
            std::string sourceString = outputLink->getOwner().getName() + "." + outputLink->getModuleOutput().getName();
            rapidjson::Value sourceStringValue(sourceString.c_str(),document.GetAllocator());
            outputValue.AddMember("source", sourceStringValue, document.GetAllocator());
        } else {
            rapidjson::Value vectorValue;
            vectorValue.SetArray();
            auto unlinkedValue = inputLink->getUnlinkedValue();
            for(int j=0; j<unlinkedValue.getSignalType().dimensionality; ++j){
                vectorValue.PushBack(unlinkedValue[j], document.GetAllocator());
            }
            outputValue.AddMember("source", vectorValue, document.GetAllocator());
        }
        outputs.PushBack(outputValue, document.GetAllocator());
    }
    moduleTypeValue.AddMember("outputs", outputs, document.GetAllocator());

    //handle internal modules
    rapidjson::Value modulesValue;
    modulesValue.SetArray();
    auto graph = moduleType.getGraph();
    graph->traverseModulesTopological([&](const Module& module){
        //skip input/output modules
        if(module.getType().isGraphInput() || module.getType().isGraphOutput())return;
        rapidjson::Value moduleValue;
        jsonifyModule(module, moduleValue, document);
        modulesValue.PushBack(moduleValue, document.GetAllocator());
    });
    moduleTypeValue.AddMember("modules", modulesValue, document.GetAllocator());
}
Exemplo n.º 5
0
void Signal::printOn(ostream &os) const
{
  os<<getSignalType()<<"@"<<getConsensusPosition()<<":"<<*propagators[propagators[1] ? 1 :0];
}