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

sglObject.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   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 Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglObject.hpp
00021  *  Created: 30 December 1997
00022  *****************************************************************************/
00023 
00024 #ifndef __SGL_OBJECT_HPP
00025 #define __SGL_OBJECT_HPP
00026 
00027 #include <sgl.h>
00028 #include <sglUserData.hpp>
00029 #include <string>
00030 
00031 //----------------------------------------------------------------------------
00032 
00110 //----------------------------------------------------------------------------
00111 
00112 class SGL_DLL_API sglObject /* : public sglMemory */
00113 {
00114 public:
00117    enum CloneModeEnum
00118    {
00120       eCLONE_ONE_NODE        = 0,
00121 
00123       eCLONE_NODES_RECURSIVE = 0x01,
00124 
00126       eCLONE_USER_DATA       = 0x02
00127 
00128 //    eCLONE_CAMERAS = 0x04,
00129 //    eCLONE_GEOMETRY = 0x08,        // clone drawables, too (not vertex data)
00130 //    eCLONE_GEOMETRY_DATA = 0x10,   // clones drawables per vertex data too.
00131 //    eCLONE_STATE = 0x20,           // clone the sglStatelets
00132 //    eCLONE_TEXTURE_IMAGE = 0x40    // copy the texture image data
00133    };
00134 
00135 public:
00137    sglObject();
00139    virtual ~sglObject() = 0;
00140 
00142    void ref()   { m_ref_count++; }
00143 
00147    void deref() { assert(m_ref_count != 0); --m_ref_count; }
00148 
00152    unsigned int getRefCount() const { return m_ref_count; }
00153 
00157    void setName(const string &name) { m_name = name; }
00158 
00162    const string &getName() const { return m_name; }
00163 
00169    void setUserData(sglUserData *data) { m_user_data = data; }
00170 
00174    sglUserData* getUserData() const    { return m_user_data; }
00175 
00181    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00182 
00183 protected:
00184    // used by the clone traversal
00185    void copyTo(sglObject *dst, unsigned int mode) const;
00186 
00187 private: // not implemented
00188    sglObject(const sglObject &);
00189    sglObject &operator=(const sglObject &);
00190 
00191 protected:
00192    unsigned int m_ref_count;
00193    sglUserData *m_user_data;
00194    string m_name;
00195 };
00196 
00197 //----------------------------------------------------------------------------
00198 
00199 inline ostream& operator<<(ostream& ostrm, const sglObject& object)
00200 {
00201    object.printInfo(ostrm, " ");
00202    return ostrm;
00203 }
00204 
00205 #endif

Generated at Mon Jul 1 18:00:05 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001