Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoSubAction.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 by Systems in Motion. All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public License
00008  *  version 2.1 as published by the Free Software Foundation. See the
00009  *  file LICENSE.LGPL at the root directory of the distribution for
00010  *  more details.
00011  *
00012  *  If you want to use Coin for applications not compatible with the
00013  *  LGPL, please contact SIM to acquire a Professional Edition license.
00014  *
00015  *  Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY
00016  *  http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097
00017  *
00018 \**************************************************************************/
00019 
00020 #ifndef COIN_SOSUBACTION_H
00021 #define COIN_SOSUBACTION_H
00022 
00023 #ifndef COIN_INTERNAL
00024 // Added to be Inventor compliant.
00025 #include <Inventor/SbString.h>
00026 #include <Inventor/actions/SoAction.h>
00027 #else // !COIN_INTERNAL
00028 #include <Inventor/SbName.h>
00029 #endif // COIN_INTERNAL
00030 
00031 
00032 #define SO_ACTION_ADD_METHOD(_nodeclass_, _method_) \
00033   do { \
00034     addMethod(_nodeclass_::getClassTypeId(), (SoActionMethod)_method_); \
00035   } while (0)
00036 
00037 
00038 #define SO_ACTION_CONSTRUCTOR(_classname_) \
00039   do { \
00040     _classname_::traversalMethods = this->methods; \
00041   } while (0)
00042 
00043 
00044 #define SO_ACTION_HEADER(_classname_) \
00045 public: \
00046   virtual SoType getTypeId(void) const; \
00047   static SoType getClassTypeId(void); \
00048   static void addMethod(const SoType type, SoActionMethod method); \
00049   static void enableElement(const SoType type, const int stackindex); \
00050  \
00051 protected: \
00052   virtual const SoEnabledElementsList & getEnabledElements(void) const; \
00053   /* These two methods are not available in the original OIV API. */ \
00054   /* They have been added as a work-around for Win32 DLL headaches. */ \
00055   /* See further explanation below. 20000808 mortene. */ \
00056   static SoEnabledElementsList * getClassEnabledElements(void); \
00057   static SoActionMethodList * getClassActionMethods(void); \
00058  \
00059 private: \
00060   /* The enabledElements and methods variables are protected in */ \
00061   /* the original OIV API. This is not such a good idea, since */ \
00062   /* exposed static class member variables is a major grievance */ \
00063   /* with regard to Win32 DLLs. */ \
00064   static SoEnabledElementsList * enabledElements; \
00065   static SoActionMethodList * methods; \
00066   static SoType classTypeId
00067 
00068 
00069 #define SO_ACTION_SOURCE(_classname_) \
00070 SoEnabledElementsList * _classname_::enabledElements = NULL; \
00071 SoActionMethodList * _classname_::methods = NULL; \
00072 SoEnabledElementsList * _classname_::getClassEnabledElements(void) { return _classname_::enabledElements; } \
00073 SoActionMethodList * _classname_::getClassActionMethods(void) { return _classname_::methods; } \
00074 /* Don't set value explicitly to SoType::badType(), to avoid a bug in */ \
00075 /* Sun CC v4.0. (Bitpattern 0x0000 equals SoType::badType()). */ \
00076 SoType _classname_::classTypeId; \
00077 SoType _classname_::getClassTypeId(void) { return _classname_::classTypeId; } \
00078 SoType _classname_::getTypeId(void) const { return _classname_::classTypeId; } \
00079 const SoEnabledElementsList & _classname_::getEnabledElements(void) const \
00080 { \
00081   assert(_classname_::enabledElements); \
00082   return *_classname_::enabledElements; \
00083 } \
00084 void \
00085 _classname_::addMethod(const SoType type, SoActionMethod method) \
00086 { \
00087   assert(_classname_::methods); \
00088   _classname_::methods->addMethod(type, method); \
00089 } \
00090 void \
00091 _classname_::enableElement(const SoType type, const int stackindex) \
00092 { \
00093   assert(_classname_::enabledElements); \
00094   _classname_::enabledElements->enable(type, stackindex); \
00095 }
00096 
00097 
00098 #define SO_ACTION_INIT_CLASS(_classname_, _parentclassname_) \
00099   do { \
00100     assert(_classname_::getClassTypeId() == SoType::badType()); \
00101     assert(_parentclassname_::getClassTypeId() != SoType::badType()); \
00102     _classname_::classTypeId = SoType::createType(_parentclassname_::getClassTypeId(), SO__QUOTE(_classname_)); \
00103     _classname_::enabledElements = new SoEnabledElementsList(_parentclassname_::getClassEnabledElements()); \
00104     _classname_::methods = new SoActionMethodList(_parentclassname_::getClassActionMethods()); \
00105   } while (0)
00106 
00107 
00108 #endif // !COIN_SOSUBACTION_H

Generated at Tue Mar 5 03:31:17 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001