📄 appframework.h
字号:
//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose: An application framework
//
// $Revision: $
// $NoKeywords: $
//=============================================================================
#ifndef APPFRAMEWORK_H
#define APPFRAMEWORK_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IAppSystem;
//-----------------------------------------------------------------------------
// Handle to a DLL
//-----------------------------------------------------------------------------
typedef int AppModule_t;
enum
{
APP_MODULE_INVALID = (AppModule_t)~0
};
//-----------------------------------------------------------------------------
// This interface represents a group of app systems that all have the same
// lifetime that need to be connected/initialized, etc. in a well-defined order
//-----------------------------------------------------------------------------
class IAppSystemGroup
{
public:
// This method will add a module (DLL) to the app system group
// returns APP_MODULE_INVALID in case of error
virtual AppModule_t LoadModule( const char *pDLLName ) = 0;
// Method to add various global singleton systems
// Passing a module == APP_MODULE_INVALID will cause this to return NULL always
// returns NULL if it fails
virtual IAppSystem *AddSystem( AppModule_t module, const char *pInterfaceName ) = 0;
// Finds a system in the group..
virtual void *FindSystem( const char *pSystemName ) = 0;
// Gets at a factory that works just like FindSystem
virtual CreateInterfaceFn GetFactory() = 0;
};
//-----------------------------------------------------------------------------
// Create a window (windows apps only)..
//-----------------------------------------------------------------------------
///bool CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h );
//void *GetAppWindow();
void *GetAppInstance();
//-----------------------------------------------------------------------------
// NOTE: The following methods may be implemented in your application
// although you need not implement them all...
//-----------------------------------------------------------------------------
class IApplication
{
public:
// An installed application creation function, you should tell the group
// the DLLs and the singleton interfaces you want to instantiate.
// Return false if there's any problems and the app will abort
virtual bool Create( IAppSystemGroup *pAppSystemGroup ) = 0;
// Allow the application to do some work after AppSystems are connected but
// they are all Initialized.
// Return false if there's any problems and the app will abort
virtual bool PreInit( IAppSystemGroup *pAppSystemGroup ) = 0;
// Main loop implemented by the application
virtual void Main() = 0;
// Allow the application to do some work after all AppSystems are shut down
virtual void PostShutdown() = 0;
// Call an installed application destroy function, occurring after all modules
// are unloaded
virtual void Destroy() = 0;
};
#define DEFINE_APPLICATION_OBJECT( _className ) \
static _className *s_ApplicationObject; \
IApplication *__g_pApplicationObject = &s_ApplicationObject
#define DEFINE_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
IApplication *__g_pApplicationObject = &_globalVarName
#endif // APPFRAMEWORK_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -