Files
OrcaSlicer/src/slic3r/GUI/DeviceCore/DevCtrl.h
T
HanifKoh 73d32d4791 Stop Leaking json Through Headers and Drop Includes Kept Only for the Name (#16221)
* 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.
2026-10-07 14:22:16 +08:00

54 lines
1.0 KiB
C++

#pragma once
#include <nlohmann/json.hpp>
#include <string>
#include <ctime>
#include <wx/string.h>
namespace Slic3r
{
//Previous definitions
class MachineObject;
class DevCtrlInfo
{
public:
DevCtrlInfo() {};
DevCtrlInfo(MachineObject* obj, int sequence_id, const nlohmann::json& req_json, int interval_max = 3, int interval_min = 0);
public:
bool CheckCanUpdateData(const nlohmann::json& jj);
private:
void OnTimeOut() { m_time_out = true;}
void OnReceived() { m_received = true;} ;
private:
bool m_time_out = false;
bool m_received = false;
std::string m_request_dev_id = "";
time_t m_request_time = 0;
int m_request_seq = 0;
nlohmann::json m_request_json = nlohmann::json();
// check
int m_request_interval_max = 3;
int m_request_interval_min = 0;
};
class DevCtrl
{
MachineObject* m_obj;
public:
DevCtrl(MachineObject* obj) : m_obj(obj) {};
~DevCtrl() = default;
public:
/*extruder system*/
int command_select_extruder(int id);
};
};