Skip to content

Commit

Permalink
refactor(main): move globals out of main
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Feb 10, 2024
1 parent 875d6d7 commit 5310c7d
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ set(SUNSHINE_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/entry_handler.h"
"${CMAKE_SOURCE_DIR}/src/file_handler.cpp"
"${CMAKE_SOURCE_DIR}/src/file_handler.h"
"${CMAKE_SOURCE_DIR}/src/globals.cpp"
"${CMAKE_SOURCE_DIR}/src/globals.h"
"${CMAKE_SOURCE_DIR}/src/logging.cpp"
"${CMAKE_SOURCE_DIR}/src/logging.h"
"${CMAKE_SOURCE_DIR}/src/main.cpp"
Expand Down
3 changes: 0 additions & 3 deletions src/entry_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#include "thread_pool.h"
#include "thread_safe.h"

extern thread_pool_util::ThreadPool task_pool;
extern bool display_cursor;

// functions
void
launch_ui();
Expand Down
9 changes: 9 additions & 0 deletions src/globals.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @file globals.cpp
* @brief Implementation for globally accessible variables and functions.
*/
#include "globals.h"

safe::mail_t mail::man;
thread_pool_util::ThreadPool task_pool;
bool display_cursor = true;
12 changes: 12 additions & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file globals.h
* @brief Header for globally accessible variables and functions.
*/
#pragma once

#include "entry_handler.h"
#include "thread_pool.h"

extern safe::mail_t mail::man;
extern thread_pool_util::ThreadPool task_pool;
extern bool display_cursor;
1 change: 1 addition & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {

#include "config.h"
#include "entry_handler.h"
#include "globals.h"
#include "input.h"
#include "logging.h"
#include "platform/common.h"
Expand Down
7 changes: 1 addition & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// local includes
#include "confighttp.h"
#include "entry_handler.h"
#include "globals.h"
#include "httpcommon.h"
#include "logging.h"
#include "main.h"
Expand All @@ -38,15 +39,9 @@ extern "C" {
#include <rs.h>
}

safe::mail_t mail::man;

using namespace std::literals;
namespace bl = boost::log;

thread_pool_util::ThreadPool task_pool;

bool display_cursor = true;

struct NoDelete {
void
operator()(void *) {}
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux/x11grab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "src/config.h"
#include "src/entry_handler.h"
#include "src/globals.h"
#include "src/logging.h"
#include "src/task_pool.h"
#include "src/thread_pool.h"
Expand Down
1 change: 1 addition & 0 deletions src/platform/windows/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "misc.h"
#include "src/config.h"
#include "src/entry_handler.h"
#include "src/globals.h"
#include "src/logging.h"
#include "src/platform/common.h"
#include "src/task_pool.h"
Expand Down
1 change: 1 addition & 0 deletions src/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C" {

#include "config.h"
#include "entry_handler.h"
#include "globals.h"
#include "input.h"
#include "logging.h"
#include "network.h"
Expand Down
1 change: 1 addition & 0 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern "C" {
#include "cbs.h"
#include "config.h"
#include "entry_handler.h"
#include "globals.h"
#include "input.h"
#include "logging.h"
#include "nvenc/nvenc_base.h"
Expand Down

0 comments on commit 5310c7d

Please sign in to comment.