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

Base


Classes

class  Callback
 Base class for callback with no arguments and no return value. More...

class  CallbackR
class  Callback1
class  CallbackR1
class  Callback2
class  CallbackR2
class  Callback3
class  CallbackR3
class  FunctionCallback
class  FunctionCallbackR
class  FunctionCallback1
class  FunctionCallbackR1
class  FunctionCallback2
class  FunctionCallbackR2
class  FunctionCallback3
class  FunctionCallbackR3
class  MethodCallback
class  MethodCallbackR
class  MethodCallback1
class  MethodCallbackR1
class  MethodCallback2
class  MethodCallbackR2
class  MethodCallback3
class  MethodCallbackR3
class  Ref
 Smart pointer class Smart pointers provide automatic memory management, so that programmer never cares on freeing memory. Smart pointers mechanism frees an object when there are no any references to it. Smart pointers should be used instead of standard C pointers:
  Object* obj; // standard pointer, should be deleted after use
  gml::Ref<Object> obj; // smart pointer frees memory when necessary
Attention:
Smart pointers works only with objects that support AddRef() and Release() operations. It is assumed that object keeps a reference count (a number of smapt pointers pointing to it). This reference count is incremented in AddRef() command and decremented in Release(). Also Release() performs check whether reference count is 0 and calls 'delete this'. GML provides special base class for this: gml::SmartObject. If you want to use smart pointers either derive your object from this class or provide own implementation of AddRef() and Release() methods. 1) initialization Smart pointers are initiliazed just like the standard pointers:
  gml::Ref<Object> obj =  new Object(1,2,3);

Smart pointers must never be defined like this: gml::Rev<Object>* obj; !!! 2) use of smart pointers Smart pointers are dereferenced like normal pointers:

  gml::Ref<Object> obj =  new Object(1,2,3);
  obj->SomeMethod();
  (*obj).SomeMethod();
3) smart pointers as parameters Smart pointers are implicitly casted to normal pointers:
  gml::Ref<Object> obj =  new Object(1,2,3);
  Object* obj1 =  obj;
This operation is dangerous unless used properly. You should use it like follows. Smart pointers may be passed to functions and returned from functions like normal pointers.
  ...
  Object* SomeMethod(Object* obj);
  ...
  gml::Ref<Object> obj =  new Object(1,2,3);
  gml::Ref<Object> obj1 = SomeMethod(obj);
The general rule is this: Use ONLY smart pointers when storing objects. Use normals pointers when passing smart pointers as parameters or return values So the following is forbidden:
  class SomeClass
    {
    private:
      Object* obj;
    public:
      void CreateObject()
        {
        gml::Ref<Object> obj = new Object(1,2,3);
        m_obj = obj;
        } // at this point obj will be deleted, and m_obj will be undefined!!
    };
Correct use:
  class SomeClass
    {
    private:
      gml::Ref<Object> obj;
    public:
      void CreateObject()
        {
        gml::Ref<Object> obj = new Object(1,2,3);
        m_obj = obj;
        } 
    };
.
More...

class  SmartObject
 Base class for objects with support for reference counting. More...

class  String
 Standard string with some extensions. More...

class  Ref
 Smart pointer class Smart pointers provide automatic memory management, so that programmer never cares on freeing memory. Smart pointers mechanism frees an object when there are no any references to it. Smart pointers should be used instead of standard C pointers:
  Object* obj; // standard pointer, should be deleted after use
  gml::Ref<Object> obj; // smart pointer frees memory when necessary
Attention:
Smart pointers works only with objects that support AddRef() and Release() operations. It is assumed that object keeps a reference count (a number of smapt pointers pointing to it). This reference count is incremented in AddRef() command and decremented in Release(). Also Release() performs check whether reference count is 0 and calls 'delete this'. GML provides special base class for this: gml::SmartObject. If you want to use smart pointers either derive your object from this class or provide own implementation of AddRef() and Release() methods. 1) initialization Smart pointers are initiliazed just like the standard pointers:
  gml::Ref<Object> obj =  new Object(1,2,3);

Smart pointers must never be defined like this: gml::Rev<Object>* obj; !!! 2) use of smart pointers Smart pointers are dereferenced like normal pointers:

  gml::Ref<Object> obj =  new Object(1,2,3);
  obj->SomeMethod();
  (*obj).SomeMethod();
3) smart pointers as parameters Smart pointers are implicitly casted to normal pointers:
  gml::Ref<Object> obj =  new Object(1,2,3);
  Object* obj1 =  obj;
This operation is dangerous unless used properly. You should use it like follows. Smart pointers may be passed to functions and returned from functions like normal pointers.
  ...
  Object* SomeMethod(Object* obj);
  ...
  gml::Ref<Object> obj =  new Object(1,2,3);
  gml::Ref<Object> obj1 = SomeMethod(obj);
The general rule is this: Use ONLY smart pointers when storing objects. Use normals pointers when passing smart pointers as parameters or return values So the following is forbidden:
  class SomeClass
    {
    private:
      Object* obj;
    public:
      void CreateObject()
        {
        gml::Ref<Object> obj = new Object(1,2,3);
        m_obj = obj;
        } // at this point obj will be deleted, and m_obj will be undefined!!
    };
Correct use:
  class SomeClass
    {
    private:
      gml::Ref<Object> obj;
    public:
      void CreateObject()
        {
        gml::Ref<Object> obj = new Object(1,2,3);
        m_obj = obj;
        } 
    };
.
More...


Functions

Ref< newT > & gml::Ref::ConvRef (const Ref< oldT > &old_ref)
 Casting & convertion of smart references.


Generated on Tue Jan 13 21:12:02 2004 for Graphics and Media Lab CSL by doxygen 1.3.4