00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : David Mott (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_SUB_EVENT_ 00051 #define _SO_SUB_EVENT_ 00052 00053 #include <Inventor/events/SoEvent.h> 00054 #include <Inventor/SoType.h> 00055 #include <Inventor/misc/SoBasic.h> 00056 #if defined(_DEBUG) 00057 #include <Inventor/errors/SoDebugError.h> 00058 #endif 00059 00060 // *** note: many of the macros use the "do { ... } while(0)" 00061 // *** hack to define multiline blocks as a single statement 00062 // *** of code that can be used anywhere and ended with a semicolon 00063 00065 // 00066 // Macros to be called within the class definition header for an event 00067 // subclass: 00068 // 00069 00071 // 00072 // These defines type-identifier and naming variables and methods that 00073 // all subclasses and abstract subclasses must support. 00074 // 00075 00076 #define SO_EVENT_HEADER() \ 00077 public: \ 00078 \ 00079 static SoType getClassTypeId(); \ 00080 \ 00081 virtual SoType getTypeId() const; \ 00082 private: \ 00083 static SoType classTypeId /* Type id */ 00084 00085 00087 // 00088 // Macros to be called within the source file for an event subclass: 00089 // 00090 00092 // 00093 // This declares the static variables defined in SO_EVENT_HEADER 00094 // 00095 00096 #define SO__EVENT_VARS(className) \ 00097 SoType className::classTypeId; 00098 00099 00101 // 00102 // Methods on the type 00103 // 00104 00105 #define SO__EVENT_METHODS(className) \ 00106 \ 00107 SoType \ 00108 className::getTypeId() const \ 00109 { \ 00110 return classTypeId; \ 00111 } \ 00112 \ 00113 SoType \ 00114 className::getClassTypeId() \ 00115 { \ 00116 return classTypeId; \ 00117 } 00118 00120 // 00121 // These include all the definitions required 00122 // at file scope 00123 // 00124 00125 #define SO_EVENT_SOURCE(className) \ 00126 SO__EVENT_VARS(className); \ 00127 SO__EVENT_METHODS(className) 00128 00129 00130 #if defined(_DEBUG) 00131 #define SO_EVENT_INIT_CLASS_CHECK_PARENT(className, parentClass) \ 00132 if (parentClass::getClassTypeId().isBad()) { \ 00133 SoDebugError::post( SO__QUOTE(className)"::initClass", \ 00134 SO__QUOTE(className)" initialized before parent class " \ 00135 SO__QUOTE(parentClass)"\n"); \ 00136 parentClass::initClass(); \ 00137 } 00138 #else 00139 #define SO_EVENT_INIT_CLASS_CHECK_PARENT(className, parentClass) \ 00140 if (parentClass::getClassTypeId().isBad()) \ 00141 parentClass::initClass() 00142 #endif 00143 00145 // 00146 // This initializes the type identifer variables defined in 00147 // SO_EVENT_HEADER . This macro should be called from within initClass(). 00148 // The parentClass argument should be the class that this subclass is 00149 // derived from. 00150 // 00151 00152 #define SO_EVENT_INIT_CLASS_INTERNAL(className,parentClass) \ 00153 SO_EVENT_INIT_CLASS_CHECK_PARENT(className, parentClass); \ 00154 classTypeId = SoType::createType(parentClass::getClassTypeId(), SO__QUOTE(className)) 00155 00156 #define SO_EVENT_INIT_CLASS(className,parentClass) \ 00157 SO_EVENT_INIT_CLASS_INTERNAL(className,parentClass); 00158 00159 #if defined(_DEBUG) 00160 #define SO_EVENT_EXIT_CLASS(className) \ 00161 if (! SoType::removeType(classTypeId.getName())) { \ 00162 SoDebugError::post(SO__QUOTE(className)"::exitClass", \ 00163 "Unable to remove type (%s) for this class. Check exitClass() " \ 00164 "method is implemented and is called only once.\n", \ 00165 classTypeId.getName().getString() ); \ 00166 } \ 00167 else \ 00168 classTypeId = SoType::badType() 00169 #else 00170 #define SO_EVENT_EXIT_CLASS(className) \ 00171 SoType::removeType(classTypeId.getName()); \ 00172 classTypeId = SoType::badType() 00173 #endif 00174 00175 #endif /* _SO_SUB_EVENT_ */ 00176 00177