00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright 2000-2002 by OpenSG Forum * 00006 * * 00007 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00008 * * 00009 \*---------------------------------------------------------------------------*/ 00010 /*---------------------------------------------------------------------------*\ 00011 * License * 00012 * * 00013 * This library is free software; you can redistribute it and/or modify it * 00014 * under the terms of the GNU Library General Public License as published * 00015 * by the Free Software Foundation, version 2. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, but * 00018 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00020 * Library General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Library General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00025 * * 00026 \*---------------------------------------------------------------------------*/ 00027 /*---------------------------------------------------------------------------*\ 00028 * Changes * 00029 * * 00030 * * 00031 * * 00032 * * 00033 * * 00034 * * 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef _OSGCOREDNODEPTR_H_ 00038 #define _OSGCOREDNODEPTR_H_ 00039 #ifdef __sgi 00040 #pragma once 00041 #endif 00042 00043 #ifdef OSG_DOC_FILES_IN_MODULE 00044 00047 #endif 00048 00049 #include <OSGSystemDef.h> 00050 #include <OSGBaseTypes.h> 00051 #include <OSGNodePtr.h> 00052 #include <OSGNodeCore.h> 00053 00054 OSG_BEGIN_NAMESPACE 00055 00059 class /*OSG_SYSTEMLIB_DLLMAPPING*/ CoredNodePtrBase 00060 { 00061 /*========================== PUBLIC =================================*/ 00062 public: 00063 00064 /*---------------------------------------------------------------------*/ 00068 inline CoredNodePtrBase(void); 00069 00070 inline CoredNodePtrBase(NodePtr node); 00071 00073 /*---------------------------------------------------------------------*/ 00077 virtual ~CoredNodePtrBase(); 00078 00080 /*---------------------------------------------------------------------*/ 00084 inline NodePtr node(void) const; 00085 00087 /*---------------------------------------------------------------------*/ 00088 00089 /*========================= PROTECTED ===============================*/ 00090 protected: 00091 00092 /*---------------------------------------------------------------------*/ 00096 virtual NodeCorePtr getCoreV(void) const = 0; 00097 00098 inline void setNode(const NodePtr &node); 00099 00100 inline void setNode(const NullFieldContainerPtr &); 00101 00103 /*---------------------------------------------------------------------*/ 00104 00105 /*========================== PRIVATE ================================*/ 00106 private: 00107 00108 NodePtr _node; 00109 }; 00110 00114 template< class Core > 00115 class CoredNodePtr : public CoredNodePtrBase 00116 { 00117 /*========================== PUBLIC =================================*/ 00118 public: 00119 00120 /*---------------------------------------------------------------------*/ 00124 CoredNodePtr(void); 00125 00126 // make them explicit to prevent unexpected construction/cast paths 00127 00128 explicit CoredNodePtr(const NodePtr& node); 00129 00130 explicit CoredNodePtr(const NodeCorePtr& core); 00131 00132 explicit CoredNodePtr(const typename Core::Ptr& core); 00133 00134 CoredNodePtr(const CoredNodePtr<Core>& ptr); 00135 00136 static CoredNodePtr<Core> create(void); 00137 00139 /*---------------------------------------------------------------------*/ 00143 virtual ~CoredNodePtr(); 00144 00146 /*---------------------------------------------------------------------*/ 00150 void coreChanged(void); 00151 00152 typename Core::Ptr core(void) const; 00153 00154 typename Core::Ptr& operator->(void); 00155 00156 /* Note: these only work for a RHS */ 00157 operator NodePtr(); 00158 00159 operator typename Core::Ptr(); 00160 00161 /* Assignment. Create a new CNP if necessary */ 00162 00163 CoredNodePtr<Core>& operator =(const NodePtr& node); 00164 00165 CoredNodePtr<Core>& operator =(const typename Core::Ptr& core); 00166 00167 CoredNodePtr<Core>& operator =(const CoredNodePtr<Core>& cnp); 00168 00169 CoredNodePtr<Core>& operator =(const NullFieldContainerPtr &); 00170 00172 /*---------------------------------------------------------------------*/ 00173 00174 /*========================= PROTECTED ===============================*/ 00175 protected: 00176 00177 /*---------------------------------------------------------------------*/ 00181 NodeCorePtr getCoreV(void) const; 00182 00183 void setCore(const NodeCorePtr &core); 00184 00185 void setCore(const typename Core::Ptr &core); 00186 00187 void setCore(const NullFieldContainerPtr&); 00188 00189 void updateNode(void); 00190 00192 /*---------------------------------------------------------------------*/ 00193 00194 /*========================== PRIVATE ================================*/ 00195 private: 00196 00197 typename Core::Ptr _core; 00198 }; 00199 00200 // begin/endEdit functions. 00201 00202 template< class Core > inline 00203 void beginEditCP(const CoredNodePtr<Core> &objectP, 00204 BitVector whichField = FieldBits ::AllFields, 00205 UInt32 origin = ChangedOrigin::External); 00206 00207 template< class Core > inline 00208 void endEditCP (const CoredNodePtr<Core> &objectP, 00209 BitVector whichField = FieldBits ::AllFields, 00210 UInt32 origin = ChangedOrigin::External); 00211 00212 // Output operator 00213 00214 template< class Core > 00215 inline std::ostream &operator << (std::ostream &str, 00216 const CoredNodePtr<Core>& cnp); 00217 00218 OSG_END_NAMESPACE 00219 00220 #include "OSGCoredNodePtr.inl" 00221 00222 #define OSGCOREDNODEPTR_HEADER_CVSID "@(#)$Id: OSGCoredNodePtr.h,v 1.6 2005/05/31 19:53:45 dirk Exp $" 00223 00224 #endif /* _OSGCOREDNODEPTR_H_ */
1.4.3