00001 /* 00002 * Copyright (C) 2006 Dip. Ing. dell'Informazione, University of Pisa, Italy 00003 * http://info.iet.unipi.it/~cng/ns2measure/ns2measure.html 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA 00018 */ 00019 00032 /* 00033 communication protocol NS2 -> measure program 00034 00035 unsigned int = UIN 00036 double = DBL 00037 char = CHR 00038 00039 type data 00040 UIN run identifier 00041 UIN no. of averaged metrics 00042 |-UIN no. of indices of metric j = nj 00043 | UIN length of the name of the metric = lenj (including '\0') 00044 j| CHR name of the metric, of length lenj 00045 | UIN index of the i-th sample of metric j (i=0,1,..,nj-1) -| nj times 00046 |-DBL i-th sample of metric j -| 00047 UIN no. of distribution metrics 00048 |-UIN no. of indices of the metric = mj 00049 | UIN length of the name of the metric = lenj (including '\0') 00050 | CHR name of the metric, of length lenj 00051 | DBL bin size 00052 | DBL lower bound of the distribution 00053 j| UIN number of bins bj 00054 | UIN index of the i-th distribution of metric j (i=0,1,..,mj-1) -| mj times 00055 | DBL first sample 0 | 00056 | DBL second sample 1 | 00057 | DBL .. | 00058 |-DBL last sample bj-1 -| 00059 00060 */ 00061 00062 #ifndef __MEASURE_INPUT_H 00063 #define __MEASURE_INPUT_H 00064 00065 #include <config.h> 00066 #include <object.h> 00067 #include <measure.h> 00068 #include <configuration.h> 00069 00070 #include <set> 00071 #include <map> 00072 #include <vector> 00073 00074 #include <iostream> 00075 #include <fstream> 00076 #include <string> 00077 #include <cstdlib> 00078 00080 class Input : public Object { 00082 Configuration& configuration; 00084 Metrics& metrics; 00086 std::set<unsigned int> runIdentifiers; 00087 00088 public: 00090 00095 void readSingleRun (std::istream& fileIn, 00096 std::ostream* fileOut = 0, bool recover = false); 00097 00099 Input (Configuration& c, Metrics& m) : 00100 Object ("Input"), configuration(c), metrics(m) { } 00102 ~Input () { } 00103 00105 00121 void loadData (std::string fileIn, std::string fileOut); 00123 bool recoverData (std::string saveFile); 00125 bool checkConfidence (); 00127 bool check (); 00129 const std::set<unsigned int>& getRunIdentifiers () const { 00130 return runIdentifiers; } 00131 }; 00132 00133 #endif // __MEASURE_INPUT_H