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

SoState.h

00001 #ifndef COIN_SOSTATE_H
00002 #define COIN_SOSTATE_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 #include <Inventor/SbBasic.h>
00028 #include <stdio.h>
00029 #include <assert.h>
00030 
00031 class SoAction;
00032 class SoTypeList;
00033 class SoElement;
00034 
00035 class COIN_DLL_API SoState {
00036 public:
00037   SoState(SoAction * action,
00038           const SoTypeList & enabledelements);
00039   ~SoState(void);
00040 
00041   SoAction * getAction(void) const;
00042 
00043   SoElement * getElement(const int stackindex);
00044   const SoElement * getConstElement(const int stackindex) const;
00045 
00046   void push(void);
00047   void pop(void);
00048 
00049   void print(FILE * const file = stdout) const;
00050 
00051   SbBool isElementEnabled(const int stackindex) const;
00052 
00053   int getDepth(void) const;
00054 
00055   void setCacheOpen(const SbBool flag);
00056   SbBool isCacheOpen(void) const;
00057 
00058   SoElement * getElementNoPush(const int stackindex) const;
00059 
00060 private:
00061   SoElement ** stack;
00062   int numstacks;
00063   SbBool cacheopen;
00064   class SoStateP * pimpl;  
00065 };
00066 
00067 // these methods are used very often, and is therefore inlined
00068 
00069 inline SbBool
00070 SoState::isElementEnabled(const int stackindex) const
00071 {
00072   return (stackindex < this->numstacks) && (this->stack[stackindex] != NULL);
00073 }
00074 
00075 inline const SoElement *
00076 SoState::getConstElement(const int stackindex) const
00077 {
00078   assert(this->isElementEnabled(stackindex));
00079   return this->stack[stackindex];
00080 }
00081 
00082 inline SbBool 
00083 SoState::isCacheOpen(void) const
00084 {
00085   return this->cacheopen;
00086 }
00087 
00088 inline SoElement *
00089 SoState::getElementNoPush(const int stackindex) const
00090 {
00091   assert(this->isElementEnabled(stackindex));
00092   return this->stack[stackindex];
00093 }
00094 
00095 
00096 #endif // !COIN_SOSTATE_H

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

Generated on Mon Feb 23 16:33:32 2009 for Coin by Doxygen. 1.5.8