mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-08 00:01:09 +00:00
* Stop Leaking json Through Headers and Drop Includes Kept Only for the Name AppConfig.hpp, DeviceManager.hpp and UserManager.hpp carried a global "using namespace nlohmann;", json_diff.hpp a global "using json = nlohmann::json;" and PrinterFileSystem.h a global "using nlohmann::json;". Every file that included one of them, directly or not, could write a bare json, and 63 did without declaring it. The last two also made the include checker treat json_diff.hpp and PrinterFileSystem.h as the headers that provide json, so they were included from files that use nothing else from them: 57 of the 59 includers of json_diff.hpp never name json_diff. The five statements are removed. Headers that use the type now spell nlohmann::json, source files declare their own "using json = nlohmann::json;", and the includes that only supplied the name are dropped or replaced by <nlohmann/json.hpp>. Eight files reached json_diff.hpp only through an include that is now gone and with it lost that header's "using namespace std;". The std names they used unqualified are qualified. * Declare json in OrcaSlicer.cpp on Every Platform OrcaSlicer.cpp had its "using namespace nlohmann;" and the json include inside the Linux-only include block, so on Windows and macOS it took json from AppConfig.hpp's global directive, which is gone. The include and a "using json = nlohmann::json;" now sit outside the block.
85 lines
1.8 KiB
C++
85 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <nlohmann/json.hpp>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <wx/string.h>
|
|
#include <map>
|
|
|
|
namespace Slic3r
|
|
{
|
|
// Previous definitions
|
|
class MachineObject;
|
|
class DevHMSItem;
|
|
|
|
class DevHMS
|
|
{
|
|
public:
|
|
DevHMS(MachineObject* obj) : m_object(obj) {}
|
|
|
|
public:
|
|
void ParseHMSItems(const nlohmann::json& hms_json);
|
|
const std::vector<DevHMSItem>& GetHMSItems() const { return m_hms_list; };
|
|
|
|
private:
|
|
[[maybe_unused]] MachineObject* m_object = nullptr;
|
|
|
|
// all hms for this machine
|
|
std::vector<DevHMSItem> m_hms_list;
|
|
};
|
|
|
|
enum HMSMessageLevel
|
|
{
|
|
HMS_UNKNOWN = 0,
|
|
HMS_FATAL = 1,
|
|
HMS_SERIOUS = 2,
|
|
HMS_COMMON = 3,
|
|
HMS_INFO = 4,
|
|
HMS_MSG_LEVEL_MAX,
|
|
};
|
|
|
|
enum ModuleID
|
|
{
|
|
MODULE_UKNOWN = 0x00,
|
|
MODULE_01 = 0x01,
|
|
MODULE_02 = 0x02,
|
|
MODULE_MC = 0x03,
|
|
MODULE_04 = 0x04,
|
|
MODULE_MAINBOARD = 0x05,
|
|
MODULE_06 = 0x06,
|
|
MODULE_AMS = 0x07,
|
|
MODULE_TH = 0x08,
|
|
MODULE_09 = 0x09,
|
|
MODULE_10 = 0x0A,
|
|
MODULE_11 = 0x0B,
|
|
MODULE_XCAM = 0x0C,
|
|
MODULE_13 = 0x0D,
|
|
MODULE_14 = 0x0E,
|
|
MODULE_15 = 0x0F,
|
|
MODULE_MAX = 0x10
|
|
};
|
|
|
|
class DevHMSItem
|
|
{
|
|
public:
|
|
std::string get_long_error_code() const;
|
|
HMSMessageLevel get_level() const { return m_msg_level; }
|
|
|
|
void set_read() { m_already_read = true; };
|
|
bool has_read() const { return m_already_read; };
|
|
|
|
protected:
|
|
friend void DevHMS::ParseHMSItems(const nlohmann::json& hms_json);
|
|
bool parse_hms_info(unsigned attr, unsigned code);
|
|
|
|
private:
|
|
ModuleID m_module_id;
|
|
unsigned m_module_num;
|
|
unsigned m_part_id;
|
|
unsigned m_reserved;
|
|
HMSMessageLevel m_msg_level = HMS_UNKNOWN;
|
|
int m_msg_code = 0;
|
|
bool m_already_read = false;
|
|
};
|
|
|
|
};// End of namespace Slic3r
|