![]() |
http://www.sim.no/ http://www.coin3d.org/ |
00001 #ifndef COIN_SOSUBACTION_H 00002 #define COIN_SOSUBACTION_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) by Kongsberg Oil & Gas Technologies. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Kongsberg Oil & Gas Technologies 00018 * about acquiring a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #ifndef COIN_INTERNAL 00028 // Added to be Inventor compliant. 00029 #include <Inventor/SbString.h> 00030 #include <Inventor/actions/SoAction.h> 00031 #endif // COIN_INTERNAL 00032 #include <Inventor/C/tidbits.h> 00033 00034 // ************************************************************************* 00035 00036 #define SO_ACTION_ADD_METHOD(_nodeclass_, _method_) \ 00037 do { \ 00038 addMethod(_nodeclass_::getClassTypeId(), (SoActionMethod)_method_); \ 00039 } while (0) 00040 00041 // ************************************************************************* 00042 00043 #define SO_ACTION_CONSTRUCTOR(_classname_) \ 00044 do { \ 00045 _classname_::traversalMethods = this->methods; \ 00046 } while (0) 00047 00048 // ************************************************************************* 00049 00050 #define SO_ACTION_HEADER(_classname_) \ 00051 public: \ 00052 virtual SoType getTypeId(void) const; \ 00053 static SoType getClassTypeId(void); \ 00054 \ 00055 static void addMethod(const SoType type, SoActionMethod method); \ 00056 \ 00057 static void enableElement(const SoType type, const int stackindex); \ 00058 \ 00059 protected: \ 00060 virtual const SoEnabledElementsList & getEnabledElements(void) const; \ 00061 /* These two methods are not available in the original OIV API. */ \ 00062 /* They have been added as a work-around for Win32 DLL headaches. */ \ 00063 /* See further explanation below. 20000808 mortene. */ \ 00064 static SoEnabledElementsList * getClassEnabledElements(void); \ 00065 static SoActionMethodList * getClassActionMethods(void); \ 00066 \ 00067 private: \ 00068 /* The enabledElements and methods variables are protected in */ \ 00069 /* the original OIV API. This is not such a good idea, since */ \ 00070 /* exposed static class member variables is a major grievance */ \ 00071 /* with regard to Win32 DLLs. */ \ 00072 static void atexit_cleanup(void); \ 00073 static SoEnabledElementsList * enabledElements; \ 00074 static SoActionMethodList * methods; \ 00075 static SoType classTypeId 00076 00077 // ************************************************************************* 00078 00079 #define SO_ACTION_SOURCE(_classname_) \ 00080 SoEnabledElementsList * _classname_::enabledElements = NULL; \ 00081 SoActionMethodList * _classname_::methods = NULL; \ 00082 SoEnabledElementsList * _classname_::getClassEnabledElements(void) { return _classname_::enabledElements; } \ 00083 SoActionMethodList * _classname_::getClassActionMethods(void) { return _classname_::methods; } \ 00084 SoType _classname_::classTypeId STATIC_SOTYPE_INIT; \ 00085 SoType _classname_::getClassTypeId(void) { return _classname_::classTypeId; } \ 00086 SoType _classname_::getTypeId(void) const { return _classname_::classTypeId; } \ 00087 const SoEnabledElementsList & _classname_::getEnabledElements(void) const \ 00088 { \ 00089 assert(_classname_::enabledElements); \ 00090 return *_classname_::enabledElements; \ 00091 } \ 00092 void \ 00093 _classname_::addMethod(const SoType type, SoActionMethod method) \ 00094 { \ 00095 assert(_classname_::methods); \ 00096 _classname_::methods->addMethod(type, method); \ 00097 } \ 00098 void \ 00099 _classname_::enableElement(const SoType type, const int stackindex) \ 00100 { \ 00101 assert(_classname_::enabledElements); \ 00102 _classname_::enabledElements->enable(type, stackindex); \ 00103 } \ 00104 void \ 00105 _classname_::atexit_cleanup(void) \ 00106 { \ 00107 delete _classname_::enabledElements; \ 00108 _classname_::enabledElements = NULL; \ 00109 delete _classname_::methods; \ 00110 _classname_::methods = NULL; \ 00111 _classname_::classTypeId STATIC_SOTYPE_INIT; \ 00112 } 00113 00114 // ************************************************************************* 00115 00116 #define SO_ACTION_INIT_CLASS(_classname_, _parentclassname_) \ 00117 do { \ 00118 assert(_classname_::getClassTypeId() == SoType::badType()); \ 00119 assert(_parentclassname_::getClassTypeId() != SoType::badType()); \ 00120 _classname_::classTypeId = SoType::createType(_parentclassname_::getClassTypeId(), SO__QUOTE(_classname_)); \ 00121 _classname_::enabledElements = new SoEnabledElementsList(_parentclassname_::getClassEnabledElements()); \ 00122 _classname_::methods = new SoActionMethodList(_parentclassname_::getClassActionMethods()); \ 00123 cc_coin_atexit_static_internal(reinterpret_cast<coin_atexit_f *>(_classname_::atexit_cleanup)); \ 00124 } while (0) 00125 00126 // ************************************************************************* 00127 00128 #endif // !COIN_SOSUBACTION_H
Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.
Generated on 19 Dec 2016 for Coin by Doxygen 1.6.1.