mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-11-23 06:19:41 +00:00
+ config (init)
This commit is contained in:
parent
fae44db0d4
commit
1b4da465aa
24766
third_party/nlohmann/json.hpp
vendored
Normal file
24766
third_party/nlohmann/json.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
tools/config/CmakeLists.txt
Normal file
21
tools/config/CmakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
add_library(config SHARED config.cpp)
|
||||
|
||||
add_dependencies(config boost)
|
||||
|
||||
target_link_libraries(config libboost_thread)
|
||||
target_compile_definitions(config PRIVATE BOOST_ALL_NO_LIB WIN32_LEAN_AND_MEAN)
|
||||
target_compile_options(config PRIVATE "/Zi")
|
||||
|
||||
target_include_directories(config PRIVATE
|
||||
${PRJ_SRC_DIR}/third_party
|
||||
)
|
||||
|
||||
set_target_properties(config
|
||||
PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/."
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/third_party/intall/lib"
|
||||
)
|
||||
|
||||
install(TARGETS config LIBRARY DESTINATION .)
|
24
tools/config/config.cpp
Normal file
24
tools/config/config.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#define __APICALL_EXTERN
|
||||
#include "config.h"
|
||||
#undef __APICALL_EXTERN
|
||||
|
||||
class Config: public IConfig {
|
||||
nlohmann::json m_logging;
|
||||
boost::mutex m_mutex_logging;
|
||||
|
||||
public:
|
||||
Config() = default;
|
||||
virtual ~Config() = default;
|
||||
|
||||
std::pair<boost::unique_lock<boost::mutex>, nlohmann::json*> accessLogging() final;
|
||||
};
|
||||
|
||||
IConfig* accessConfig() {
|
||||
static Config obj;
|
||||
return &obj;
|
||||
}
|
||||
|
||||
std::pair<boost::unique_lock<boost::mutex>, nlohmann::json*> Config::accessLogging() {
|
||||
boost::unique_lock lock(m_mutex_logging);
|
||||
return std::make_pair(std::move(lock), &m_logging);
|
||||
}
|
27
tools/config/config.h
Normal file
27
tools/config/config.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include "third_party/nlohmann/json.hpp"
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
class IConfig {
|
||||
CLASS_NO_COPY(IConfig);
|
||||
CLASS_NO_MOVE(IConfig);
|
||||
|
||||
protected:
|
||||
IConfig() = default;
|
||||
|
||||
public:
|
||||
virtual ~IConfig() = default;
|
||||
|
||||
virtual std::pair<boost::unique_lock<boost::mutex>, nlohmann::json*> accessLogging() = 0;
|
||||
};
|
||||
|
||||
#ifdef __APICALL_EXTERN
|
||||
#define __APICALL __declspec(dllexport)
|
||||
#else
|
||||
#define __APICALL __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
__APICALL IConfig* accessConfig();
|
||||
#undef __APICALL
|
Loading…
Reference in New Issue
Block a user