|
MASA-Core
|
00001 /******************************************************************************* 00002 * 00003 * Copyright (c) 2010-2015 Edans Sandes 00004 * 00005 * This file is part of MASA-Core. 00006 * 00007 * MASA-Core is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * MASA-Core is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with MASA-Core. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 ******************************************************************************/ 00021 00022 #include "MasaNetStatus.hpp" 00023 #include <sstream> 00024 00025 MasaNetStatus::MasaNetStatus() { 00026 this->serverState = SERVER_SHUTDOWN; 00027 this->processingState = STATE_IDLE; 00028 this->lastProcessedRow = -1; 00029 this->bestScore.score = -INF; 00030 this->bestScore.i = -1; 00031 this->bestScore.j = -1; 00032 } 00033 00034 MasaNetStatus::~MasaNetStatus() { 00035 } 00036 00037 void MasaNetStatus::copyFrom(MasaNetStatus* status) { 00038 this->bestScore = status->bestScore; 00039 this->lastProcessedRow = status->lastProcessedRow; 00040 this->processingState = status->processingState; 00041 this->serverState = status->serverState; 00042 } 00043 00044 00045 00046 const score_t& MasaNetStatus::getBestScore() { 00047 return bestScore; 00048 } 00049 00050 void MasaNetStatus::setBestScore(const score_t& bestScore) { 00051 this->bestScore = bestScore; 00052 } 00053 00054 int MasaNetStatus::getLastProcessedRow() const { 00055 return lastProcessedRow; 00056 } 00057 00058 void MasaNetStatus::setLastProcessedRow(int lastProcessedRow) { 00059 this->lastProcessedRow = lastProcessedRow; 00060 } 00061 00062 int MasaNetStatus::getProcessingState() const { 00063 return processingState; 00064 } 00065 00066 void MasaNetStatus::setProcessingState(int processingState) { 00067 this->processingState = processingState; 00068 } 00069 00070 int MasaNetStatus::getServerState() const { 00071 return serverState; 00072 } 00073 00074 00075 void MasaNetStatus::setServerState(int serverState) { 00076 this->serverState = serverState; 00077 } 00078 00079 string MasaNetStatus::toString() { 00080 stringstream msg; 00081 00082 msg << "\nServer State:\t "; 00083 switch (getServerState()) { 00084 case SERVER_SHUTDOWN: msg << "Shutdown"; break; 00085 case SERVER_LISTENING: msg << "Listening"; break; 00086 } 00087 00088 msg << "\nProc. Status:\t "; 00089 switch (getProcessingState()) { 00090 case STATE_IDLE: msg << "Idle"; break; 00091 case STATE_STARTING: msg << "Starting"; break; 00092 case STATE_PROCESSING: msg << "Processing"; break; 00093 case STATE_FINISHING: msg << "Finishing"; break; 00094 } 00095 00096 msg << "\nLastRow:\t " << getLastProcessedRow(); 00097 msg << "\nBestScore:\t "; 00098 int score = getBestScore().score; 00099 if (score == -INF) { 00100 msg << "-INF"; 00101 } else { 00102 msg << score; 00103 } 00104 msg << "@(" << getBestScore().i << "," << getBestScore().j << ")"; 00105 return msg.str(); 00106 }
1.7.6.1