Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
pluginconfig.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1998 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library 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 GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_IUTIL_PLUGINCONFIG_H__ 00020 #define __CS_IUTIL_PLUGINCONFIG_H__ 00021 00026 #include "csutil/scf.h" 00027 00029 enum csVariantType 00030 { 00032 CSVAR_LONG, 00034 CSVAR_BOOL, 00036 CSVAR_CMD, 00038 CSVAR_FLOAT, 00040 CSVAR_STRING 00041 }; 00042 00048 struct csVariant 00049 { 00050 private: 00051 csVariantType type; 00052 union value 00053 { 00054 long l; 00055 bool b; 00056 float f; 00057 char* s; 00058 } v; 00059 00060 public: 00061 csVariant () { type = CSVAR_LONG; v.s = 0; } 00062 ~csVariant () { if (type == CSVAR_STRING) delete[] v.s; } 00064 void SetLong (long l) 00065 { 00066 if (type == CSVAR_STRING) delete[] v.s; 00067 type = CSVAR_LONG; 00068 v.l = l; 00069 } 00071 void SetBool (bool b) 00072 { 00073 if (type == CSVAR_STRING) delete[] v.s; 00074 type = CSVAR_BOOL; 00075 v.b = b; 00076 } 00078 void SetFloat (float f) 00079 { 00080 if (type == CSVAR_STRING) delete[] v.s; 00081 type = CSVAR_FLOAT; 00082 v.f = f; 00083 } 00085 void SetString (const char* s) 00086 { 00087 if (type == CSVAR_STRING) delete[] v.s; 00088 type = CSVAR_STRING; 00089 if (s) 00090 v.s = csStrNew (s); 00091 else 00092 v.s = 0; 00093 } 00095 void SetCommand () 00096 { 00097 if (type == CSVAR_STRING) delete[] v.s; 00098 type = CSVAR_CMD; 00099 } 00100 00102 long GetLong () const 00103 { 00104 CS_ASSERT (type == CSVAR_LONG); 00105 return v.l; 00106 } 00108 bool GetBool () const 00109 { 00110 CS_ASSERT (type == CSVAR_BOOL); 00111 return v.b; 00112 } 00114 float GetFloat () const 00115 { 00116 CS_ASSERT (type == CSVAR_FLOAT); 00117 return v.f; 00118 } 00120 const char* GetString () const 00121 { 00122 CS_ASSERT (type == CSVAR_STRING); 00123 return v.s; 00124 } 00125 csVariantType GetType () const { return type; } 00126 }; 00127 00129 struct csOptionDescription 00130 { 00132 int id; 00134 const char* name; 00136 const char* description; 00138 csVariantType type; 00139 }; 00140 00141 //SCF_VERSION (iPluginConfig, 1, 0, 0); 00161 struct iPluginConfig : public virtual iBase 00162 { 00163 SCF_INTERFACE(iPluginConfig,2,0,0); 00165 virtual bool GetOptionDescription (int idx, csOptionDescription *option) = 0; 00167 virtual bool SetOption (int id, csVariant* value) = 0; 00169 virtual bool GetOption (int id, csVariant* value) = 0; 00170 }; 00173 #endif // __CS_IUTIL_PLUGINCONFIG_H__
Generated for Crystal Space by doxygen 1.4.4