Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

onstartup.h

00001 //==========================================================================
00002 //   ONSTARTUP.H - header for
00003 //                             OMNeT++
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  EXECUTE_ON_STARTUP macro and supporting class
00008 //
00009 //==========================================================================
00010 
00011 /*--------------------------------------------------------------*
00012   Copyright (C) 1992-2003 Andras Varga
00013 
00014   This file is distributed WITHOUT ANY WARRANTY. See the file
00015   `license' for details on this and other legal matters.
00016 *--------------------------------------------------------------*/
00017 
00018 #ifndef __ONSTARTUP_H
00019 #define __ONSTARTUP_H
00020 
00021 #include "defs.h"
00022 
00023 
00033 #define EXECUTE_ON_STARTUP(NAME, CODE)  \
00034  static void __##NAME##_code() {CODE;} \
00035  static ExecuteOnStartup __##NAME##_reg(__##NAME##_code);
00036 
00037 
00038 //
00039 // Example:
00040 // EXECUTE_ON_STARTUP(EthernetModule, (new EthernetModuleType()->setOwner(&modules)))
00041 //
00042 
00048 class ExecuteOnStartup
00049 {
00050      private:
00051          void (*code_to_exec)();
00052          ExecuteOnStartup *next;
00053          static ExecuteOnStartup *head;
00054      public:
00055          ExecuteOnStartup(void (*code_to_exec)());
00056          ~ExecuteOnStartup();
00057          void execute();
00058          static void executeAll();
00059 };
00060 
00061 #endif
00062 

Generated at Mon Jun 16 23:37:31 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001