/*========================================================================= Program: bbtk Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision$ =========================================================================*/ /* --------------------------------------------------------------------- * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux * * This software is governed by the CeCILL-B license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/ or redistribute the software under the terms of the CeCILL-B * license as circulated by CEA, CNRS and INRIA at the following URL * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html * or in the file LICENSE.txt. * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited * liability. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. * ------------------------------------------------------------------------ */ /** * \file * \brief Class bbtk::GBlackBox */ #include "GBlackBoxModel.h" namespace bbtk { //========================================================================= GBlackBoxModel::GBlackBoxModel() { _isExecutable = false; } //========================================================================= GBlackBoxModel::~GBlackBoxModel() { } //========================================================================= std::string GBlackBoxModel::getBBTKPackage() { return _bbtkPackage; } //========================================================================= void GBlackBoxModel::setBBTKPackage(std::string obpackage) { _bbtkPackage = obpackage; } //========================================================================= bool GBlackBoxModel::isExecutable() { return _isExecutable; } //========================================================================= void GBlackBoxModel::setExecutable(bool executable) { _isExecutable = executable; } //========================================================================= std::string GBlackBoxModel::getStatusText() { std::string temp = ""; temp+=_bbtkPackage; temp+=":"; temp+=_bbtkType; temp+=":"; temp+=_bbtkName; return temp; } //========================================================================= void GBlackBoxModel::setValueToInputPort(int pos,std::string value) { _inputs[pos]->setValue(value); } //========================================================================= void GBlackBoxModel::save(std::string &content) { content+="BOX\n"; // Box info content+=_bbtkPackage; content+=":"; content+=_bbtkType; content+=":"; content+=_bbtkName; content+="\n"; content+="ISEXEC:"; if(_isExecutable) { content+="TRUE"; } else { content+="FALSE"; } content+="\n"; //Box Position char buffer [50]; sprintf (buffer, "%f", _xInic); content+=buffer; content+=":"; sprintf (buffer, "%f", _yInic); content+=buffer; content+=":"; sprintf (buffer, "%f", _zInic); content+=buffer; content+="\n"; sprintf (buffer, "%f", _xFin); content+=buffer; content+=":"; sprintf (buffer, "%f", _yFin); content+=buffer; content+=":"; sprintf (buffer, "%f", _zFin); content+=buffer; content+="\n"; //Ports with a value for(int i = 0; i<_inputs.size();i++) { if(_inputs[i]->isValueSet()) { _inputs[i]->save(content); } } content+="FIN_BOX\n"; } //========================================================================= void GBlackBoxModel::setValueToInput(std::string name,std::string value) { for(int i = 0; i<_inputs.size();i++) { if(_inputs[i]->getBBTKName()==name) { _inputs[i]->setValue(value); } } } //========================================================================= std::string GBlackBoxModel::getValueInputPort(int pos) { return _inputs[pos]->getValue(); } //========================================================================= std::string GBlackBoxModel::getValueInput(std::string name) { for(int i = 0; i<_inputs.size();i++) { if(_inputs[i]->getBBTKName()==name) { return _inputs[i]->getValue(); } } return NULL; } //========================================================================= std::vector GBlackBoxModel::getConnectedInputs() { std::vector connected; for(int i = 0; i<_inputs.size();i++) { if(_inputs[i]->isConnected()) { connected.push_back(i); } } return connected; } //========================================================================= std::vector GBlackBoxModel::getConnectedOutputs() { std::vector connected; for(int i = 0; i<_outputs.size();i++) { if(_outputs[i]->isConnected()) { connected.push_back(i); } } return connected; } //========================================================================= } // EO namespace bbtk // EOF