Assignment 3
Unique No:
Due 2025
,Part A — Client side: serializing pallets and sending over TCP (threaded)
Design overview
Use QXmlStreamWriter to construct the XML document in a structured and
efficient manner.
Perform both serialization and network transmission inside a worker object that is
executed on a QThread so the GUI remains responsive.
The worker communicates with the UI through signals that report progress,
success, or error conditions.
When the TCP connection to the server is established and the XML data has
been transmitted, the resulting XML string is displayed inside a QTextEdit widget
in the serialization tab.
Container code validation
The server uses this regular expression to check container identifiers:
^(20[0-9]{2})/(0[1-9]|1[0-2])/[BC](\d{1,4})$
Year: 2000–2099
Month: 01–12
Category: B or C
Serial number: 1–9999
Client: SerializationWorker (Header)
// SerializationWorker.h
#ifndef SERIALIZATIONWORKER_H
#define SERIALIZATIONWORKER_H
#include <QObject>
#include <QString>
#include <map>
, #include <memory>
#include <vector>
// Forward declarations
class Pallet;
class QTcpSocket;
/*
* SerializationWorker
*
* This worker is designed to run on a background thread.
* It handles XML construction from pallet data and
* transmits the result to a remote server.
*/
class SerializationWorker : public QObject {
Q_OBJECT
public:
explicit SerializationWorker(const std::map<int, Pallet*>& pallets);
~SerializationWorker();
public slots:
// Entry point for execution when moved to a thread
void process();
signals:
// Triggered when XML has been built and sent successfully
void finished(const QString& xml);
// Triggered when an error occurs
void error(const QString& message);