obj.h

Go to the documentation of this file.
00001 
00004 
00005 //
00006 // Copyright (c) 1999-2004 California Institute of Technology
00007 // Copyright (c) 2004-2007 University of Southern California
00008 // Rob Peters <rjpeters at usc dot edu>
00009 //
00010 // created: Tue May 11 13:44:19 1999
00011 // commit: $Id: obj.h 10065 2007-04-12 05:54:56Z rjpeters $
00012 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/tcl/obj.h $
00013 //
00014 // --------------------------------------------------------------------
00015 //
00016 // This file is part of GroovX.
00017 //   [http://ilab.usc.edu/rjpeters/groovx/]
00018 //
00019 // GroovX is free software; you can redistribute it and/or modify it
00020 // under the terms of the GNU General Public License as published by
00021 // the Free Software Foundation; either version 2 of the License, or
00022 // (at your option) any later version.
00023 //
00024 // GroovX is distributed in the hope that it will be useful, but
00025 // WITHOUT ANY WARRANTY; without even the implied warranty of
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027 // General Public License for more details.
00028 //
00029 // You should have received a copy of the GNU General Public License
00030 // along with GroovX; if not, write to the Free Software Foundation,
00031 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00032 //
00034 
00035 #ifndef GROOVX_TCL_OBJ_H_UTC20050628162421_DEFINED
00036 #define GROOVX_TCL_OBJ_H_UTC20050628162421_DEFINED
00037 
00038 typedef struct Tcl_Obj Tcl_Obj;
00039 
00040 namespace tcl
00041 {
00042   class obj;
00043 }
00044 
00046 
00054 
00055 
00056 class tcl::obj
00057 {
00058 public:
00060   obj();
00061 
00063   obj(Tcl_Obj* obj) : m_obj(obj) { incr_ref(m_obj); }
00064 
00066   ~obj() { decr_ref(m_obj); }
00067 
00069   obj(const obj& x) :
00070     m_obj(x.m_obj)
00071     {
00072       incr_ref(m_obj);
00073     }
00074 
00076   obj& operator=(const obj& x)
00077     {
00078       assign(x.m_obj); return *this;
00079     }
00080 
00082   obj& operator=(Tcl_Obj* x)
00083     {
00084       assign(x); return *this;
00085     }
00086 
00087   Tcl_Obj* get() const { return m_obj; }
00088 
00089   void append(const tcl::obj& other);
00090 
00091   bool is_shared() const;
00092   bool is_unique() const { return !is_shared(); }
00093 
00094   void make_unique() const;
00095 
00096   const char* tcltype_name() const;
00097 
00098 private:
00099   static void incr_ref(Tcl_Obj* obj);
00100   static void decr_ref(Tcl_Obj* obj);
00101 
00102   void assign(Tcl_Obj* x) const
00103     {
00104       if (m_obj != x)
00105         {
00106           decr_ref(m_obj);
00107           m_obj = x;
00108           incr_ref(m_obj);
00109         }
00110     }
00111 
00112   mutable Tcl_Obj* m_obj;
00113 };
00114 
00115 static const char __attribute__((used)) vcid_groovx_tcl_obj_h_utc20050628162421[] = "$Id: obj.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00116 #endif // !GROOVX_TCL_OBJ_H_UTC20050628162421_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:41 2008 by Doxygen version 1.5.5.