NAME

OTC_TObject - Class to allow actions to be run on abnormal program termination.

SYNOPSIS


#include <OTC/debug/tobject.hh>

class OTC_TObject
{
  public:
    virtual ~OTC_TObject();
    static void terminateAll();
  protected:
    OTC_TObject();
    virtual void cleanup() = 0;
};

CLASS TYPE

Abstract

DESCRIPTION

Any of your classes, which need to perform special actions in the event of abnormal program termination, should be derived from this class. In your derived class, you should redefine the cleanup() function, to initiate any actions which your class needs to perform. This function will be called when terminate() is invoked, provided that you have registered a terminate function which invokes the function OTC_TObject::terminateAll(). Note that your cleanup() function should do as little as possible. If your function results in OTCLIB_TERMINATE() being called, then this will result in abort() being called. It is not known what a real exception implementation will do in this situation yet, thus no special checks are made in terminate() for looping; they are only done in OTCLIB_TERMINATE(). The requirement for this class will largely vanish when real exceptions are available, as most objects will be destroyed automatically as a result of the stack being unwound, when an exception occurs. This class could still be useful though to ensure that destructors of objects on the free store, referenced through pointers at global scope, are destroyed.

DESTRUCTION

virtual ~OTC_TObject();

TERMINATION

static void terminateAll();

CONSTRUCTION

OTC_TObject();

CLEANUP

virtual void cleanup() = 0;

LIBRARY

OTC

AUTHOR(S)

Graham Dumpleton

COPYRIGHT

Copyright 1991 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED