CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csutil/scf.h

Go to the documentation of this file.
00001 /*
00002     Crystal Space Shared Class Facility (SCF)
00003     Copyright (C) 1999 by Andrew Zabolotny
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CSSCF_H__
00021 #define __CSSCF_H__
00022 
00023 #include "csextern.h"
00024 
00033 class csPluginPaths;
00034 
00035 #include "ref.h"
00036 #include "array.h"
00037 
00041 typedef unsigned long scfInterfaceID;
00042 
00047 #ifdef SCF_DEBUG
00048 #  define SCF_TRACE(x)                                                  \
00049    {                                                                    \
00050      printf ("SCF [%s:%d]:\n", __FILE__, __LINE__);                     \
00051      printf x; SCF_PRINT_CALL_ADDRESS                                   \
00052    }
00053 #else
00054 #  define SCF_TRACE(x)
00055 #endif
00056 
00061 #if (__GNUC__ >= 3) || ((__GNUC__ >= 2) && (__GNUC_MINOR__ >= 8))
00062 #  define SCF_PRINT_CALL_ADDRESS                                        \
00063    printf ("  Called from address %p\n", __builtin_return_address (0));
00064 #else
00065 #  define SCF_PRINT_CALL_ADDRESS
00066 #endif
00067 
00069 #define SCF_CONSTRUCT_VERSION(Major,Minor,Micro)                        \
00070   ((Major << 24) | (Minor << 16) | Micro)
00071 
00077 struct iBase
00078 {
00080   virtual void IncRef () = 0;
00082   virtual void DecRef () = 0;
00084   virtual int GetRefCount () = 0;
00086   virtual void *QueryInterface (scfInterfaceID iInterfaceID, int iVersion) = 0;
00091   static void* QueryInterfaceSafe (iBase* ibase, scfInterfaceID iInterfaceID,
00092         int iVersion)
00093   {
00094     if (ibase == 0) return 0;
00095     else return ibase->QueryInterface (iInterfaceID, iVersion);
00096   }
00098   virtual void AddRefOwner (iBase** ref_owner) = 0;
00100   virtual void RemoveRefOwner (iBase** ref_owner) = 0;
00101 };
00102 
00103 #ifdef CS_REF_TRACKER
00104  #include <typeinfo>
00105  #define CS_TYPENAME(x)             typeid(x).name()
00106 
00107  #define SCF_INIT_TRACKER_ALIASES    QueryInterface ((scfInterfaceID)-1, -1);
00108 #else
00109  #define CS_TYPENAME(x)             0
00110  #define SCF_INIT_TRACKER_ALIASES
00111 #endif
00112 
00117 #define SCF_DECLARE_IBASE                                               \
00118   int scfRefCount;              /* Reference counter */                 \
00119   csArray<iBase**>* scfWeakRefOwners;                                   \
00120   void scfRemoveRefOwners ();                                           \
00121   SCF_DECLARE_EMBEDDED_IBASE (iBase)
00122 
00127 #define SCF_DECLARE_EMBEDDED_IBASE(OuterClass)                          \
00128 public:                                                                 \
00129   OuterClass *scfParent;        /* The parent object */                 \
00130   virtual void IncRef ();                                               \
00131   virtual void DecRef ();                                               \
00132   virtual int GetRefCount ();                                           \
00133   virtual void AddRefOwner (iBase** ref_owner);                         \
00134   virtual void RemoveRefOwner (iBase** ref_owner);                      \
00135   virtual void *QueryInterface (scfInterfaceID iInterfaceID, int iVersion)
00136 
00146 #define SCF_CONSTRUCT_IBASE(Parent)                                     \
00147   csRefTrackerAccess::TrackConstruction (this);                         \
00148   csRefTrackerAccess::SetDescription (this, CS_TYPENAME(*this));        \
00149   scfRefCount = 1;                                                      \
00150   scfWeakRefOwners = 0;                                                 \
00151   scfParent = Parent; if (scfParent) scfParent->IncRef();               \
00152   SCF_INIT_TRACKER_ALIASES                                              
00153 
00163 #define SCF_CONSTRUCT_EMBEDDED_IBASE(Interface)                         \
00164   Interface.scfParent = this;                                           \
00165   csRefTrackerAccess::AddAlias (&Interface, this);
00166 
00172 #define SCF_DESTRUCT_IBASE()                                            \
00173   csRefTrackerAccess::TrackDestruction (this, scfRefCount);             \
00174   scfRemoveRefOwners ();
00175 
00182 #define SCF_DESTRUCT_EMBEDDED_IBASE(Interface)                          \
00183   csRefTrackerAccess::RemoveAlias (&Interface, this);                   \
00184   Interface.scfParent = 0;
00185 
00191 #define SCF_IMPLEMENT_IBASE_INCREF(Class)                               \
00192 void Class::IncRef ()                                                   \
00193 {                                                                       \
00194   SCF_TRACE (("  (%s *)%p->IncRef (%d)\n", #Class, this, scfRefCount + 1));\
00195   csRefTrackerAccess::TrackIncRef (this, scfRefCount);                  \
00196   scfRefCount++;                                                        \
00197 }
00198 
00207 #define SCF_IMPLEMENT_IBASE_DECREF(Class)                               \
00208 void Class::DecRef ()                                                   \
00209 {                                                                       \
00210   csRefTrackerAccess::TrackDecRef (this, scfRefCount);                  \
00211   if (scfRefCount == 1)                                                 \
00212   {                                                                     \
00213     SCF_TRACE ((" delete (%s *)%p\n", #Class, this));                   \
00214     scfRemoveRefOwners ();                                              \
00215     if (scfParent)                                                      \
00216       scfParent->DecRef ();                                             \
00217     delete this;                                                        \
00218     return;                                                             \
00219   }                                                                     \
00220   scfRefCount--;                                                        \
00221 }
00222 
00229 #define SCF_IMPLEMENT_IBASE_REMOVE_REF_OWNERS(Class)                    \
00230 void Class::scfRemoveRefOwners ()                                       \
00231 {                                                                       \
00232   if (!scfWeakRefOwners) return;                                        \
00233   for (int i = 0 ; i < scfWeakRefOwners->Length () ; i++)               \
00234   {                                                                     \
00235     iBase** p = (*scfWeakRefOwners)[i];                                 \
00236     *p = 0;                                                             \
00237   }                                                                     \
00238   delete scfWeakRefOwners;                                              \
00239   scfWeakRefOwners = 0;                                                 \
00240 }
00241 
00246 #define SCF_IMPLEMENT_IBASE_REFOWNER(Class)                             \
00247 void Class::AddRefOwner (iBase** ref_owner)                             \
00248 {                                                                       \
00249   if (!scfWeakRefOwners)                                                \
00250     scfWeakRefOwners = new csArray<iBase**>;                            \
00251   scfWeakRefOwners->Push (ref_owner);                                   \
00252 }                                                                       \
00253 void Class::RemoveRefOwner (iBase** ref_owner)                          \
00254 {                                                                       \
00255   if (!scfWeakRefOwners)                                                \
00256     scfWeakRefOwners = new csArray<iBase**>;                            \
00257   scfWeakRefOwners->Delete (ref_owner);                                 \
00258 }
00259 
00264 #define SCF_IMPLEMENT_IBASE_GETREFCOUNT(Class)                          \
00265 int Class::GetRefCount ()                                               \
00266 {                                                                       \
00267   return scfRefCount;                                                   \
00268 }
00269 
00276 #define SCF_IMPLEMENT_IBASE_QUERY(Class)                                \
00277 void *Class::QueryInterface (scfInterfaceID iInterfaceID, int iVersion) \
00278 {                                                                       \
00279   SCF_TRACE (("  (%s *)%p->QueryInterface (%u, %08X)\n",                \
00280     #Class, this, iInterfaceID, iVersion));
00281 
00288 #define SCF_IMPLEMENT_IBASE_QUERY_END                                   \
00289   return scfParent ?                                                    \
00290     scfParent->QueryInterface (iInterfaceID, iVersion) : 0;             \
00291 }
00292 
00298 #define SCF_IMPLEMENT_IBASE(Class)                                      \
00299   SCF_IMPLEMENT_IBASE_INCREF(Class)                                     \
00300   SCF_IMPLEMENT_IBASE_DECREF(Class)                                     \
00301   SCF_IMPLEMENT_IBASE_GETREFCOUNT(Class)                                \
00302   SCF_IMPLEMENT_IBASE_REFOWNER(Class)                                   \
00303   SCF_IMPLEMENT_IBASE_REMOVE_REF_OWNERS(Class)                          \
00304   SCF_IMPLEMENT_IBASE_QUERY(Class)
00305 
00310 #define SCF_IMPLEMENT_IBASE_END                                         \
00311   SCF_IMPLEMENT_IBASE_QUERY_END
00312 
00319 #define SCF_IMPLEMENT_EMBEDDED_IBASE_INCREF(Class)                      \
00320 void Class::IncRef ()                                                   \
00321 {                                                                       \
00322   SCF_TRACE (("  (%s *)%p->IncRef (%d)\n", #Class, this,                \
00323     scfParent->GetRefCount () + 1));                                    \
00324   scfParent->IncRef ();                                                 \
00325 }
00326 
00333 #define SCF_IMPLEMENT_EMBEDDED_IBASE_DECREF(Class)                      \
00334 void Class::DecRef ()                                                   \
00335 {                                                                       \
00336   SCF_TRACE (("  (%s *)%p->DecRef (%d)\n", #Class, this,                \
00337               scfParent->GetRefCount ()-1));                            \
00338   scfParent->DecRef ();                                                 \
00339 }
00340 
00345 #define SCF_IMPLEMENT_EMBEDDED_IBASE_GETREFCOUNT(Class)                 \
00346 int Class::GetRefCount ()                                               \
00347 {                                                                       \
00348   return scfParent->GetRefCount ();                                     \
00349 }
00350 
00355 #define SCF_IMPLEMENT_EMBEDDED_IBASE_REFOWNER(Class)                    \
00356 void Class::AddRefOwner (iBase** ref_owner)                             \
00357 {                                                                       \
00358   scfParent->AddRefOwner (ref_owner);                                   \
00359 }                                                                       \
00360 void Class::RemoveRefOwner (iBase** ref_owner)                          \
00361 {                                                                       \
00362   scfParent->RemoveRefOwner (ref_owner);                                \
00363 }
00364 
00371 #define SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY(Class)                       \
00372 void *Class::QueryInterface (scfInterfaceID iInterfaceID, int iVersion) \
00373 {                                                                       \
00374   SCF_TRACE (("  (%s *)%p->QueryInterface (%u, %08X)\n",                \
00375     #Class, this, iInterfaceID, iVersion));
00376 
00383 #define SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY_END                          \
00384   return scfParent->QueryInterface (iInterfaceID, iVersion);            \
00385 }
00386 
00393 #define SCF_IMPLEMENT_EMBEDDED_IBASE(Class)                             \
00394   SCF_IMPLEMENT_EMBEDDED_IBASE_INCREF(Class)                            \
00395   SCF_IMPLEMENT_EMBEDDED_IBASE_DECREF(Class)                            \
00396   SCF_IMPLEMENT_EMBEDDED_IBASE_GETREFCOUNT(Class)                       \
00397   SCF_IMPLEMENT_EMBEDDED_IBASE_REFOWNER(Class)                          \
00398   SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY(Class)
00399 
00404 #define SCF_IMPLEMENT_EMBEDDED_IBASE_END                                \
00405   SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY_END
00406 
00413 #define SCF_IMPLEMENTS_INTERFACE(Interface)                             \
00414   csRefTrackerAccess::AddAlias (CS_STATIC_CAST(Interface*, this), this);\
00415   SCF_IMPLEMENTS_INTERFACE_COMMON (Interface, this)
00416 
00421 #define SCF_IMPLEMENTS_EMBEDDED_INTERFACE(Interface)                    \
00422   SCF_IMPLEMENTS_INTERFACE_COMMON (Interface, (&scf##Interface))
00423 
00427 #define SCF_IMPLEMENTS_INTERFACE_COMMON(Interface,Object)               \
00428   static scfInterfaceID Interface##_scfID = (scfInterfaceID)-1;         \
00429   if (Interface##_scfID == (scfInterfaceID)-1)                          \
00430     Interface##_scfID = iSCF::SCF->GetInterfaceID (#Interface);         \
00431   if (iInterfaceID == Interface##_scfID &&                              \
00432     scfCompatibleVersion (iVersion, scfInterface<Interface>::GetVersion())) \
00433   {                                                                     \
00434     (Object)->IncRef ();                                                \
00435     return CS_STATIC_CAST(Interface*, Object);                          \
00436   }
00437 
00448 #define SCF_DECLARE_IBASE_EXT(ParentClass)                              \
00449   typedef ParentClass __scf_superclass;                                 \
00450   virtual void IncRef ();                                               \
00451   virtual void DecRef ();                                               \
00452   virtual int GetRefCount ();                                           \
00453   virtual void AddRefOwner (iBase** ref_owner);                         \
00454   virtual void RemoveRefOwner (iBase** ref_owner);                      \
00455   virtual void *QueryInterface (scfInterfaceID iInterfaceID, int iVersion)
00456 
00463 #define SCF_IMPLEMENT_IBASE_EXT_INCREF(Class)                           \
00464 void Class::IncRef ()                                                   \
00465 {                                                                       \
00466   __scf_superclass::IncRef ();                                          \
00467 }
00468 
00475 #define SCF_IMPLEMENT_IBASE_EXT_DECREF(Class)                           \
00476 void Class::DecRef ()                                                   \
00477 {                                                                       \
00478   __scf_superclass::DecRef ();                                          \
00479 }
00480 
00487 #define SCF_IMPLEMENT_IBASE_EXT_GETREFCOUNT(Class)                      \
00488 int Class::GetRefCount ()                                               \
00489 {                                                                       \
00490   return __scf_superclass::GetRefCount ();                              \
00491 }
00492 
00497 #define SCF_IMPLEMENT_IBASE_EXT_REFOWNER(Class)                 \
00498 void Class::AddRefOwner (iBase** ref_owner)                             \
00499 {                                                                       \
00500   __scf_superclass::AddRefOwner (ref_owner);                            \
00501 }                                                                       \
00502 void Class::RemoveRefOwner (iBase** ref_owner)                          \
00503 {                                                                       \
00504   __scf_superclass::RemoveRefOwner (ref_owner);                         \
00505 }
00506 
00513 #define SCF_IMPLEMENT_IBASE_EXT_QUERY(Class)                            \
00514 void *Class::QueryInterface (scfInterfaceID iInterfaceID, int iVersion) \
00515 {
00516 
00523 #define SCF_IMPLEMENT_IBASE_EXT_QUERY_END                               \
00524   return __scf_superclass::QueryInterface (iInterfaceID, iVersion);     \
00525 }
00526 
00531 #define SCF_IMPLEMENT_IBASE_EXT(Class)                                  \
00532   SCF_IMPLEMENT_IBASE_EXT_INCREF(Class)                                 \
00533   SCF_IMPLEMENT_IBASE_EXT_DECREF(Class)                                 \
00534   SCF_IMPLEMENT_IBASE_EXT_GETREFCOUNT(Class)                            \
00535   SCF_IMPLEMENT_IBASE_EXT_REFOWNER(Class)                               \
00536   SCF_IMPLEMENT_IBASE_EXT_QUERY(Class)
00537 
00542 #define SCF_IMPLEMENT_IBASE_EXT_END                                     \
00543   SCF_IMPLEMENT_IBASE_EXT_QUERY_END
00544 
00560 #ifdef CS_MEMORY_TRACKER
00561 // This special version of SCF_IMPLEMENT_FACTORY_INIT will make sure that
00562 // the memory tracker for this plugin is implemented.
00563 #define SCF_IMPLEMENT_FACTORY_INIT(Class)                               \
00564 static inline void Class ## _scfUnitInitialize(iSCF* SCF)               \
00565 {                                                                       \
00566   iSCF::SCF = SCF;                                                      \
00567   extern void RegisterMemoryTrackerModule (char*);                      \
00568   RegisterMemoryTrackerModule (#Class);                                 \
00569 }                                                                       \
00570 CS_EXPORTED_FUNCTION                                                    \
00571 void CS_EXPORTED_NAME(Class,_scfInitialize)(iSCF* SCF)                  \
00572 { Class ## _scfUnitInitialize(SCF); }
00573 #else
00574 #define SCF_IMPLEMENT_FACTORY_INIT(Class)                               \
00575 static inline void Class ## _scfUnitInitialize(iSCF* SCF)               \
00576 { iSCF::SCF = SCF; }                                                    \
00577 CS_EXPORTED_FUNCTION                                                    \
00578 void CS_EXPORTED_NAME(Class,_scfInitialize)(iSCF* SCF)                  \
00579 { Class ## _scfUnitInitialize(SCF); }
00580 #endif
00581 
00582 #ifdef CS_BUILD_SHARED_LIBS
00583 # define SCF_STATIC_VAR_CLEANUP
00584 #else
00585 # define SCF_STATIC_VAR_CLEANUP         CS_STATIC_VARIABLE_CLEANUP
00586 #endif
00587 
00593 #define SCF_IMPLEMENT_FACTORY_FINIS(Class)                              \
00594 CS_DECLARE_STATIC_VARIABLE_CLEANUP                                      \
00595 CS_EXPORTED_FUNCTION                                                    \
00596 void CS_EXPORTED_NAME(Class,_scfFinalize)()                             \
00597 {                                                                       \
00598 SCF_STATIC_VAR_CLEANUP                                                  \
00599 }
00600 
00607 #define SCF_IMPLEMENT_FACTORY_CREATE(Class)                             \
00608 CS_EXPORTED_FUNCTION                                                    \
00609 void* CS_EXPORTED_NAME(Class,_Create)(iBase *iParent)                   \
00610 {                                                                       \
00611   void *ret = new Class (iParent);                                      \
00612   SCF_TRACE (("  %p = new %s ()\n", ret, #Class));                      \
00613   return ret;                                                           \
00614 }
00615 
00622 #define SCF_IMPLEMENT_FACTORY(Class)                                    \
00623   SCF_IMPLEMENT_FACTORY_INIT(Class)                                     \
00624   SCF_IMPLEMENT_FACTORY_FINIS(Class)                                    \
00625   SCF_IMPLEMENT_FACTORY_CREATE(Class)
00626 
00627 #define SCF_STATIC_CLASS_CONTEXT      "*static*"
00628 
00637 #define SCF_REGISTER_STATIC_CLASS(Class,Ident,Desc,Dep)                 \
00638   CS_EXPORTED_FUNCTION void* CS_EXPORTED_NAME(Class,_Create)(iBase*);   \
00639   class Class##_StaticInit__                                            \
00640   {                                                                     \
00641   public:                                                               \
00642     Class##_StaticInit__()                                              \
00643     {                                                                   \
00644       scfInitialize(0);                                                 \
00645       iSCF::SCF->RegisterClass(                                         \
00646         CS_EXPORTED_NAME(Class,_Create), Ident, Desc, Dep,              \
00647         SCF_STATIC_CLASS_CONTEXT);                                      \
00648     }                                                                   \
00649   } Class##_static_init__;
00650 
00655 #define SCF_REGISTER_STATIC_LIBRARY(Module, MetaInfo)                   \
00656   class Module##_StaticInit                                             \
00657   {                                                                     \
00658   public:                                                               \
00659     Module##_StaticInit()                                               \
00660     {                                                                   \
00661       scfInitialize(0);                                                 \
00662       iSCF::SCF->RegisterClasses(MetaInfo, SCF_STATIC_CLASS_CONTEXT);   \
00663     }                                                                   \
00664   } Module##_static_init__;
00665 
00674 #define SCF_REGISTER_FACTORY_FUNC(Class)                                \
00675   CS_EXPORTED_FUNCTION void* CS_EXPORTED_NAME(Class,_Create)(iBase*);   \
00676   class Class##_StaticInit                                              \
00677   {                                                                     \
00678   public:                                                               \
00679     Class##_StaticInit()                                                \
00680     {                                                                   \
00681       scfInitialize(0);                                                 \
00682       iSCF::SCF->RegisterFactoryFunc(CS_EXPORTED_NAME(Class,_Create),#Class); \
00683     }                                                                   \
00684   } Class##_static_init__;
00685 
00686 //--------------------------------------------- Class factory interface -----//
00687 
00701 struct iFactory : public iBase
00702 {
00704   virtual void *CreateInstance () = 0;
00706   virtual void TryUnload () = 0;
00708   virtual const char *QueryDescription () = 0;
00710   virtual const char *QueryDependencies () = 0;
00712   virtual const char *QueryClassID () = 0;
00713 };
00714 
00715 //----------------------------------------------- Client-side functions -----//
00716 
00717 struct iDocument;
00718 struct iStringArray;
00719 
00721 typedef void* (*scfFactoryFunc)(iBase*);
00722 
00727 #define SCF_CREATE_INSTANCE(ClassID,Interface)                          \
00728   csPtr<Interface> (                                                    \
00729     (Interface *)iSCF::SCF->CreateInstance (                            \
00730     ClassID, #Interface, scfInterface<Interface>::GetVersion()))
00731 
00744 #define SCF_VERSION(Name,Major,Minor,Micro)                             \
00745 struct Name;                                                            \
00746 CS_SPECIALIZE_TEMPLATE                                                  \
00747 class scfInterface<Name>                                                \
00748 {                                                                       \
00749 public:                                                                 \
00750   static int GetVersion()                                               \
00751   {                                                                     \
00752     return SCF_CONSTRUCT_VERSION(Major, Minor, Micro);                  \
00753   }                                                                     \
00754   static scfInterfaceID GetID()                                         \
00755   {                                                                     \
00756     static scfInterfaceID ID = (scfInterfaceID)-1;                      \
00757     if (ID == (scfInterfaceID)(-1))                                     \
00758       ID = iSCF::SCF->GetInterfaceID(#Name);                            \
00759     return ID;                                                          \
00760   }                                                                     \
00761   static char const* GetName()                                          \
00762   {                                                                     \
00763     return #Name;                                                       \
00764   }                                                                     \
00765 };
00766 
00773 template <class T> class scfInterface
00774 {
00775 public:
00780   static int GetVersion()
00781   {
00782     CS_ASSERT_MSG("illegal invocation of non-specialized "
00783       "scfInterface<>::GetVersion()", 1 == 0);
00784     return 0;
00785   }
00786 
00794   static scfInterfaceID GetID()
00795   {
00796     CS_ASSERT_MSG("illegal invocation of non-specialized "
00797       "scfInterface<>::GetID()", 1 == 0);
00798     return (scfInterfaceID)(-1);
00799   }
00800 
00804   static char const* GetName()
00805   {
00806     CS_ASSERT_MSG("illegal invocation of non-specialized "
00807       "scfInterface<>::GetName()", 1 == 0);
00808     return 0;
00809   }
00810 };
00811 
00816 #define SCF_QUERY_INTERFACE(Object,Interface)                           \
00817   csPtr<Interface> ((Interface *)(Object)->QueryInterface (             \
00818   scfInterface<Interface>::GetID (), scfInterface<Interface>::GetVersion()))
00819 
00825 #define SCF_QUERY_INTERFACE_SAFE(Object,Interface)                      \
00826   csPtr<Interface> ((Interface *)(iBase::QueryInterfaceSafe ((Object),  \
00827   scfInterface<Interface>::GetID (), scfInterface<Interface>::GetVersion())))
00828 
00842 extern CS_CSUTIL_EXPORT void scfInitialize (csPluginPaths* pluginPaths);
00843 
00848 extern CS_CSUTIL_EXPORT void scfInitialize (int argc, const char* const argv[]);
00849 
00856 static inline bool scfCompatibleVersion (int iVersion, int iItfVersion)
00857 {
00858   return ((iVersion & 0xff000000) == (iItfVersion & 0xff000000))
00859       && ((iVersion & 0x00ffffff) <= (iItfVersion & 0x00ffffff));
00860 }
00861 
00862 #ifdef CS_DEBUG
00863   struct iObjectRegistry;
00864 #endif
00865 
00872 struct iSCF : public iBase
00873 {
00885   static CS_CSUTIL_EXPORT iSCF* SCF;
00886 
00887 #ifdef CS_DEBUG
00888   // This is EXTREMELY dirty but I see no other solution for now.
00889   // For debugging reasons I must have a global (global over the application
00890   // and all plugins)pointer to the object registry. I have no other
00891   // global object to tag this pointer on that except for iSCF.
00892   // This pointer is only here in debug mode though. That ensures that it
00893   // cannot be misused in real code.
00894   // If you know another solution for this problem? This global pointer
00895   // will be used by csDebuggingGraph in csutil.
00896   iObjectRegistry* object_reg;
00897 #endif
00898 
00902   virtual void RegisterClasses (iDocument* metadata,
00903     const char* context = 0) = 0;
00904 
00910   virtual void RegisterClasses (char const* xml,
00911     const char* context = 0) = 0;
00912 
00916   virtual void RegisterClasses (const char* pluginPath,
00917     iDocument* metadata, const char* context = 0) = 0;
00918 
00925   virtual bool ClassRegistered (const char *iClassID) = 0;
00926 
00942   virtual void *CreateInstance (const char *iClassID,
00943         const char *iInterface, int iVersion) = 0;
00944 
00950   virtual const char *GetClassDescription (const char *iClassID) = 0;
00951 
00957   virtual const char *GetClassDependencies (const char *iClassID) = 0;
00958 
00985   virtual csRef<iDocument> GetPluginMetadata (char const *iClassID) = 0;
00986 
00993   virtual void UnloadUnusedModules () = 0;
00994 
01005   virtual bool RegisterClass (const char *iClassID,
01006         const char *iLibraryName, const char *iFactoryClass,
01007         const char *Description, const char *Dependencies = 0,
01008         const char* context = 0) = 0;
01009 
01016   virtual bool RegisterClass (scfFactoryFunc, const char *iClassID,
01017         const char *Description, const char *Dependencies = 0,
01018         const char* context = 0) = 0;
01019 
01027   virtual bool RegisterFactoryFunc (scfFactoryFunc, const char *FactClass) = 0;
01028 
01035   virtual bool UnregisterClass (const char *iClassID) = 0;
01036 
01041   virtual char const* GetInterfaceName (scfInterfaceID) const = 0;
01042 
01048   virtual scfInterfaceID GetInterfaceID (const char *iInterface) = 0;
01049 
01056   virtual void Finish () = 0;
01057 
01067   virtual csRef<iStringArray> QueryClassList (char const* pattern) = 0;
01068 
01072   virtual void ScanPluginsPath (const char* path, bool recursive = false,
01073     const char* context = 0) = 0;
01074 
01084   virtual bool RegisterPlugin (const char* path) = 0;
01085 };
01086 
01087 SCF_VERSION (iFactory, 0, 0, 1);
01088 SCF_VERSION (iBase, 0, 1, 0);
01089 SCF_VERSION (iSCF, 0, 2, 1);
01090 
01091 // A bit hacky.
01092 #include "csutil/reftrackeraccess.h"
01093 
01096 #endif // __CSSCF_H__

Generated for Crystal Space by doxygen 1.2.18