2017-11-23 23:05:14 +01:00
|
|
|
#include "externals.hh"
|
|
|
|
#include "common.hh"
|
|
|
|
|
|
|
|
#include "c-filewatcher.hh"
|
2017-11-23 23:31:24 +01:00
|
|
|
#include "c-opcomp.hh"
|
|
|
|
#include "c-ops.hh"
|
2017-11-24 14:52:56 +01:00
|
|
|
#include "c-project.hh"
|
2017-11-23 23:37:52 +01:00
|
|
|
#include "c-sync.hh"
|
|
|
|
#include "c-undo.hh"
|
2017-11-23 23:05:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct CommonData_
|
|
|
|
{
|
2017-11-24 14:52:56 +01:00
|
|
|
T_Project project;
|
2017-11-23 23:05:14 +01:00
|
|
|
T_FilesWatcher watcher;
|
|
|
|
T_SyncManager sync;
|
|
|
|
T_ScriptManager ops;
|
|
|
|
T_UndoManager undo;
|
2017-11-24 14:52:56 +01:00
|
|
|
|
|
|
|
CommonData_( T_String const& path ) noexcept
|
|
|
|
: project{ path }
|
|
|
|
{}
|
2017-11-23 23:05:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
std::aligned_storage_t< sizeof( CommonData_ ) , alignof( CommonData_ ) > Instance_;
|
|
|
|
|
|
|
|
} // namespace <anon>
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
2017-11-24 14:52:56 +01:00
|
|
|
void Common::Init(
|
|
|
|
T_String const& path ) noexcept
|
2017-11-23 23:05:14 +01:00
|
|
|
{
|
2017-11-24 14:52:56 +01:00
|
|
|
new ((char*)&Instance_) CommonData_( path );
|
2017-11-23 23:05:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Common::Shutdown( ) noexcept
|
|
|
|
{
|
|
|
|
((CommonData_*)(char*)&Instance_)->~CommonData_( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#define M_GET_( P ) ((CommonData_*)(char*)&Instance_)->P
|
|
|
|
|
2017-11-24 14:52:56 +01:00
|
|
|
T_Project& Common::Project( ) noexcept
|
|
|
|
{ return M_GET_( project ); }
|
|
|
|
|
2017-11-23 23:05:14 +01:00
|
|
|
T_FilesWatcher& Common::Watcher( ) noexcept
|
|
|
|
{ return M_GET_( watcher ); }
|
|
|
|
|
|
|
|
T_SyncManager& Common::Sync( ) noexcept
|
|
|
|
{ return M_GET_( sync ); }
|
|
|
|
|
|
|
|
T_ScriptManager& Common::Ops( ) noexcept
|
|
|
|
{ return M_GET_( ops ); }
|
|
|
|
|
|
|
|
T_UndoManager& Common::Undo( ) noexcept
|
|
|
|
{ return M_GET_( undo ); }
|