first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

128
include/platform/platform.h Normal file
View File

@ -0,0 +1,128 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __PLATFORM__
#define __PLATFORM__
#include "memory/nauto_ptr.h"
#include "memory/singleton.h"
#include "filesystem/filesystem.h"
#include "input/input_system.h"
#include "async/job.h"
#include "signal/signal.h"
#include "licensing/licensing.h"
#include "analytics/analytics.h"
#include "billing/billing.h"
#include "time/ntime.h"
namespace GS {
struct ISharedLib;
/*!
@short Platform interface.
@author Emmanuel Julien (ejulien@owloh.com)
*/
class Platform : public Singleton <Platform>
{
bool initialized;
public:
/// Initialize platform.
virtual void Initialize();
AutoPtr <ASync::JobManager> job_manager;
AutoPtr <IO::Filesystem> io;
AutoPtr <IBilling> billing;
AutoPtr <IAnalytics> analytics;
AutoPtr <ILicensing> licensing;
AutoPtr <Input::System> input_system;
// Platform signals.
struct Signals
{
Signal <void> renderer_output_closed;
};
Signals signal;
/// Return the platform name.
virtual String GetName() const = 0;
/// Return the device name the platform is running on.
virtual String GetDeviceName() const = 0;
/// Get the platform locale as an ISO3166 code.
virtual String GetLocale() = 0;
/// Return the number of logical thread available.
virtual int GetSystemThreadCount() { return 1; }
/// Return the number of physical processor core available.
virtual int GetSystemCoreCount() { return 1; }
/// Open a given URL using the platform integrated browser.
virtual bool OpenURL(const char *) { return false; }
/// Open the application page.
virtual bool OpenAppPage() { return false; }
/// Send to background.
virtual bool SendToBackground(bool kill = false) { return false; }
/// Return the current user directory.
virtual bool GetUserDir(String &, const char *user = 0) { return false; }
/// Output a program trace to the platform log.
virtual void Trace(const char *trace, const char *source, int line);
/*!
@name Application
@{
*/
static String app_dir;
virtual String GetAppPluginPath(const char *) const;
/// @}
/*!
@name Timer subsystem.
@{
*/
/// Get the platform clock.
virtual Time GetTime() = 0;
/// Return the system clock frequency.
virtual int GetClockFrequency() = 0;
/// Return the current clock.
virtual int GetClock() = 0;
/// Sleep platform for 'n' milliseconds.
virtual void Sleep(uint ms) = 0;
int GetStartClock() const;
Time GetStartTime() const;
/// System clock unit macros.
int GetSecond(int t) { return t * GetClockFrequency(); }
int GetMinute(int t) { return t * 60 * GetClockFrequency(); }
/// @}
/// Load a shared library.
virtual ISharedLib *LoadSharedLibrary(const char *) { return 0; }
Platform();
virtual ~Platform() {}
};
} // GS
#ifdef _DEBUG
#define __NTRACE(T) { GS::Platform::Get().Trace(T, __FILE__, __LINE__); }
#else
#define __NTRACE(T) ;
#endif
#endif // __PLATFORM__