Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #if !defined(ALIZE_SegServerFileReaderRaw_cpp)
00056 #define ALIZE_SegServerFileReaderRaw_cpp
00057
00058 #include <new>
00059 #include "SegServerFileReaderRaw.h"
00060 #include "SegServer.h"
00061 #include "Exception.h"
00062 #include "Config.h"
00063 #include "ULongVector.h"
00064
00065
00066 using namespace alize;
00067
00068 typedef SegServerFileReaderRaw R;
00069
00070
00071 R::SegServerFileReaderRaw(const FileName& f,const Config& c)
00072 :SegServerFileReaderAbstract(f, c) {}
00073
00074 R& R::create(const FileName& n,const Config& c)
00075 {
00076 R* p = new (std::nothrow) R(n, c);
00077 assertMemoryIsAllocated(p, __FILE__, __LINE__);
00078 return *p;
00079 }
00080
00081 void R::readSegServer(SegServer& ss)
00082 {
00083 assert(_pReader != NULL);
00084 ss.removeAllClusters();
00085 ss.removeAllSegs();
00086 unsigned long i, j, k, n, nbLines, nbElements, idxCluster;
00087
00088 ss.setServerName(_pReader->readString(_pReader->readUInt4()));
00089 n = _pReader->readUInt4();
00090 for (i=0; i<n; i++)
00091 {
00092 unsigned long b = _pReader->readUInt4();
00093 unsigned long l = _pReader->readUInt4();
00094 unsigned long lc = _pReader->readUInt4();
00095 const String st = _pReader->readString(_pReader->readUInt4());
00096 const String sn = _pReader->readString(_pReader->readUInt4());
00097 Seg& seg = ss.createSeg(b, l, lc, st, sn);
00098 nbLines = _pReader->readUInt4();
00099 XList& list = seg.list();
00100 list.reset();
00101 for (j=0; j<nbLines; j++)
00102 {
00103 XLine& line = list.addLine();
00104 nbElements = _pReader->readUInt4();
00105 for (k=0; k<nbElements; k++)
00106 { line.addElement(_pReader->readString(_pReader->readUInt4())); }
00107 }
00108 }
00109 unsigned long nbClusters = _pReader->readUInt4();
00110 ULongVector idxClusterVect, typeVect, idxSubSegVect, idClusterVect;
00111 for (idxCluster=0; idxCluster<nbClusters; idxCluster++)
00112 {
00113 unsigned long id = _pReader->readUInt4();
00114 unsigned long lc = _pReader->readUInt4();
00115 const String st = _pReader->readString(_pReader->readUInt4());
00116 const String sn = _pReader->readString(_pReader->readUInt4());
00117 SegCluster& cl = ss.createCluster(lc, st, sn);
00118 ss.setClusterId(cl, id);
00119
00120
00121 nbLines = _pReader->readUInt4();
00122 XList& list = cl.list();
00123 list.reset();
00124 for (j=0; j<nbLines; j++)
00125 {
00126 XLine& line = list.addLine();
00127 nbElements = _pReader->readUInt4();
00128 for (k=0; k<nbElements; k++)
00129 { line.addElement(_pReader->readString(_pReader->readUInt4())); }
00130 }
00131
00132 unsigned long nbSubSeg = _pReader->readUInt4();
00133 for (j=0; j<nbSubSeg; j++)
00134 {
00135 idxClusterVect.addValue(idxCluster);
00136 typeVect.addValue(_pReader->readString(1).c_str()[0]);
00137 idxSubSegVect.addValue(_pReader->readUInt4());
00138
00139 }
00140 }
00141 for (idxCluster=0; idxCluster<idxClusterVect.size(); idxCluster++)
00142 {
00143 if (typeVect[idxCluster] == 's')
00144 ss.getCluster(idxClusterVect[idxCluster])
00145 .add(ss.getSeg(idxSubSegVect[idxCluster]));
00146 else
00147 ss.getCluster(idxClusterVect[idxCluster])
00148 .add(ss.getCluster(idxSubSegVect[idxCluster]));
00149 }
00150 _pReader->close();
00151 }
00152
00153 void R::error(const String& msg)
00154 {
00155 assert(_pReader != NULL);
00156 _pReader->close();
00157 throw InvalidDataException(msg, __FILE__, __LINE__,
00158 _pReader->getFullFileName());
00159 }
00160
00161 String R::getClassName() const { return "SegServerFileReaderRaw"; }
00162
00163 R::~SegServerFileReaderRaw() {}
00164
00165
00166 #endif // !defined(ALIZE_SegServerFileReaderRaw_cpp)