pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2725 - branches/pingus_sdl/src


From: jsalmon3
Subject: [Pingus-CVS] r2725 - branches/pingus_sdl/src
Date: Sat, 14 Jul 2007 04:04:07 +0200

Author: jsalmon3
Date: 2007-07-14 04:03:55 +0200 (Sat, 14 Jul 2007)
New Revision: 2725

Removed:
   branches/pingus_sdl/src/shared_ptr.hpp
Modified:
   branches/pingus_sdl/src/file_reader.cpp
   branches/pingus_sdl/src/file_reader.hpp
   branches/pingus_sdl/src/font.cpp
   branches/pingus_sdl/src/font.hpp
   branches/pingus_sdl/src/graphic_context_state.hpp
   branches/pingus_sdl/src/pingus_level.hpp
   branches/pingus_sdl/src/pixel_buffer.cpp
   branches/pingus_sdl/src/pixel_buffer.hpp
   branches/pingus_sdl/src/sexpr_file_reader.cpp
   branches/pingus_sdl/src/sprite.cpp
   branches/pingus_sdl/src/sprite.hpp
Log:
Switched to boost::shared_ptr

Modified: branches/pingus_sdl/src/file_reader.cpp
===================================================================
--- branches/pingus_sdl/src/file_reader.cpp     2007-07-14 01:27:01 UTC (rev 
2724)
+++ branches/pingus_sdl/src/file_reader.cpp     2007-07-14 02:03:55 UTC (rev 
2725)
@@ -23,13 +23,12 @@
 #include "file_reader.hpp"
 #include "file_reader_impl.hpp"
 
-FileReader::FileReader(SharedPtr<FileReaderImpl> impl_)
+FileReader::FileReader(boost::shared_ptr<FileReaderImpl> impl_)
   : impl(impl_)
 {
 }
 
 FileReader::FileReader()
-  : impl(0)
 {
 }
 

Modified: branches/pingus_sdl/src/file_reader.hpp
===================================================================
--- branches/pingus_sdl/src/file_reader.hpp     2007-07-14 01:27:01 UTC (rev 
2724)
+++ branches/pingus_sdl/src/file_reader.hpp     2007-07-14 02:03:55 UTC (rev 
2725)
@@ -22,7 +22,7 @@
 
 #include <string>
 #include <vector>
-#include "shared_ptr.hpp"
+#include <boost/shared_ptr.hpp>
 
 class Size;
 class Color;
@@ -37,7 +37,7 @@
 class FileReader
 {
 public:
-  FileReader(SharedPtr<FileReaderImpl> impl_);
+  FileReader(boost::shared_ptr<FileReaderImpl> impl_);
   FileReader();
 
   /** Name of the current section, ie. in the case of
@@ -75,7 +75,7 @@
 
   static FileReader parse(const std::string& filename);
 private:
-  SharedPtr<FileReaderImpl> impl;
+  boost::shared_ptr<FileReaderImpl> impl;
 };
 
 #endif

Modified: branches/pingus_sdl/src/font.cpp
===================================================================
--- branches/pingus_sdl/src/font.cpp    2007-07-14 01:27:01 UTC (rev 2724)
+++ branches/pingus_sdl/src/font.cpp    2007-07-14 02:03:55 UTC (rev 2725)
@@ -206,7 +206,6 @@
 };
 
 Font::Font()
-  : impl(0)
 {
 }
 

Modified: branches/pingus_sdl/src/font.hpp
===================================================================
--- branches/pingus_sdl/src/font.hpp    2007-07-14 01:27:01 UTC (rev 2724)
+++ branches/pingus_sdl/src/font.hpp    2007-07-14 02:03:55 UTC (rev 2725)
@@ -27,11 +27,11 @@
 #define HEADER_FONT_HPP
 
 #include <string>
+#include <boost/shared_ptr.hpp>
 #include "SDL.h"
 #include "math/origin.hpp"
 #include "math/rect.hpp"
 #include "math/size.hpp"
-#include "shared_ptr.hpp"
 
 class FontImpl;
 class FontDescription;
@@ -53,7 +53,7 @@
   Rect bounding_rect(int , int, const std::string& str) const;
 
 private:
-  SharedPtr<FontImpl> impl;
+  boost::shared_ptr<FontImpl> impl;
 };
 
 #endif

Modified: branches/pingus_sdl/src/graphic_context_state.hpp
===================================================================
--- branches/pingus_sdl/src/graphic_context_state.hpp   2007-07-14 01:27:01 UTC 
(rev 2724)
+++ branches/pingus_sdl/src/graphic_context_state.hpp   2007-07-14 02:03:55 UTC 
(rev 2725)
@@ -20,11 +20,11 @@
 #ifndef HEADER_GRAPHIC_CONTEXT_STATE_HXX
 #define HEADER_GRAPHIC_CONTEXT_STATE_HXX
 
+#include <boost/shared_ptr.hpp>
 #include "math/rect.hpp"
 #include "math/vector3f.hpp"
 #include "math/vector2i.hpp"
 #include "math/vector2f.hpp"
-#include "shared_ptr.hpp"
 #include "display/drawing_context.hpp"
 #include "display/scene_context.hpp"
 
@@ -87,7 +87,7 @@
   Vector2f screen2world(const Vector2i& pos);
 
 private:
-  SharedPtr<GraphicContextStateImpl> impl;
+  boost::shared_ptr<GraphicContextStateImpl> impl;
 };
 
 #endif

Modified: branches/pingus_sdl/src/pingus_level.hpp
===================================================================
--- branches/pingus_sdl/src/pingus_level.hpp    2007-07-14 01:27:01 UTC (rev 
2724)
+++ branches/pingus_sdl/src/pingus_level.hpp    2007-07-14 02:03:55 UTC (rev 
2725)
@@ -23,7 +23,7 @@
 #include <string>
 #include <vector>
 #include <map>
-#include "shared_ptr.hpp"
+#include <boost/shared_ptr.hpp>
 #include "file_reader.hpp"
 
 
@@ -83,7 +83,7 @@
   const std::string get_resname() const;
 
 protected:
-  SharedPtr<PingusLevelImpl> impl;
+  boost::shared_ptr<PingusLevelImpl> impl;
 };
 
 

Modified: branches/pingus_sdl/src/pixel_buffer.cpp
===================================================================
--- branches/pingus_sdl/src/pixel_buffer.cpp    2007-07-14 01:27:01 UTC (rev 
2724)
+++ branches/pingus_sdl/src/pixel_buffer.cpp    2007-07-14 02:03:55 UTC (rev 
2725)
@@ -29,7 +29,6 @@
 #include "pixel_buffer.hpp"
 
 PixelBuffer::PixelBuffer()
-  : impl(0)
 {
 }
 

Modified: branches/pingus_sdl/src/pixel_buffer.hpp
===================================================================
--- branches/pingus_sdl/src/pixel_buffer.hpp    2007-07-14 01:27:01 UTC (rev 
2724)
+++ branches/pingus_sdl/src/pixel_buffer.hpp    2007-07-14 02:03:55 UTC (rev 
2725)
@@ -28,8 +28,8 @@
 
 #include "SDL.h"
 #include <string>
+#include <boost/shared_ptr.hpp>
 #include "math/color.hpp"
-#include "shared_ptr.hpp"
 
 class PixelBufferImpl
 {
@@ -44,9 +44,6 @@
 /** */
 class PixelBuffer
 {
-private:
-  SharedPtr<PixelBufferImpl> impl;
-
 public:
   PixelBuffer();
   PixelBuffer(const std::string& name);
@@ -67,6 +64,9 @@
   SDL_Surface* get_surface() const;
 
   operator bool() const;
+
+protected:
+  boost::shared_ptr<PixelBufferImpl> impl;
 };
 
 #endif

Modified: branches/pingus_sdl/src/sexpr_file_reader.cpp
===================================================================
--- branches/pingus_sdl/src/sexpr_file_reader.cpp       2007-07-14 01:27:01 UTC 
(rev 2724)
+++ branches/pingus_sdl/src/sexpr_file_reader.cpp       2007-07-14 02:03:55 UTC 
(rev 2725)
@@ -252,7 +252,7 @@
 };
 
 SExprFileReader::SExprFileReader(lisp::Lisp* lisp)
-  : FileReader(SharedPtr<FileReaderImpl>(new SExprFileReaderImpl(lisp)))
+  : FileReader(boost::shared_ptr<FileReaderImpl>(new 
SExprFileReaderImpl(lisp)))
 {
 }
 

Deleted: branches/pingus_sdl/src/shared_ptr.hpp
===================================================================
--- branches/pingus_sdl/src/shared_ptr.hpp      2007-07-14 01:27:01 UTC (rev 
2724)
+++ branches/pingus_sdl/src/shared_ptr.hpp      2007-07-14 02:03:55 UTC (rev 
2725)
@@ -1,168 +0,0 @@
-//  $Id$
-// 
-//  Flexlay - A Generic 2D Game Editor
-//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-// 
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#ifndef HEADER_SHARED_PTR_HXX
-#define HEADER_SHARED_PTR_HXX
-
-#include <assert.h>
-
-// This code is a modified version of CL_SharedPtr from ClanLib
-
-class UnknownSharedPtrImpl
-{
-public:
-  UnknownSharedPtrImpl() : count(1) {}
-  virtual ~UnknownSharedPtrImpl() {}
-
-  unsigned count;
-};
-
-template<typename U>
-class SharedPtrImpl : public UnknownSharedPtrImpl
-{
-public:
-  SharedPtrImpl() : ptr(0) {}
-
-  U* ptr;
-};
-
-template<typename T, typename U>
-class SharedPtrDelete : public SharedPtrImpl<T>
-{
-public:
-  SharedPtrDelete(U* ptr) { this->ptr = ptr; }
-  ~SharedPtrDelete() { delete this->ptr; }
-};
-
-class UnknownSharedPtr;
-
-/** */
-template<typename T, typename U = T>
-class SharedPtr
-{
-public:
-  SharedPtr() : impl(0) {}
-  SharedPtr(const SharedPtr<T, U>& ptr) : impl(ptr.impl) { increment(); }
-  SharedPtr(const UnknownSharedPtr& ptr) : impl(0) {
-    if (ptr.impl) {
-      impl = dynamic_cast<SharedPtrImpl<T>*>(ptr.impl);
-      increment();
-    }
-  }
-  
-  template<typename D>
-  explicit SharedPtr(D* ptr) : impl(0) {
-    if (ptr)
-      impl = new SharedPtrDelete<T, D>(ptr);
-  }
-  explicit SharedPtr(SharedPtrImpl<T>* impl) : impl(impl) { increment(); }
-  
-  ~SharedPtr() { decrement(); }
-
-  bool operator==(const T* ptr) const { return ptr == (impl ? impl.ptr : 0); }
-  bool operator==(const SharedPtr<T, U>& ptr) const { return ptr.impl == impl; 
}
-
-  SharedPtr<T>& operator=(const SharedPtr<T>& ptr) {
-    if (ptr.impl != impl) {
-      decrement();
-      impl = ptr.impl;
-      increment();
-    }
-    return *this;
-  }
-  SharedPtr<T>& operator=(const UnknownSharedPtr& ptr) {
-    if (ptr.impl != impl) {
-      decrement();
-      if (ptr.impl) {
-       impl = dynamic_cast<SharedPtrImpl<T>*>(ptr.impl);
-       increment();
-      }
-    }
-    return *this;
-  }
-
-  U& operator*() { assert(impl); return *((U*)impl->ptr); }
-  U const& operator*() const { assert(impl); return *((const U*)impl->ptr); }
-
-  U* operator->() { assert(impl); return (U*)(impl->ptr); }
-  U const* operator->() const { assert(impl); return (const U*)(impl->ptr); }
-
-  const U* get() const { return (U*)(impl ? impl->ptr : 0); }
-
-  operator bool() const { return impl ? impl->ptr : 0; }
-
-private:
-  SharedPtrImpl<T>* impl;
-
-  void increment() {
-    if (impl)
-      impl->count++;
-  }
-  void decrement() {
-    if (impl && --impl->count == 0) {
-      delete impl;
-      impl = 0;
-    }
-  }
-
-  friend class UnknownSharedPtr;
-};
-
-class UnknownSharedPtr
-{
-public:
-  UnknownSharedPtr() : impl(0) {}
-  template<typename T>
-  explicit UnknownSharedPtr(const SharedPtr<T>& ptr) : impl(ptr.impl) {
-    increment();
-  }
-  ~UnknownSharedPtr() { decrement(); }
-
-  bool operator==(const UnknownSharedPtr& ptr) const { return ptr.impl == 
impl; }
-  template <typename T, typename U>
-  bool operator==(const SharedPtr<T, U>& ptr) const { return ptr.impl == impl; 
}
-
-  template<typename T, typename U>
-  UnknownSharedPtr& operator=(const SharedPtr<T, U>& ptr) {
-    if (ptr.impl != impl) {
-      decrement();
-      impl = ptr.impl;
-      increment();
-    }
-    return *this;
-  }
-
-private:
-  UnknownSharedPtrImpl* impl;
-
-  void increment() {
-    if (impl)
-      impl->count++;
-  }
-  void decrement() {
-    if (impl && --impl->count == 0) {
-      delete impl;
-      impl = 0;
-    }
-  }
-};
-
-#endif
-
-/* EOF */

Modified: branches/pingus_sdl/src/sprite.cpp
===================================================================
--- branches/pingus_sdl/src/sprite.cpp  2007-07-14 01:27:01 UTC (rev 2724)
+++ branches/pingus_sdl/src/sprite.cpp  2007-07-14 02:03:55 UTC (rev 2725)
@@ -134,7 +134,6 @@
 };
 
 Sprite::Sprite()
-  : impl(0)
 {
 }
 

Modified: branches/pingus_sdl/src/sprite.hpp
===================================================================
--- branches/pingus_sdl/src/sprite.hpp  2007-07-14 01:27:01 UTC (rev 2724)
+++ branches/pingus_sdl/src/sprite.hpp  2007-07-14 02:03:55 UTC (rev 2725)
@@ -27,8 +27,8 @@
 #define HEADER_SPRITE_HPP
 
 #include <string>
+#include <boost/shared_ptr.hpp>
 #include "SDL.h"
-#include "shared_ptr.hpp"
 
 class PixelBuffer;
 class SpriteImpl;
@@ -57,7 +57,7 @@
   operator bool();
 
 private:
-  SharedPtr<SpriteImpl> impl;
+  boost::shared_ptr<SpriteImpl> impl;
 };
 
 #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]