Coin Logo http://www.sim.no
http://www.coin3d.org

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SoSubAction.h

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-2004 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 <URL:http://www.coin3d.org/> for more information.
00021  *
00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
00023  *  <URL:http://www.sim.no/>.
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 #define SO_ACTION_ADD_METHOD(_nodeclass_, _method_) \
00038   do { \
00039     addMethod(_nodeclass_::getClassTypeId(), (SoActionMethod)_method_); \
00040   } while (0)
00041 
00042 
00043 #define SO_ACTION_CONSTRUCTOR(_classname_) \
00044   do { \
00045     _classname_::traversalMethods = this->methods; \
00046   } while (0)
00047 
00048 
00049 #define SO_ACTION_HEADER(_classname_) \
00050 public: \
00051   virtual SoType getTypeId(void) const; \
00052   static SoType getClassTypeId(void); \
00053  \
00054   static void addMethod(const SoType type, SoActionMethod method); \
00055  \
00056   static void enableElement(const SoType type, const int stackindex); \
00057  \
00058 protected: \
00059   virtual const SoEnabledElementsList & getEnabledElements(void) const; \
00060   /* These two methods are not available in the original OIV API. */ \
00061   /* They have been added as a work-around for Win32 DLL headaches. */ \
00062   /* See further explanation below. 20000808 mortene. */ \
00063   static SoEnabledElementsList * getClassEnabledElements(void); \
00064   static SoActionMethodList * getClassActionMethods(void); \
00065  \
00066 private: \
00067   /* The enabledElements and methods variables are protected in */ \
00068   /* the original OIV API. This is not such a good idea, since */ \
00069   /* exposed static class member variables is a major grievance */ \
00070   /* with regard to Win32 DLLs. */ \
00071   static void atexit_cleanup(void); \
00072   static SoEnabledElementsList * enabledElements; \
00073   static SoActionMethodList * methods; \
00074   static SoType classTypeId
00075 
00076 
00077 #define SO_ACTION_SOURCE(_classname_) \
00078 SoEnabledElementsList * _classname_::enabledElements = NULL; \
00079 SoActionMethodList * _classname_::methods = NULL; \
00080 SoEnabledElementsList * _classname_::getClassEnabledElements(void) { return _classname_::enabledElements; } \
00081 SoActionMethodList * _classname_::getClassActionMethods(void) { return _classname_::methods; } \
00082 /* Don't set value explicitly to SoType::badType(), to avoid a bug in */ \
00083 /* Sun CC v4.0. (Bitpattern 0x0000 equals SoType::badType()). */ \
00084 SoType _classname_::classTypeId; \
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 }
00112 
00113 #define SO_ACTION_INIT_CLASS(_classname_, _parentclassname_) \
00114   do { \
00115     assert(_classname_::getClassTypeId() == SoType::badType()); \
00116     assert(_parentclassname_::getClassTypeId() != SoType::badType()); \
00117     _classname_::classTypeId = SoType::createType(_parentclassname_::getClassTypeId(), SO__QUOTE(_classname_)); \
00118     _classname_::enabledElements = new SoEnabledElementsList(_parentclassname_::getClassEnabledElements()); \
00119     _classname_::methods = new SoActionMethodList(_parentclassname_::getClassActionMethods()); \
00120   } while (0)
00121 
00122 #endif // !COIN_SOSUBACTION_H

Copyright © 1998-2003 by Systems in Motion AS. All rights reserved.

Generated on Sat Apr 10 08:33:10 2004 for Coin by Doxygen. 1.3.6-20040222