Improve symmetry of Constructor/Destructor functions.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
7b09bacb01
commit
bde3eb92b0
11 changed files with 43 additions and 26 deletions
|
@ -110,7 +110,7 @@ namespace common2
|
|||
}
|
||||
}
|
||||
|
||||
void InitializeFileRegistry(const EmulatorOptions & options)
|
||||
std::shared_ptr<Registry> CreateFileRegistry(const EmulatorOptions & options)
|
||||
{
|
||||
const std::string homeDir = getHomeDir();
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace common2
|
|||
std::shared_ptr<Configuration> config(new Configuration(filename, saveOnExit));
|
||||
config->addExtraOptions(options.registryOptions);
|
||||
|
||||
Registry::instance = config;
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class Registry;
|
||||
|
||||
namespace common2
|
||||
{
|
||||
|
@ -8,6 +11,6 @@ namespace common2
|
|||
struct EmulatorOptions;
|
||||
|
||||
std::string GetConfigFile(const std::string & filename);
|
||||
void InitializeFileRegistry(const EmulatorOptions & options);
|
||||
std::shared_ptr<Registry> CreateFileRegistry(const EmulatorOptions & options);
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace ra2
|
|||
, mySpeed(true)
|
||||
, myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
||||
{
|
||||
InitialiseRetroRegistry();
|
||||
Registry::instance = CreateRetroRegistry();
|
||||
SetFrame(myFrame);
|
||||
myFrame->Initialize();
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace ra2
|
|||
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, retroVariables.data());
|
||||
}
|
||||
|
||||
void InitialiseRetroRegistry()
|
||||
std::shared_ptr<Registry> CreateRetroRegistry()
|
||||
{
|
||||
const auto registry = std::make_shared<common2::PTreeRegistry>();
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace ra2
|
|||
}
|
||||
}
|
||||
|
||||
Registry::instance = registry;
|
||||
return registry;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Registry;
|
||||
|
||||
namespace ra2
|
||||
{
|
||||
|
||||
void SetupRetroVariables();
|
||||
void InitialiseRetroRegistry();
|
||||
std::shared_ptr<Registry> CreateRetroRegistry();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "frontends/common2/utils.h"
|
||||
#include "frontends/ncurses/world.h"
|
||||
#include "frontends/ncurses/nframe.h"
|
||||
#include "frontends/ncurses/evdevpaddle.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -146,11 +147,13 @@ namespace
|
|||
return 1;
|
||||
|
||||
const Logger logger(options.log);
|
||||
InitializeFileRegistry(options);
|
||||
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
|
||||
const std::shared_ptr<na2::NFrame> frame(new na2::NFrame(options.paddleDeviceName));
|
||||
const Initialisation init(frame);
|
||||
const std::shared_ptr<na2::EvDevPaddle> paddle(new na2::EvDevPaddle(options.paddleDeviceName));
|
||||
|
||||
const std::shared_ptr<na2::NFrame> frame(new na2::NFrame(paddle));
|
||||
const Initialisation init(registry, frame, paddle);
|
||||
|
||||
na2::SetCtrlCHandler(options.headless);
|
||||
applyOptions(options);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "frontends/ncurses/colors.h"
|
||||
#include "frontends/ncurses/asciiart.h"
|
||||
#include "frontends/ncurses/evdevpaddle.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "Memory.h"
|
||||
#include "Log.h"
|
||||
|
@ -39,8 +38,8 @@ namespace na2
|
|||
std::shared_ptr<GraphicsColors> colors;
|
||||
};
|
||||
|
||||
NFrame::NFrame(const std::string & paddleDevice)
|
||||
: myPaddleDevice(paddleDevice)
|
||||
NFrame::NFrame(const std::shared_ptr<EvDevPaddle> & paddle)
|
||||
: myPaddle(paddle)
|
||||
, myRows(-1)
|
||||
, myColumns(-1)
|
||||
{
|
||||
|
@ -54,8 +53,6 @@ namespace na2
|
|||
myTextFlashCounter = 0;
|
||||
myTextFlashState = 0;
|
||||
myAsciiArt.reset(new ASCIIArt());
|
||||
myPaddle.reset(new EvDevPaddle(myPaddleDevice));
|
||||
Paddle::instance = myPaddle;
|
||||
}
|
||||
|
||||
void NFrame::Destroy()
|
||||
|
@ -67,9 +64,6 @@ namespace na2
|
|||
myStatus.reset();
|
||||
myAsciiArt.reset();
|
||||
|
||||
myPaddle.reset();
|
||||
Paddle::instance.reset();
|
||||
|
||||
myNCurses.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace na2
|
|||
class NFrame : public common2::CommonFrame
|
||||
{
|
||||
public:
|
||||
NFrame(const std::string & paddleDevice);
|
||||
NFrame(const std::shared_ptr<EvDevPaddle> & paddle);
|
||||
|
||||
WINDOW * GetWindow();
|
||||
WINDOW * GetStatus();
|
||||
|
@ -35,7 +35,8 @@ namespace na2
|
|||
|
||||
private:
|
||||
|
||||
const std::string myPaddleDevice;
|
||||
const std::shared_ptr<EvDevPaddle> myPaddle;
|
||||
|
||||
int myRows;
|
||||
int myColumns;
|
||||
int myTextFlashCounter;
|
||||
|
@ -44,7 +45,6 @@ namespace na2
|
|||
std::shared_ptr<WINDOW> myFrame;
|
||||
std::shared_ptr<WINDOW> myStatus;
|
||||
std::shared_ptr<ASCIIArt> myAsciiArt;
|
||||
std::shared_ptr<EvDevPaddle> myPaddle;
|
||||
std::shared_ptr<NCurses> myNCurses;
|
||||
|
||||
LPBYTE myTextBank1; // Aux
|
||||
|
|
|
@ -91,8 +91,8 @@ void run_sdl(int argc, const char * argv [])
|
|||
return;
|
||||
|
||||
const Logger logger(options.log);
|
||||
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
InitializeFileRegistry(options);
|
||||
|
||||
std::shared_ptr<sa2::SDLFrame> frame;
|
||||
if (options.imgui)
|
||||
|
@ -104,8 +104,8 @@ void run_sdl(int argc, const char * argv [])
|
|||
frame.reset(new sa2::SDLRendererFrame(options));
|
||||
}
|
||||
|
||||
Paddle::instance.reset(new sa2::Gamepad(0));
|
||||
const Initialisation init(frame);
|
||||
std::shared_ptr<Paddle> paddle(new sa2::Gamepad(0));
|
||||
const Initialisation init(registry, frame, paddle);
|
||||
|
||||
if (SDL_GL_SetSwapInterval(options.glSwapInterval))
|
||||
{
|
||||
|
|
|
@ -36,9 +36,16 @@ Video& GetVideo()
|
|||
return sg_Video;
|
||||
}
|
||||
|
||||
Initialisation::Initialisation(const std::shared_ptr<FrameBase> & frame)
|
||||
Initialisation::Initialisation(
|
||||
const std::shared_ptr<Registry> & registry,
|
||||
const std::shared_ptr<FrameBase> & frame,
|
||||
const std::shared_ptr<Paddle> & paddle
|
||||
)
|
||||
{
|
||||
Registry::instance = registry;
|
||||
SetFrame(frame);
|
||||
Paddle::instance = paddle;
|
||||
|
||||
frame->Initialize();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <memory>
|
||||
|
||||
class FrameBase;
|
||||
class Paddle;
|
||||
class Registry;
|
||||
|
||||
void SetFrame(const std::shared_ptr<FrameBase> & frame);
|
||||
|
||||
|
@ -10,7 +12,11 @@ void SetFrame(const std::shared_ptr<FrameBase> & frame);
|
|||
class Initialisation
|
||||
{
|
||||
public:
|
||||
Initialisation(const std::shared_ptr<FrameBase> & frame);
|
||||
Initialisation(
|
||||
const std::shared_ptr<Registry> & registry,
|
||||
const std::shared_ptr<FrameBase> & frame,
|
||||
const std::shared_ptr<Paddle> & paddle
|
||||
);
|
||||
~Initialisation();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue