From dcf0cdf35b7d26d55182882f77039c43ad6a195c Mon Sep 17 00:00:00 2001 From: Raoul Gough Date: Wed, 10 Sep 2003 11:24:47 +0000 Subject: [PATCH] Split IntWrapper into separate module [SVN r1520] --- .../boost/python/suite/indexing/indexing.cpp | 112 +----------------- 1 file changed, 2 insertions(+), 110 deletions(-) diff --git a/include/boost/python/suite/indexing/indexing.cpp b/include/boost/python/suite/indexing/indexing.cpp index aba20e38..b7582e20 100755 --- a/include/boost/python/suite/indexing/indexing.cpp +++ b/include/boost/python/suite/indexing/indexing.cpp @@ -22,6 +22,7 @@ // #include "container_proxy.hpp" +#include "IntWrapper.hpp" #include #include @@ -34,110 +35,6 @@ #include #include -namespace { - bool gIntWrapperTrace = true; -} - -struct IntWrapper { - static unsigned ourObjectCounter; - int mObjNumber; - int mI; - - IntWrapper () - : mObjNumber (ourObjectCounter++) - , mI (0) - { - if (gIntWrapperTrace) - { - printf ("IntWrapper %u ()\n", mObjNumber); - } - } - - explicit IntWrapper (int i) - : mObjNumber (ourObjectCounter++) - , mI (i) - { - if (gIntWrapperTrace) - { - printf ("IntWrapper %u (%d)\n" - , mObjNumber - , mI); - } - } - - IntWrapper (IntWrapper const &other) - : mObjNumber (ourObjectCounter++) - , mI (other.mI) - { - if (gIntWrapperTrace) - { - printf ("IntWrapper %u (IntWrapper %u)\n" - , mObjNumber - , other.mObjNumber); - } - } - - IntWrapper &operator= (IntWrapper const &other) - { - if (gIntWrapperTrace) - { - printf ("IntWrapper %u = IntWrapper %u\n" - , mObjNumber - , other.mObjNumber); - } - - mI = other.mI; - - return *this; - } - - ~IntWrapper () - { - if (gIntWrapperTrace) - { - printf ("~IntWrapper %u\n", mObjNumber); - } - } - - void increment() - { - if (gIntWrapperTrace) - { - printf ("IntWrapper %u::increment\n", mObjNumber); - } - - ++mI; - } - - operator boost::shared_ptr () const - { - if (gIntWrapperTrace) - { - printf ("IntWrapper %u shared_ptr conversion\n", mObjNumber); - } - - return boost::shared_ptr (new IntWrapper (*this)); - } -}; - -unsigned IntWrapper::ourObjectCounter = 0; - -bool operator== (IntWrapper const &lhs, IntWrapper const &rhs) -{ - return lhs.mI == rhs.mI; -} - -bool operator< (IntWrapper const &lhs, IntWrapper const &rhs) -{ - return lhs.mI < rhs.mI; -} - -std::ostream &operator<< (std::ostream &strm, IntWrapper const &iw) -{ - strm << iw.mI; - return strm; -} - template std::string proxy_repr (typename ContainerProxy::value_type const &proxy) { @@ -160,11 +57,6 @@ void pointer_increment (boost::shared_ptr const &ptr) (*ptr).increment(); } -void setTrace (int onoff) -{ - gIntWrapperTrace = onoff; -} - IntWrapper *get_pointer (container_proxy >::value_type const &proxy) { return &(*proxy); @@ -172,7 +64,7 @@ IntWrapper *get_pointer (container_proxy >::value_type c BOOST_PYTHON_MODULE (indexing) { - boost::python::def ("trace", &setTrace); + boost::python::def ("trace", &IntWrapper::setTrace); typedef std::vector Container; typedef container_proxy ProxyContainer;