#ifndef FACTORYNETOBJECTS_H #define FACTORYNETOBJECTS_H #include "clientprotocol_global.h" #include "basenetworkobject.h" #include #include namespace ClientProtocol { extern QMap map; extern QMap types_sizes; class CLIENTPROTOCOLSHARED_EXPORT FactoryNetObjects { private: public: FactoryNetObjects() = delete; static BaseNetworkObject *build(quint8 type); static BaseNetworkObject *build(quint8 type, const QByteArray& array); static NetworkClassSize getSize(quint8 type); static bool isRegisteredType(quint8 type); static bool isInited(); template static bool regType(quint8 id) { if (map.contains(id)) { return false; } auto tempObj = new T(); map.insert(id, tempObj); types_sizes.insert(id, tempObj->classSize()); return true; } }; } #endif // FACTORYNETOBJECTS_H