00001 // callback.h 00002 // Data structure to allow an object to register a "callback". 00003 // On an asynchronous operation, the call to start the operation 00004 // returns immediately. When the operation completes, the called 00005 // object must somehow notify the caller of the completion. 00006 // In the general case, the called object doesn't know the type 00007 // of the caller. 00008 // 00009 // We implement this using virtual functions in C++. An object 00010 // that needs to register a callback is set up as a derived class of 00011 // the abstract base class "CallbackObj". When we pass a 00012 // pointer to the object to a lower level module, that module 00013 // calls back via "obj->CallBack()", without knowing the 00014 // type of the object being called back. 00015 // 00016 // Note that this isn't a general-purpose mechanism, 00017 // because a class can only register a single callback. 00018 // 00019 // DO NOT CHANGE -- part of the machine emulation 00020 // 00021 // Copyright (c) 1992-1996 The Regents of the University of California. 00022 // All rights reserved. See copyright.h for copyright notice and limitation 00023 // of liability and disclaimer of warranty provisions. 00024 // 00025 00026 #ifndef CALLBACK_H 00027 #define CALLBACK_H 00028 00029 #include "copyright.h" 00030 00031 // Abstract base class for objects that register callbacks 00032 00033 class CallBackObj { 00034 public: 00035 virtual void CallBack() = 0; 00036 protected: 00037 CallBackObj() {}; // to prevent anyone from creating 00038 // an instance of this class. Only 00039 // allow creation of instances of 00040 // classes derived from this class. 00041 virtual ~CallBackObj() {}; 00042 }; 00043 00044 #endif