PixelLightAPI  .
FrontendMain.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: FrontendMain.h                                 *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_FRONTENDMAIN_H__
00024 #define __PLCORE_FRONTENDMAIN_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/Main.h"
00032 #include "PLCore/Runtime.h"
00033 #include "PLCore/ModuleMain.h"
00034 #include "PLCore/Frontend/Frontend.h"
00035 #include "PLCore/Frontend/FrontendContext.h"
00036 
00037 
00038 //[-------------------------------------------------------]
00039 //[ Macros                                                ]
00040 //[-------------------------------------------------------]
00041 /**
00042 *  @brief
00043 *    Defines a default frontend for a module inside a plugin library
00044 *
00045 *  @param[in] ModuleName
00046 *    Module name
00047 *  @param[in] ApplicationClass
00048 *    Name of the application RTTI class to use (must be derived from "PLCore::FrontendApplication")
00049 *
00050 *  @remarks
00051 *    Use this when you don't want to care about the program entry point.
00052 */
00053 #define pl_module_application(ModuleName, ApplicationClass) \
00054     int PLMain(const PLCore::String &sExecutableFilename, const PLCore::Array<PLCore::String> &lstArguments) \
00055     { \
00056         /* Scan PL-runtime directory for compatible plugins and load them in as well as scan for compatible data and register it */ \
00057         if (PLCore::Runtime::ScanDirectoryPluginsAndData()) { \
00058             /* Setup the frontend context */ \
00059             PLCore::FrontendContext cFrontendContext; \
00060             cFrontendContext.SetExecutableFilename(sExecutableFilename); \
00061             cFrontendContext.SetArguments(lstArguments); \
00062             cFrontendContext.SetName(ModuleName); \
00063             cFrontendContext.SetFrontendParameters(PLCore::String("ApplicationClass=\"") + ApplicationClass + '\"'); \
00064     \
00065             /* Run the frontend */ \
00066             return PLCore::Frontend::Run(cFrontendContext); \
00067         } else { \
00068             /* Error! */ \
00069             return -1; \
00070         } \
00071     } \
00072     \
00073     pl_module_plugin(ModuleName)
00074 
00075 /**
00076 *  @brief
00077 *    Defines a frontend for a module inside a plugin library
00078 *
00079 *  @param[in] ModuleName
00080 *    Module name
00081 *  @param[in] ApplicationClass
00082 *    Name of the application RTTI class to use (must be derived from "PLCore::FrontendApplication")
00083 *  @param[in] FrontendClass
00084 *    Name of the frontend implementation RTTI class to use (e.g. "PLFrontendOS::Frontend")
00085 *
00086 *  @remarks
00087 *    Use this when you don't want to care about the program entry point.
00088 */
00089 #define pl_module_application_frontend(ModuleName, ApplicationClass, FrontendClass) \
00090     int PLMain(const PLCore::String &sExecutableFilename, const PLCore::Array<PLCore::String> &lstArguments) \
00091     { \
00092         /* Scan PL-runtime directory for compatible plugins and load them in as well as scan for compatible data and register it */ \
00093         if (PLCore::Runtime::ScanDirectoryPluginsAndData()) { \
00094             /* Setup the frontend context */ \
00095             PLCore::FrontendContext cFrontendContext; \
00096             cFrontendContext.SetExecutableFilename(sExecutableFilename); \
00097             cFrontendContext.SetArguments(lstArguments); \
00098             cFrontendContext.SetName(ModuleName); \
00099             cFrontendContext.SetFrontendParameters(PLCore::String("ApplicationClass=\"") + ApplicationClass + '\"'); \
00100             cFrontendContext.SetFrontendImplementation(FrontendClass); \
00101     \
00102             /* Run the frontend */ \
00103             return PLCore::Frontend::Run(cFrontendContext); \
00104         } else { \
00105             /* Error! */ \
00106             return -1; \
00107         } \
00108     } \
00109     \
00110     pl_module_plugin(ModuleName)
00111 
00112 
00113 #endif // __PLCORE_FRONTENDMAIN_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:54
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported