CFEL - ASG Software Suite  2.5.0
CASS
jocassview/id_list.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 -2015 Lutz Foucar
2 
3 /**
4  * @file jocassview/id_list.cpp contains the classes that can serialize
5  * the key list
6  *
7  * @author Lutz Foucar
8  */
9 
10 #include "id_list.h"
11 
12 #if QT_VERSION >= 0x050000
13 #include <QtWidgets/QMessageBox>
14 #else
15 #include <QtGui/QMessageBox>
16 #endif
17 
18 
19 using namespace jocassview;
20 using namespace std;
21 
23  : Serializable(1),
24  _size(0)
25 {
26 
27 }
28 
30  : Serializable(1),
31  _list(list),
32  _size(0)
33 {
34 
35 }
36 
38  : Serializable(1)
39 {
40  deserialize(in);
41 }
42 
44 {
45  return _list;
46 }
47 
49 {
51  writeVersion(out);
52  out.add(_size);
54  for (int i(0); i < _list.size() ; ++i)
55  out.add(_list.at(i).toStdString());
56 }
57 
59 {
60  _list.clear();
62  uint16_t ver(in.retrieve<uint16_t>());
63  if(ver != _version)
64  {
66  QObject::tr("Error: Deserialization version doesn't match"));
67  return false;
68  }
69  _size = in.retrieve<size_t>();
70  if (!in.endChecksumGroupForRead())
71  {
73  QObject::tr("Error: Wrong Checksum"));
74  return false;
75  }
76  for(size_t ii=0; ii<_size; ++ii)
77  _list.append(QString::fromStdString(in.retrieve<string>()));
78  return true;
79 }
const QStringList & getList() const
getter for the internal list
QStringList _list
a list of all processor keys
void startChecksumGroupForWrite()
control checksum for writing to stream
Definition: serializer.hpp:135
virtual void writeVersion(SerializerBackend &out) const
write the version to the stream
STL namespace.
tr(const char *sourceText, const char *disambiguation=0, int n=-1)
information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
bool deserialize(cass::SerializerBackend &in)
deserialize the list from the serializer
size_t _size
the size of the processor keys list
uint16_t _version
the version for de/serializing
fromStdString(const std::string &str)
uint16_t ver() const
retrieve the version of the serializer
void startChecksumGroupForRead()
control checksum calculation for the next values added
Definition: serializer.hpp:106
file contains the classes that can serialize the key list
IdList()
default constructor
Type retrieve()
read arbitrary value from stream
Definition: serializer.hpp:169
void add(const Type &value)
add arbitrary value to the stream
Definition: serializer.hpp:158
void serialize(cass::SerializerBackend &out) const
implmented but doesn't do anything