Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 * Interface to the commandline arguments 00027 */ 00028 00033 #include "CTR_Map.h" 00034 #include "STR_HashedString.h" 00035 #include "BL_System.h" 00036 00037 struct SingletonSystem { 00038 CTR_Map<STR_HashedString,int> int_params; 00039 CTR_Map<STR_HashedString,float> float_params; 00040 CTR_Map<STR_HashedString,STR_String> string_params; 00041 }; 00042 00043 static SingletonSystem *_system_instance = NULL; 00044 00045 SYS_SystemHandle SYS_GetSystem() 00046 { 00047 if(!_system_instance) 00048 _system_instance = new SingletonSystem(); 00049 00050 return (SYS_SystemHandle)_system_instance; 00051 } 00052 00053 void SYS_DeleteSystem(SYS_SystemHandle sys) 00054 { 00055 if(_system_instance) { 00056 delete _system_instance; 00057 _system_instance = NULL; 00058 } 00059 } 00060 00061 int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue) 00062 { 00063 int *result = ((SingletonSystem *)sys)->int_params[paramname]; 00064 if(result) 00065 return *result; 00066 00067 return defaultvalue; 00068 } 00069 00070 float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue) 00071 { 00072 float *result = ((SingletonSystem *)sys)->float_params[paramname]; 00073 if(result) 00074 return *result; 00075 00076 return defaultvalue; 00077 } 00078 00079 const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue) 00080 { 00081 STR_String *result = ((SingletonSystem *)sys)->string_params[paramname]; 00082 if(result) 00083 return *result; 00084 00085 return defaultvalue; 00086 } 00087 00088 void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, int value) 00089 { 00090 ((SingletonSystem *)sys)->int_params.insert(paramname, value); 00091 } 00092 00093 void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value) 00094 { 00095 ((SingletonSystem *)sys)->float_params.insert(paramname, value); 00096 } 00097 00098 void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value) 00099 { 00100 ((SingletonSystem *)sys)->string_params.insert(paramname, value); 00101 } 00102