CrystalSpace

Public API Reference

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

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  /* @@@ HACK: Force an AddAlias() call for every contained interface
00107   * However, when iSCF::SCF == 0, don't call QI to prevent interface ID 
00108   * resolution (which will fail).
00109   */
00110  #define SCF_INIT_TRACKER_ALIASES    \
00111   if (iSCF::SCF != 0) QueryInterface ((scfInterfaceID)-1, -1);
00112 #else
00113  #define CS_TYPENAME(x)             0
00114  #define SCF_INIT_TRACKER_ALIASES
00115 #endif
00116 
00121 #define SCF_DECLARE_IBASE                                               \
00122   int scfRefCount;              /* Reference counter */                 \
00123   csArray<iBase**>* scfWeakRefOwners;                                   \
00124   void scfRemoveRefOwners ();                                           \
00125   SCF_DECLARE_EMBEDDED_IBASE (iBase)
00126 
00131 #define SCF_DECLARE_EMBEDDED_IBASE(OuterClass)                          \
00132 public:                                                                 \
00133   OuterClass *scfParent;        /* The parent object */                 \
00134   virtual void IncRef ();                                               \
00135   virtual void DecRef ();                                               \
00136   virtual int GetRefCount ();                                           \
00137   virtual void AddRefOwner (iBase** ref_owner);                         \
00138   virtual void RemoveRefOwner (iBase** ref_owner);                      \
00139   virtual void *QueryInterface (scfInterfaceID iInterfaceID, int iVersion)
00140 
00150 #define SCF_CONSTRUCT_IBASE(Parent)                                     \
00151   csRefTrackerAccess::TrackConstruction (this);                         \
00152   csRefTrackerAccess::SetDescription (this, CS_TYPENAME(*this));        \
00153   scfRefCount = 1;                                                      \
00154   scfWeakRefOwners = 0;                                                 \
00155   scfParent = Parent; if (scfParent) scfParent->IncRef();               \
00156   SCF_INIT_TRACKER_ALIASES                                              
00157 
00167 #define SCF_CONSTRUCT_EMBEDDED_IBASE(Interface)                         \
00168   Interface.scfParent = this;                                           \
00169   csRefTrackerAccess::AddAlias (&Interface, this);
00170 
00176 #define SCF_DESTRUCT_IBASE()                                            \
00177   csRefTrackerAccess::TrackDestruction (this, scfRefCount);             \
00178   scfRemoveRefOwners ();
00179 
00186 #define SCF_DESTRUCT_EMBEDDED_IBASE(Interface)                          \
00187   csRefTrackerAccess::RemoveAlias (&Interface, this);                   \
00188   Interface.scfParent = 0;
00189 
00195 #define SCF_IMPLEMENT_IBASE_INCREF(Class)                               \
00196 void Class::IncRef ()                                                   \
00197 {                                                                       \
00198   SCF_TRACE (("  (%s *)%p->IncRef (%d)\n", #Class, this, scfRefCount + 1));\
00199   csRefTrackerAccess::TrackIncRef (this, scfRefCount);                  \
00200   scfRefCount++;                                                        \
00201 }
00202 
00211 #define SCF_IMPLEMENT_IBASE_DECREF(Class)                               \
00212 void Class::DecRef ()                                                   \
00213 {                                                                       \
00214   csRefTrackerAccess::TrackDecRef (this, scfRefCount);                  \
00215   if (scfRefCount == 1)                                                 \
00216   {                                                                     \
00217     SCF_TRACE ((" delete (%s *)%p\n", #Class, this));                   \
00218     scfRemoveRefOwners ();                                              \
00219     if (scfParent)                                                      \
00220       scfParent->DecRef ();                                             \
00221     delete this;                                                        \
00222     return;                                                             \
00223   }                                                                     \
00224   scfRefCount--;                                                        \
00225 }
00226 
00233 #define SCF_IMPLEMENT_IBASE_REMOVE_REF_OWNERS(Class)                    \
00234 void Class::scfRemoveRefOwners ()                                       \
00235 {                                                                       \
00236   if (!scfWeakRefOwners) return;                                        \
00237   for (size_t i = 0 ; i < scfWeakRefOwners->Length () ; i++)            \
00238   {                                                                     \
00239     iBase** p = (*scfWeakRefOwners)[i];                                 \
00240     *p = 0;                                                             \
00241   }                                                                     \
00242   delete scfWeakRefOwners;                                              \
00243   scfWeakRefOwners = 0;                                                 \
00244 }
00245 
00250 #define SCF_IMPLEMENT_IBASE_REFOWNER(Class)                             \
00251 void Class::AddRefOwner (iBase** ref_owner)                             \
00252 {                                                                       \
00253   if (!scfWeakRefOwners)                                                \
00254     scfWeakRefOwners = new csArray<iBase**> (0, 4);                     \
00255   scfWeakRefOwners->InsertSorted (ref_owner);                           \
00256 }                                                                       \
00257 void Class::RemoveRefOwner (iBase** ref_owner)                          \
00258 {                                                                       \
00259   if (!scfWeakRefOwners)                                                \
00260     return;                                                             \
00261   size_t index = scfWeakRefOwners->FindSortedKey (                      \
00262     csArrayCmp<iBase**, iBase**> (ref_owner));                          \
00263   if (index != csArrayItemNotFound) scfWeakRefOwners->DeleteIndex (     \
00264     index);                                                             \
00265 }
00266 
00271 #define SCF_IMPLEMENT_IBASE_GETREFCOUNT(Class)                          \
00272 int Class::GetRefCount ()                                               \
00273 {                                                                       \
00274   return scfRefCount;                                                   \
00275 }
00276 
00283 #define SCF_IMPLEMENT_IBASE_QUERY(Class)                                \
00284 void *Class::QueryInterface (scfInterfaceID iInterfaceID, int iVersion) \
00285 {                                                                       \
00286   SCF_TRACE (("  (%s *)%p->QueryInterface (%u, %08X)\n",                \
00287     #Class, this, iInterfaceID, iVersion));
00288 
00295 #define SCF_IMPLEMENT_IBASE_QUERY_END                                   \
00296   return scfParent ?                                                    \
00297     scfParent->QueryInterface (iInterfaceID, iVersion) : 0;             \
00298 }
00299 
00305 #define SCF_IMPLEMENT_IBASE(Class)                                      \
00306   SCF_IMPLEMENT_IBASE_INCREF(Class)                                     \
00307   SCF_IMPLEMENT_IBASE_DECREF(Class)                                     \
00308   SCF_IMPLEMENT_IBASE_GETREFCOUNT(Class)                                \
00309   SCF_IMPLEMENT_IBASE_REFOWNER(Class)                                   \
00310   SCF_IMPLEMENT_IBASE_REMOVE_REF_OWNERS(Class)                          \
00311   SCF_IMPLEMENT_IBASE_QUERY(Class)
00312 
00317 #define SCF_IMPLEMENT_IBASE_END                                         \
00318   SCF_IMPLEMENT_IBASE_QUERY_END
00319 
00326 #define SCF_IMPLEMENT_EMBEDDED_IBASE_INCREF(Class)                      \
00327 void Class::IncRef ()                                                   \
00328 {                                                                       \
00329   SCF_TRACE (("  (%s *)%p->IncRef (%d)\n", #Class, this,                \
00330     scfParent->GetRefCount () + 1));                                    \
00331   scfParent->IncRef ();                                                 \
00332 }
00333 
00340 #define SCF_IMPLEMENT_EMBEDDED_IBASE_DECREF(Class)                      \
00341 void Class::DecRef ()                                                   \
00342 {                                                                       \
00343   SCF_TRACE (("  (%s *)%p->DecRef (%d)\n", #Class, this,                \
00344               scfParent->GetRefCount ()-1));                            \
00345   scfParent->DecRef ();                                                 \
00346 }
00347 
00352 #define SCF_IMPLEMENT_EMBEDDED_IBASE_GETREFCOUNT(Class)                 \
00353 int Class::GetRefCount ()                                               \
00354 {                                                                       \
00355   return scfParent->GetRefCount ();                                     \
00356 }
00357 
00362 #define SCF_IMPLEMENT_EMBEDDED_IBASE_REFOWNER(Class)                    \
00363 void Class::AddRefOwner (iBase** ref_owner)                             \
00364 {                                                                       \
00365   scfParent->AddRefOwner (ref_owner);                                   \
00366 }                                                                       \
00367 void Class::RemoveRefOwner (iBase** ref_owner)                          \
00368 {                                                                       \
00369   scfParent->RemoveRefOwner (ref_owner);                                \
00370 }
00371 
00378 #define SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY(Class)                       \
00379 void *Class::QueryInterface (scfInterfaceID iInterfaceID, int iVersion) \
00380 {                                                                       \
00381   SCF_TRACE (("  (%s *)%p->QueryInterface (%u, %08X)\n",                \
00382     #Class, this, iInterfaceID, iVersion));
00383 
00390 #define SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY_END                          \
00391   return scfParent->QueryInterface (iInterfaceID, iVersion);            \
00392 }
00393 
00400 #define SCF_IMPLEMENT_EMBEDDED_IBASE(Class)                             \
00401   SCF_IMPLEMENT_EMBEDDED_IBASE_INCREF(Class)                            \
00402   SCF_IMPLEMENT_EMBEDDED_IBASE_DECREF(Class)                            \
00403   SCF_IMPLEMENT_EMBEDDED_IBASE_GETREFCOUNT(Class)                       \
00404   SCF_IMPLEMENT_EMBEDDED_IBASE_REFOWNER(Class)                          \
00405   SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY(Class)
00406 
00411 #define SCF_IMPLEMENT_EMBEDDED_IBASE_END                                \
00412   SCF_IMPLEMENT_EMBEDDED_IBASE_QUERY_END
00413 
00420 #define SCF_IMPLEMENTS_INTERFACE(Interface)                             \
00421   csRefTrackerAccess::AddAlias (CS_STATIC_CAST(Interface*, this), this);\
00422   SCF_IMPLEMENTS_INTERFACE_COMMON (Interface, this)
00423 
00428 #define SCF_IMPLEMENTS_EMBEDDED_INTERFACE(Interface)                    \
00429   SCF_IMPLEMENTS_INTERFACE_COMMON (Interface, (&scf##Interface))
00430 
00434 #define SCF_IMPLEMENTS_INTERFACE_COMMON(Interface,Object)               \
00435   static scfInterfaceID Interface##_scfID = (scfInterfaceID)-1;         \
00436   if (Interface##_scfID == (scfInterfaceID)-1)                          \
00437     Interface##_scfID = iSCF::SCF->GetInterfaceID (#Interface);         \
00438   if (iInterfaceID == Interface##_scfID &&                              \
00439     scfCompatibleVersion (iVersion, scfInterface<Interface>::GetVersion())) \
00440   {                                                                     \
00441     (Object)->IncRef ();                                                \
00442     return CS_STATIC_CAST(Interface*, Object);                          \
00443   }
00444 
00455 #define SCF_DECLARE_IBASE_EXT(ParentClass)                              \
00456   typedef ParentClass __scf_superclass;                                 \
00457   virtual void IncRef ();                                               \
00458   virtual void DecRef ();                                               \
00459   virtual int GetRefCount ();                                           \
00460   virtual void AddRefOwner (iBase** ref_owner);                         \
00461   virtual void RemoveRefOwner (iBase** ref_owner);                      \
00462   virtual void *QueryInterface (scfInterfaceID iInterfaceID, int iVersion)
00463 
00470 #define SCF_IMPLEMENT_IBASE_EXT_INCREF(Class)                           \
00471 void Class::IncRef ()                                                   \
00472 {                                                                       \
00473   __scf_superclass::IncRef ();                                          \
00474 }
00475 
00482 #define SCF_IMPLEMENT_IBASE_EXT_DECREF(Class)                           \
00483 void Class::DecRef ()                                                   \
00484 {                                                                       \
00485   __scf_superclass::DecRef ();                                          \
00486 }
00487 
00494 #define SCF_IMPLEMENT_IBASE_EXT_GETREFCOUNT(Class)                      \
00495 int Class::GetRefCount ()                                               \
00496 {                                                                       \
00497   return __scf_superclass::GetRefCount ();                              \
00498 }
00499 
00504 #define SCF_IMPLEMENT_IBASE_EXT_REFOWNER(Class)                 \
00505 void Class::AddRefOwner (iBase** ref_owner)                             \
00506 {                                                                       \
00507   __scf_superclass::AddRefOwner (ref_owner);                            \
00508 }                                                                       \
00509 void Class::RemoveRefOwner (iBase** ref_owner)                          \
00510 {                                                                       \
00511   __scf_superclass::RemoveRefOwner (ref_owner);                         \
00512 }
00513 
00520 #define SCF_IMPLEMENT_IBASE_EXT_QUERY(Class)                            \
00521 void *Class::QueryInterface (scfInterfaceID iInterfaceID, int iVersion) \
00522 {
00523 
00530 #define SCF_IMPLEMENT_IBASE_EXT_QUERY_END                               \
00531   return __scf_superclass::QueryInterface (iInterfaceID, iVersion);     \
00532 }
00533 
00538 #define SCF_IMPLEMENT_IBASE_EXT(Class)                                  \
00539   SCF_IMPLEMENT_IBASE_EXT_INCREF(Class)                                 \
00540   SCF_IMPLEMENT_IBASE_EXT_DECREF(Class)                                 \
00541   SCF_IMPLEMENT_IBASE_EXT_GETREFCOUNT(Class)                            \
00542   SCF_IMPLEMENT_IBASE_EXT_REFOWNER(Class)                               \
00543   SCF_IMPLEMENT_IBASE_EXT_QUERY(Class)
00544 
00549 #define SCF_IMPLEMENT_IBASE_EXT_END                                     \
00550   SCF_IMPLEMENT_IBASE_EXT_QUERY_END
00551 
00567 #ifdef CS_MEMORY_TRACKER
00568 // This special version of SCF_IMPLEMENT_FACTORY_INIT will make sure that
00569 // the memory tracker for this plugin is implemented.
00570 #define SCF_IMPLEMENT_FACTORY_INIT(Class)                               \
00571 static inline void Class ## _scfUnitInitialize(iSCF* SCF)               \
00572 {                                                                       \
00573   iSCF::SCF = SCF;                                                      \
00574   extern void RegisterMemoryTrackerModule (char*);                      \
00575   RegisterMemoryTrackerModule (#Class);                                 \
00576 }                                                                       \
00577 CS_EXPORTED_FUNCTION                                                    \
00578 void CS_EXPORTED_NAME(Class,_scfInitialize)(iSCF* SCF)                  \
00579 { Class ## _scfUnitInitialize(SCF); }
00580 #else
00581 #define SCF_IMPLEMENT_FACTORY_INIT(Class)                               \
00582 static inline void Class ## _scfUnitInitialize(iSCF* SCF)               \
00583 { iSCF::SCF = SCF; }                                                    \
00584 CS_EXPORTED_FUNCTION                                                    \
00585 void CS_EXPORTED_NAME(Class,_scfInitialize)(iSCF* SCF)                  \
00586 { Class ## _scfUnitInitialize(SCF); }
00587 #endif
00588 
00594 #define SCF_IMPLEMENT_FACTORY_FINIS(Class)                              \
00595 CS_EXPORTED_FUNCTION                                                    \
00596 void CS_EXPORTED_NAME(Class,_scfFinalize)()                             \
00597 {                                                                       \
00598 CS_STATIC_VARIABLE_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 
00670 #define SCF_DEFINE_FACTORY_FUNC_REGISTRATION(Class)                     \
00671   CS_EXPORTED_FUNCTION void* CS_EXPORTED_NAME(Class,_Create)(iBase*);   \
00672   class Class##_StaticInit                                              \
00673   {                                                                     \
00674   public:                                                               \
00675     Class##_StaticInit()                                                \
00676     {                                                                   \
00677       scfInitialize(0);                                                 \
00678       iSCF::SCF->RegisterFactoryFunc(CS_EXPORTED_NAME(Class,_Create),#Class); \
00679     }                                                                   \
00680   };
00681 
00686 #define SCF_USE_STATIC_PLUGIN(Module)                                   \
00687   namespace csStaticPluginInit                                          \
00688   {                                                                     \
00689     class Module { public: Module(); };                                 \
00690     Module Module##_StaticInit;                                         \
00691   }
00692 
00701 #define SCF_REGISTER_FACTORY_FUNC(Class)                                \
00702   SCF_DEFINE_FACTORY_FUNC_REGISTRATION(Class)                           \
00703   Class##_StaticInit Class##_static_init__;
00704 
00705 //--------------------------------------------- Class factory interface -----//
00706 
00720 struct iFactory : public iBase
00721 {
00723   virtual void *CreateInstance () = 0;
00725   virtual void TryUnload () = 0;
00727   virtual const char *QueryDescription () = 0;
00729   virtual const char *QueryDependencies () = 0;
00731   virtual const char *QueryClassID () = 0;
00733   virtual const char *QueryModuleName () = 0;
00734 };
00735 
00736 //----------------------------------------------- Client-side functions -----//
00737 
00738 struct iDocument;
00739 struct iStringArray;
00740 
00742 typedef void* (*scfFactoryFunc)(iBase*);
00743 
00748 #define SCF_CREATE_INSTANCE(ClassID,Interface)                          \
00749   csPtr<Interface> (                                                    \
00750     (Interface *)iSCF::SCF->CreateInstance (                            \
00751     ClassID, #Interface, scfInterface<Interface>::GetVersion()))
00752 
00765 #define SCF_VERSION(Name,Major,Minor,Micro)                             \
00766 struct Name;                                                            \
00767 CS_SPECIALIZE_TEMPLATE                                                  \
00768 class scfInterface<Name>                                                \
00769 {                                                                       \
00770 public:                                                                 \
00771   static int GetVersion()                                               \
00772   {                                                                     \
00773     return SCF_CONSTRUCT_VERSION(Major, Minor, Micro);                  \
00774   }                                                                     \
00775   static scfInterfaceID GetID()                                         \
00776   {                                                                     \
00777     static scfInterfaceID ID = (scfInterfaceID)-1;                      \
00778     if (ID == (scfInterfaceID)(-1))                                     \
00779       ID = iSCF::SCF->GetInterfaceID(#Name);                            \
00780     return ID;                                                          \
00781   }                                                                     \
00782   static char const* GetName()                                          \
00783   {                                                                     \
00784     return #Name;                                                       \
00785   }                                                                     \
00786 }
00787 
00794 template <class T> class scfInterface
00795 {
00796 public:
00801   static int GetVersion()
00802   {
00803     CS_ASSERT_MSG("illegal invocation of non-specialized "
00804       "scfInterface<>::GetVersion()", 1 == 0);
00805     return 0;
00806   }
00807 
00815   static scfInterfaceID GetID()
00816   {
00817     CS_ASSERT_MSG("illegal invocation of non-specialized "
00818       "scfInterface<>::GetID()", 1 == 0);
00819     return (scfInterfaceID)(-1);
00820   }
00821 
00825   static char const* GetName()
00826   {
00827     CS_ASSERT_MSG("illegal invocation of non-specialized "
00828       "scfInterface<>::GetName()", 1 == 0);
00829     return 0;
00830   }
00831 };
00832 
00837 #define SCF_QUERY_INTERFACE(Object,Interface)                           \
00838   csPtr<Interface> ((Interface *)(Object)->QueryInterface (             \
00839   scfInterface<Interface>::GetID (), scfInterface<Interface>::GetVersion()))
00840 
00846 #define SCF_QUERY_INTERFACE_SAFE(Object,Interface)                      \
00847   csPtr<Interface> ((Interface *)(iBase::QueryInterfaceSafe ((Object),  \
00848   scfInterface<Interface>::GetID (), scfInterface<Interface>::GetVersion())))
00849 
00865 extern CS_CSUTIL_EXPORT void scfInitialize(csPluginPaths* pluginPaths,
00866   bool verbose = false);
00867 
00872 extern CS_CSUTIL_EXPORT void scfInitialize(int argc, const char* const argv[]);
00873 
00880 static inline bool scfCompatibleVersion (int iVersion, int iItfVersion)
00881 {
00882   return ((iVersion & 0xff000000) == (iItfVersion & 0xff000000))
00883       && ((iVersion & 0x00ffffff) <= (iItfVersion & 0x00ffffff));
00884 }
00885 
00886 #if defined(CS_DEBUG) || defined(CS_MEMORY_TRACKER)
00887   struct iObjectRegistry;
00888 #endif
00889 
00896 struct iSCF : public iBase
00897 {
00909   static CS_CSUTIL_EXPORT iSCF* SCF;
00910 
00911 #if defined(CS_DEBUG) || defined(CS_MEMORY_TRACKER)
00912   // This is EXTREMELY dirty but I see no other solution for now.
00913   // For debugging reasons I must have a global (global over the application
00914   // and all plugins)pointer to the object registry. I have no other
00915   // global object to tag this pointer on that except for iSCF.
00916   // This pointer is only here in debug mode though. That ensures that it
00917   // cannot be misused in real code.
00918   // If you know another solution for this problem? This global pointer
00919   // will be used by csDebuggingGraph in csutil.
00920   iObjectRegistry* object_reg;
00921 #endif
00922 
00926   virtual void RegisterClasses (iDocument* metadata,
00927     const char* context = 0) = 0;
00928 
00934   virtual void RegisterClasses (char const* xml,
00935     const char* context = 0) = 0;
00936 
00940   virtual void RegisterClasses (const char* pluginPath,
00941     iDocument* metadata, const char* context = 0) = 0;
00942 
00949   virtual bool ClassRegistered (const char *iClassID) = 0;
00950 
00966   virtual void *CreateInstance (const char *iClassID,
00967         const char *iInterface, int iVersion) = 0;
00968 
00974   virtual const char *GetClassDescription (const char *iClassID) = 0;
00975 
00981   virtual const char *GetClassDependencies (const char *iClassID) = 0;
00982 
01009   virtual csRef<iDocument> GetPluginMetadata (char const *iClassID) = 0;
01010 
01017   virtual void UnloadUnusedModules () = 0;
01018 
01029   virtual bool RegisterClass (const char *iClassID,
01030         const char *iLibraryName, const char *iFactoryClass,
01031         const char *Description, const char *Dependencies = 0,
01032         const char* context = 0) = 0;
01033 
01040   virtual bool RegisterClass (scfFactoryFunc, const char *iClassID,
01041         const char *Description, const char *Dependencies = 0,
01042         const char* context = 0) = 0;
01043 
01051   virtual bool RegisterFactoryFunc (scfFactoryFunc, const char *FactClass) = 0;
01052 
01059   virtual bool UnregisterClass (const char *iClassID) = 0;
01060 
01065   virtual char const* GetInterfaceName (scfInterfaceID) const = 0;
01066 
01072   virtual scfInterfaceID GetInterfaceID (const char *iInterface) = 0;
01073 
01080   virtual void Finish () = 0;
01081 
01091   virtual csRef<iStringArray> QueryClassList (char const* pattern) = 0;
01092 
01096   virtual void ScanPluginsPath (const char* path, bool recursive = false,
01097     const char* context = 0) = 0;
01098 
01108   virtual bool RegisterPlugin (const char* path) = 0;
01109 };
01110 
01111 SCF_VERSION (iFactory, 0, 0, 2);
01112 SCF_VERSION (iBase, 0, 1, 0);
01113 SCF_VERSION (iSCF, 0, 2, 1);
01114 
01115 // A bit hacky.
01116 #include "csutil/reftrackeraccess.h"
01117 
01120 #endif // __CSSCF_H__

Generated for Crystal Space by doxygen 1.3.9.1