Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

StateSet.h

Go to the documentation of this file.
00001 // Copyright NVIDIA Corporation 2002-2004
00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
00005 // AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 
00011 
00012 #pragma once
00013 
00015 #include "nvsgcommon.h"
00016 
00017 #include "nvsg/Object.h"
00018 #include <vector>
00019 
00020 namespace nvsg
00021 {
00022   class GeoNode;
00023   class StateAttribute;
00024 
00026 
00029   class StateSet : public Object
00030   {
00031     public:
00033 
00034       NVSG_API static const StateSet * create( void );
00035 
00037 
00038       NVSG_API static const StateSet * createFromBase( const Object &rhs );
00039 
00041 
00042       NVSG_API virtual const StateSet * clone( void ) const;
00043 
00045 
00046       NVSG_API virtual bool isDataShared( void ) const;
00047 
00049 
00050       NVSG_API virtual DataID getDataID( void ) const;
00051 
00053 
00059       NVSG_API void addAttribute( const StateAttribute *attrib    
00060                                 );
00061 
00063 
00064       NVSG_API size_t getNumberOfAttributes( void ) const;
00065 
00067 
00069       NVSG_API const StateAttribute * getAttribute( size_t index    
00070                                                   ) const;
00071 
00073 
00075       NVSG_API const StateAttribute * getAttributeByObjectCode( unsigned int oc   
00076                                                               ) const;
00077 
00079 
00080       NVSG_API bool removeAttribute( const StateAttribute * attrib    
00081                                    );
00082 
00084 
00085       NVSG_API bool removeAttribute( size_t index   
00086                                    );
00087 
00089 
00091       NVSG_API bool removeAttributeByObjectCode( unsigned int oc    
00092                                                );
00093       
00095 
00096       NVSG_API size_t getNumberOfOwners( void ) const;
00097 
00099 
00100       NVSG_API const GeoNode * getOwner( size_t index    
00101                                        ) const;
00102 
00104 
00105       NVSG_API virtual bool containsCgFx( void ) const;
00106 
00108 
00109       NVSG_API virtual void invalidateCgFxContainment( void );
00110 
00112 
00113       NVSG_API virtual bool containsTransparentMaterial( void ) const;
00114 
00116 
00117       NVSG_API virtual void invalidateTransparentMaterialContainment( void );
00118 
00120 
00121       NVSG_API virtual bool containsTransparentTexture( void ) const;
00122 
00124 
00125       NVSG_API virtual void invalidateTransparentTextureContainment( void );
00126     protected:
00128       NVSG_API StateSet( void );
00129 
00131       NVSG_API StateSet( const Object &rhs );
00132 
00134       NVSG_API StateSet( const StateSet& rhs );
00135 
00137       NVSG_API virtual ~StateSet( void );
00138 
00140 
00141       NVSG_API void invalidateCaches( const StateAttribute *attrib, bool insert );
00142 
00143     private:
00144       // A Node can be owned by more than one GeoNode. The owner connection is 
00145       // used for example to invalidate the owner's containment cache.
00146       friend class GeoNode;
00147       void addOwner( const GeoNode * geoNode );
00148       void removeOwner( const GeoNode * geoNode );
00149 
00150     private:
00151       std::vector<const StateAttribute*>  m_stateAttribs;
00152       std::vector<const GeoNode*>         m_owners;       // owners of this state set are collected here
00153 
00154       //  State caches
00155       mutable bool  m_containsCgFx;
00156       mutable bool  m_containsCgFxValid;
00157       mutable bool  m_containsTransparentMaterial;
00158       mutable bool  m_containsTransparentMaterialValid;
00159       mutable bool  m_containsTransparentTexture;
00160       mutable bool  m_containsTransparentTextureValid;
00161 
00162   };
00163 
00164   inline const StateAttribute * StateSet::getAttribute( size_t index ) const
00165   {
00166     __TRACE();
00167     __ASSERT(index<m_stateAttribs.size()); // undefined behavior for invalid index
00168     return m_stateAttribs[index];
00169   }
00170 
00171   inline size_t StateSet::getNumberOfAttributes( void ) const
00172   {
00173     __TRACE();
00174     return( m_stateAttribs.size() );
00175   }
00176 
00177   inline size_t StateSet::getNumberOfOwners( void ) const
00178   {
00179     __TRACE();
00180     return( m_owners.size() );
00181   }
00182 
00183   inline const GeoNode * StateSet::getOwner( size_t index ) const
00184   {
00185     __TRACE();
00186     __ASSERT( index < m_owners.size() );
00187     return m_owners[index];
00188   }
00189 
00190 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
00191 
00197   NVSG_API bool operator==( const StateSet &lhs   
00198                           , const StateSet &rhs   
00199                           );
00200 
00201 } //  namespace nvsg

Generated on Tue Mar 1 13:19:19 2005 for NVSGSDK by NVIDIA