mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +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.
46 lines
995 B
C++
46 lines
995 B
C++
#pragma once
|
|
#include <nlohmann/json.hpp>
|
|
#include <string>
|
|
|
|
namespace Slic3r {
|
|
|
|
class MachineObject;
|
|
|
|
|
|
class DevStorage
|
|
{
|
|
public:
|
|
DevStorage(MachineObject *obj) : m_owner(obj){}
|
|
|
|
public:
|
|
|
|
enum SdcardState : int {
|
|
NO_SDCARD = 0,
|
|
HAS_SDCARD_NORMAL = 1,
|
|
HAS_SDCARD_ABNORMAL = 2,
|
|
HAS_SDCARD_READONLY = 3,
|
|
SDCARD_STATE_NUM = 4
|
|
};
|
|
|
|
/* sdcard */
|
|
SdcardState get_sdcard_state() const { return m_sdcard_state; };
|
|
SdcardState set_sdcard_state(int state);
|
|
|
|
static void ParseV1_0(const nlohmann::json &print_json, DevStorage *system);
|
|
|
|
bool is_timelapse_storage_low(const std::string& storage) const;
|
|
|
|
private:
|
|
[[maybe_unused]] MachineObject *m_owner;
|
|
SdcardState m_sdcard_state { NO_SDCARD };
|
|
// timelapse storage space info (from device push cam data)
|
|
int tl_internal_free_kb{-1};
|
|
int tl_internal_total_kb{-1};
|
|
int tl_external_free_kb{-1};
|
|
int tl_external_total_kb{-1};
|
|
|
|
|
|
|
|
};
|
|
|
|
} // namespace Slic3r
|