[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3.7 Advanced Techniques

The SCF library implements some things that you will need to know about to use some advanced techniques. They are described in detail, below.

Dynamic Class Registration

You can register and deregister SCF classes at run time. You can even dynamically replace one class with another if you use same ID during registration. There are two functions that can be used to dynamically register classes; one for registering classes in shared libraries and one for registering classes within client module. To register a class that is located inside a shared library, use this function:

 
bool iSCF::RegisterClass(
    char const* iClassID,
    char const* iLibraryName);

The prototype should be self-describing. As any method of iSCF, you should call the function as `iSCF::SCF->RegisterClass()'. If you have a class that is linked into the executable, you should prepare a structure of the `scfClassInfo' type and pass it to the following function:

 
bool iSCF::RegisterClass(scfClassInfo*);

You should fill the `ClassID' and `Factory' fields. The `Description' field is not used except by the `scfreg' utility.

You can deregister an already registered class with the following function:

 
bool iSCF::UnregisterClass(char const* iClassID);

Non-Registered Classes

Sometimes you don't want to register your classes with the SCF kernel. That is, you create your objects manually, using `new' or some other method. In this case your object is not a part of the class tree (see above) and thus doesn't have a parent. In this case you have to pass `0' to the SCF_CONSTRUCT_IBASE() macro in constructor.

 
MyClass::MyClass()
{
  SCF_CONSTRUCT_IBASE(0)
}

If you also want your object to not be automatically deleted when the reference count reaches zero, you can use SCF_IMPLEMENT_EMBEDDED_IBASE() instead of SCF_IMPLEMENT_IBASE(), as if your object was an embedded interface. Embedded interfaces don't have the habit of deleting themselves when their reference count reaches zero. In this case you should take care and delete your object manually.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html