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-2003 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 #endif // COIN_INTERNAL
00034 
00035 
00036 #define SO_ACTION_ADD_METHOD(_nodeclass_, _method_) \
00037   do { \
00038     addMethod(_nodeclass_::getClassTypeId(), (SoActionMethod)_method_); \
00039   } while (0)
00040 
00041 
00042 #define SO_ACTION_CONSTRUCTOR(_classname_) \
00043   do { \
00044     _classname_::traversalMethods = this->methods; \
00045   } while (0)
00046 
00047 
00048 #define SO_ACTION_HEADER(_classname_) \
00049 public: \
00050   virtual SoType getTypeId(void) const; \
00051   static SoType getClassTypeId(void); \
00052   static void addMethod(const SoType type, SoActionMethod method); \
00053   static void enableElement(const SoType type, const int stackindex); \
00054  \
00055 protected: \
00056   virtual const SoEnabledElementsList & getEnabledElements(void) const; \
00057   /* These two methods are not available in the original OIV API. */ \
00058   /* They have been added as a work-around for Win32 DLL headaches. */ \
00059   /* See further explanation below. 20000808 mortene. */ \
00060   static SoEnabledElementsList * getClassEnabledElements(void); \
00061   static SoActionMethodList * getClassActionMethods(void); \
00062  \
00063 private: \
00064   /* The enabledElements and methods variables are protected in */ \
00065   /* the original OIV API. This is not such a good idea, since */ \
00066   /* exposed static class member variables is a major grievance */ \
00067   /* with regard to Win32 DLLs. */ \
00068   static SoEnabledElementsList * enabledElements; \
00069   static SoActionMethodList * methods; \
00070   static SoType classTypeId
00071 
00072 
00073 #define SO_ACTION_SOURCE(_classname_) \
00074 SoEnabledElementsList * _classname_::enabledElements = NULL; \
00075 SoActionMethodList * _classname_::methods = NULL; \
00076 SoEnabledElementsList * _classname_::getClassEnabledElements(void) { return _classname_::enabledElements; } \
00077 SoActionMethodList * _classname_::getClassActionMethods(void) { return _classname_::methods; } \
00078 /* Don't set value explicitly to SoType::badType(), to avoid a bug in */ \
00079 /* Sun CC v4.0. (Bitpattern 0x0000 equals SoType::badType()). */ \
00080 SoType _classname_::classTypeId; \
00081 SoType _classname_::getClassTypeId(void) { return _classname_::classTypeId; } \
00082 SoType _classname_::getTypeId(void) const { return _classname_::classTypeId; } \
00083 const SoEnabledElementsList & _classname_::getEnabledElements(void) const \
00084 { \
00085   assert(_classname_::enabledElements); \
00086   return *_classname_::enabledElements; \
00087 } \
00088 void \
00089 _classname_::addMethod(const SoType type, SoActionMethod method) \
00090 { \
00091   assert(_classname_::methods); \
00092   _classname_::methods->addMethod(type, method); \
00093 } \
00094 void \
00095 _classname_::enableElement(const SoType type, const int stackindex) \
00096 { \
00097   assert(_classname_::enabledElements); \
00098   _classname_::enabledElements->enable(type, stackindex); \
00099 }
00100 
00101 
00102 #define SO_ACTION_INIT_CLASS(_classname_, _parentclassname_) \
00103   do { \
00104     assert(_classname_::getClassTypeId() == SoType::badType()); \
00105     assert(_parentclassname_::getClassTypeId() != SoType::badType()); \
00106     _classname_::classTypeId = SoType::createType(_parentclassname_::getClassTypeId(), SO__QUOTE(_classname_)); \
00107     _classname_::enabledElements = new SoEnabledElementsList(_parentclassname_::getClassEnabledElements()); \
00108     _classname_::methods = new SoActionMethodList(_parentclassname_::getClassActionMethods()); \
00109   } while (0)
00110 
00111 #endif // !COIN_SOSUBACTION_H

Generated on Sat Oct 23 08:34:37 2004 for Coin by doxygen 1.3.6