physicallayer/facttmpl.h
00001 /* 00002 Crystal Space Entity Layer 00003 Copyright (C) 2001 by Jorrit Tyberghein 00004 This file was written by Matze Braun <MatzeBraun@gmx.de> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public 00017 License along with this library; if not, write to the Free 00018 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef __FACTTMPL_H__ 00022 #define __FACTTMPL_H__ 00023 00029 #define CEL_DECLARE_FACTORY(name) \ 00030 class celPf##name : public scfImplementation2<celPf##name, \ 00031 iCelPropertyClassFactory, iComponent> \ 00032 { \ 00033 private: \ 00034 iObjectRegistry* object_reg; \ 00035 \ 00036 public: \ 00037 celPf##name (iBase* parent) : scfImplementationType (this, parent) { } \ 00038 virtual ~celPf##name () { } \ 00039 bool Initialize (iObjectRegistry* object_reg); \ 00040 virtual const char* GetName() const; \ 00041 virtual csPtr<iCelPropertyClass> CreatePropertyClass (const char* name); \ 00042 }; 00043 00052 #define CEL_IMPLEMENT_FACTORY(name, strname) \ 00053 SCF_IMPLEMENT_FACTORY (celPf##name) \ 00054 bool celPf##name::Initialize (iObjectRegistry* object_reg) \ 00055 { \ 00056 celPf##name::object_reg = object_reg; \ 00057 csRef<iCelPlLayer> pl = csQueryRegistry<iCelPlLayer> (object_reg); \ 00058 if (!pl) return false; \ 00059 pl->RegisterPropertyClassFactory(this, 0); \ 00060 return true; \ 00061 } \ 00062 const char* celPf##name::GetName() const \ 00063 { \ 00064 return strname; \ 00065 } \ 00066 csPtr<iCelPropertyClass> celPf##name::CreatePropertyClass(const char* name) \ 00067 { \ 00068 iCelPropertyClass* pc = new celPc##name (object_reg); \ 00069 pc->SetName (name); \ 00070 return csPtr<iCelPropertyClass> (pc); \ 00071 } \ 00072 00073 00077 #define CEL_IMPLEMENT_FACTORY_ALT(name, strname, altname) \ 00078 SCF_IMPLEMENT_FACTORY (celPf##name) \ 00079 bool celPf##name::Initialize (iObjectRegistry* object_reg) \ 00080 { \ 00081 celPf##name::object_reg = object_reg; \ 00082 csRef<iCelPlLayer> pl = csQueryRegistry<iCelPlLayer> (object_reg); \ 00083 if (!pl) return false; \ 00084 pl->RegisterPropertyClassFactory(this, altname); \ 00085 return true; \ 00086 } \ 00087 const char* celPf##name::GetName() const \ 00088 { \ 00089 return strname; \ 00090 } \ 00091 csPtr<iCelPropertyClass> celPf##name::CreatePropertyClass(const char* name) \ 00092 { \ 00093 iCelPropertyClass* pc = new celPc##name (object_reg); \ 00094 pc->SetName (name); \ 00095 return csPtr<iCelPropertyClass> (pc); \ 00096 } \ 00097 00098 #endif
Generated for CEL: Crystal Entity Layer 1.4.1 by doxygen 1.7.1