Tidy up some xml structures.
This commit is contained in:
parent
875cdc84ff
commit
8771b721d1
31 changed files with 885 additions and 563 deletions
|
@ -1,9 +1,13 @@
|
|||
#include "MainApplication.h"
|
||||
#include "FileLogger.h"
|
||||
#include "MidiReader.h"
|
||||
#include "File.h"
|
||||
#include "DocumentConverter.h"
|
||||
#include <filesystem>
|
||||
|
||||
MainApplication::MainApplication()
|
||||
: mDatabaseManager()
|
||||
: mDatabaseManager(),
|
||||
mCommandLineArgs()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -13,20 +17,64 @@ MainApplication::~MainApplication()
|
|||
|
||||
}
|
||||
|
||||
void MainApplication::Initialize(const std::filesystem::path& workDir)
|
||||
void MainApplication::Initialize(CommandLineArgsUPtr commandLineArgs)
|
||||
{
|
||||
FileLogger::GetInstance().SetWorkDirectory(workDir.string());
|
||||
mCommandLineArgs = std::move(commandLineArgs);
|
||||
std::string launch_path = mCommandLineArgs->GetLaunchPath().string();
|
||||
|
||||
FileLogger::GetInstance().SetWorkDirectory(launch_path);
|
||||
FileLogger::GetInstance().Open();
|
||||
MLOG_INFO("Launched");
|
||||
|
||||
mDatabaseManager = DatabaseManager::Create();
|
||||
mDatabaseManager->CreateDatabase(workDir.string() + "/database.db");
|
||||
mDatabaseManager->CreateDatabase(launch_path + "/database.db");
|
||||
|
||||
mNetworkManager = NetworkManager::Create();
|
||||
|
||||
mAudioManager = AudioManager::Create();
|
||||
}
|
||||
|
||||
void MainApplication::Run()
|
||||
{
|
||||
std::string program_type;
|
||||
if(mCommandLineArgs->GetNumberOfArgs() > 1)
|
||||
{
|
||||
program_type = mCommandLineArgs->GetArg(1);
|
||||
}
|
||||
|
||||
std::string input_path;
|
||||
std::string output_path;
|
||||
for(unsigned idx=1; idx<mCommandLineArgs->GetNumberOfArgs(); idx++)
|
||||
{
|
||||
auto arg = mCommandLineArgs->GetArg(idx);
|
||||
if(arg == "-input" && mCommandLineArgs->GetNumberOfArgs() > idx+1)
|
||||
{
|
||||
input_path = mCommandLineArgs->GetArg(idx + 1);
|
||||
}
|
||||
else if(arg == "-output" && mCommandLineArgs->GetNumberOfArgs() > idx+1)
|
||||
{
|
||||
output_path = mCommandLineArgs->GetArg(idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(program_type == "-server")
|
||||
{
|
||||
RunServer();
|
||||
}
|
||||
else if(program_type == "-audio")
|
||||
{
|
||||
PlayAudio();
|
||||
}
|
||||
else if(program_type == "-convert")
|
||||
{
|
||||
ConvertDocument(input_path, output_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
MLOG_ERROR("Unknown program type: " + program_type);
|
||||
}
|
||||
}
|
||||
|
||||
void MainApplication::RunServer()
|
||||
{
|
||||
mNetworkManager->RunHttpServer();
|
||||
|
@ -41,6 +89,15 @@ void MainApplication::PlayAudio()
|
|||
mAudioManager->GetAudioInterface()->Play(device);
|
||||
}
|
||||
|
||||
void MainApplication::ConvertDocument(const std::string& inputPath, const std::string& outputPath)
|
||||
{
|
||||
auto input_file = File(std::filesystem::path(inputPath));
|
||||
auto output_file = File(std::filesystem::path(outputPath));
|
||||
MLOG_INFO("Converting: " + inputPath + " to " + outputPath);
|
||||
DocumentConverter converter;
|
||||
converter.Convert(&input_file, &output_file);
|
||||
}
|
||||
|
||||
void MainApplication::ShutDown()
|
||||
{
|
||||
mDatabaseManager->OnShutDown();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue