## Public API Reference

- Main Page
- Classes
- Files

# 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 iCelPropertyClassFactory, public iComponent      \
    00031 {                                                                           \
    00032 private:                                                                    \
    00033   iObjectRegistry* object_reg;                                              \
    00034                                                                             \
    00035 public:                                                                     \
    00036   celPf##name (iBase* parent);                                              \
    00037   virtual ~celPf##name ();                                                  \
    00038   bool Initialize (iObjectRegistry* object_reg);                            \
    00039   SCF_DECLARE_IBASE;                                                        \
    00040   virtual const char* GetName() const;                                      \
    00041   virtual csPtr<iCelPropertyClass> CreatePropertyClass ();                  \
    00042 };
    00043
    00052 #define CEL_IMPLEMENT_FACTORY(name, strname)                                \
    00053 SCF_IMPLEMENT_FACTORY (celPf##name)                                         \
    00054 SCF_IMPLEMENT_IBASE (celPf##name)                                           \
    00055   SCF_IMPLEMENTS_INTERFACE (iCelPropertyClassFactory)                       \
    00056   SCF_IMPLEMENTS_INTERFACE (iComponent)                                     \
    00057 SCF_IMPLEMENT_IBASE_END                                                     \
    00058 celPf##name::celPf##name (iBase *parent)                                    \
    00059 {                                                                           \
    00060   SCF_CONSTRUCT_IBASE (parent);                                             \
    00061 }                                                                           \
    00062 celPf##name::~celPf##name()                                                 \
    00063 {                                                                           \
    00064   SCF_DESTRUCT_IBASE ();                                                    \
    00065 }                                                                           \
    00066 bool celPf##name::Initialize (iObjectRegistry* object_reg)                  \
    00067 {                                                                           \
    00068   celPf##name::object_reg = object_reg;                                     \
    00069   csRef<iCelPlLayer> pl (CS_QUERY_REGISTRY(object_reg, iCelPlLayer));       \
    00070   if (!pl) return false;                                                    \
    00071   pl->RegisterPropertyClassFactory(this);                                   \
    00072   return true;                                                              \
    00073 }                                                                           \
    00074 const char* celPf##name::GetName() const                                    \
    00075 {                                                                           \
    00076   return strname;                                                           \
    00077 }                                                                           \
    00078 csPtr<iCelPropertyClass> celPf##name::CreatePropertyClass()                 \
    00079 {                                                                           \
    00080   return csPtr<iCelPropertyClass> (new celPc##name (object_reg));           \
    00081 }                                                                           \
    00082
    00083 #endif
    00084