![]() |
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) 1998-2007 by Systems in Motion. All rights reserved. 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 Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, 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 #else // !COIN_INTERNAL 00032 #include <Inventor/SbName.h> 00033 #include <Inventor/actions/SoSubActionP.h> 00034 #endif // COIN_INTERNAL 00035 00036 // ************************************************************************* 00037 00038 #define SO_ACTION_ADD_METHOD(_nodeclass_, _method_) \ 00039 do { \ 00040 addMethod(_nodeclass_::getClassTypeId(), (SoActionMethod)_method_); \ 00041 } while (0) 00042 00043 // ************************************************************************* 00044 00045 #define SO_ACTION_CONSTRUCTOR(_classname_) \ 00046 do { \ 00047 _classname_::traversalMethods = this->methods; \ 00048 } while (0) 00049 00050 // ************************************************************************* 00051 00052 #define SO_ACTION_HEADER(_classname_) \ 00053 public: \ 00054 virtual SoType getTypeId(void) const; \ 00055 static SoType getClassTypeId(void); \ 00056 \ 00057 static void addMethod(const SoType type, SoActionMethod method); \ 00058 \ 00059 static void enableElement(const SoType type, const int stackindex); \ 00060 \ 00061 protected: \ 00062 virtual const SoEnabledElementsList & getEnabledElements(void) const; \ 00063 /* These two methods are not available in the original OIV API. */ \ 00064 /* They have been added as a work-around for Win32 DLL headaches. */ \ 00065 /* See further explanation below. 20000808 mortene. */ \ 00066 static SoEnabledElementsList * getClassEnabledElements(void); \ 00067 static SoActionMethodList * getClassActionMethods(void); \ 00068 \ 00069 private: \ 00070 /* The enabledElements and methods variables are protected in */ \ 00071 /* the original OIV API. This is not such a good idea, since */ \ 00072 /* exposed static class member variables is a major grievance */ \ 00073 /* with regard to Win32 DLLs. */ \ 00074 static void atexit_cleanup(void); \ 00075 static SoEnabledElementsList * enabledElements; \ 00076 static SoActionMethodList * methods; \ 00077 static SoType classTypeId 00078 00079 // ************************************************************************* 00080 00081 #define SO_ACTION_SOURCE(_classname_) \ 00082 SoEnabledElementsList * _classname_::enabledElements = NULL; \ 00083 SoActionMethodList * _classname_::methods = NULL; \ 00084 SoEnabledElementsList * _classname_::getClassEnabledElements(void) { return _classname_::enabledElements; } \ 00085 SoActionMethodList * _classname_::getClassActionMethods(void) { return _classname_::methods; } \ 00086 SoType _classname_::classTypeId STATIC_SOTYPE_INIT; \ 00087 SoType _classname_::getClassTypeId(void) { return _classname_::classTypeId; } \ 00088 SoType _classname_::getTypeId(void) const { return _classname_::classTypeId; } \ 00089 const SoEnabledElementsList & _classname_::getEnabledElements(void) const \ 00090 { \ 00091 assert(_classname_::enabledElements); \ 00092 return *_classname_::enabledElements; \ 00093 } \ 00094 void \ 00095 _classname_::addMethod(const SoType type, SoActionMethod method) \ 00096 { \ 00097 assert(_classname_::methods); \ 00098 _classname_::methods->addMethod(type, method); \ 00099 } \ 00100 void \ 00101 _classname_::enableElement(const SoType type, const int stackindex) \ 00102 { \ 00103 assert(_classname_::enabledElements); \ 00104 _classname_::enabledElements->enable(type, stackindex); \ 00105 } \ 00106 void \ 00107 _classname_::atexit_cleanup(void) \ 00108 { \ 00109 delete _classname_::enabledElements; \ 00110 _classname_::enabledElements = NULL; \ 00111 delete _classname_::methods; \ 00112 _classname_::methods = NULL; \ 00113 _classname_::classTypeId STATIC_SOTYPE_INIT; \ 00114 } 00115 00116 // ************************************************************************* 00117 00118 #define SO_ACTION_INIT_CLASS(_classname_, _parentclassname_) \ 00119 do { \ 00120 assert(_classname_::getClassTypeId() == SoType::badType()); \ 00121 assert(_parentclassname_::getClassTypeId() != SoType::badType()); \ 00122 _classname_::classTypeId = SoType::createType(_parentclassname_::getClassTypeId(), SO__QUOTE(_classname_)); \ 00123 _classname_::enabledElements = new SoEnabledElementsList(_parentclassname_::getClassEnabledElements()); \ 00124 _classname_::methods = new SoActionMethodList(_parentclassname_::getClassActionMethods()); \ 00125 } while (0) 00126 00127 #define SO_ACTION_EXIT_CLASS(_class_) \ 00128 _class_::atexit_cleanup() 00129 00130 // ************************************************************************* 00131 00132 #endif // !COIN_SOSUBACTION_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 28 2011 10:11:58 for Coin by Doxygen. 1.7.3