Sha256: f36a5feebfafd1476b02d97b3e93b8b9606ac0374d3e3c7ca3065fafcdaad0fa

Contents?: true

Size: 838 Bytes

Versions: 5

Compression:

Stored size: 838 Bytes

Contents

#ifndef GOSU_MACUTILITY_HPP
#define GOSU_MACUTILITY_HPP

#ifdef __OBJC__
#import <objc/objc.h>
#import <stdexcept>
#import <boost/utility.hpp>
namespace Gosu
{
    template<typename T>
    class ObjRef : boost::noncopyable
    {
        T* ptr;
    public:
        ObjRef(T* ptr = nil)
        : ptr(ptr) 
        {
        }
        
        ~ObjRef() 
        {
            if (ptr)
                [ptr release];
        }
        
        void reset(T* newPtr = nil)
        { 
            if (ptr)
                [ptr release]; 
            ptr = newPtr;
        }
        
        T* get() const 
        {
            return ptr; 
        }
        
        T* obj() const
        {
            if (!ptr)
                throw std::logic_error("Tried dereferencing nil");
            return ptr;
        }
    };
}
#endif

#endif

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gosu-0.7.10.1 GosuImpl/MacUtility.hpp
gosu-0.7.10.2 GosuImpl/MacUtility.hpp
gosu-0.7.10.3 GosuImpl/MacUtility.hpp
gosu-0.7.11 GosuImpl/MacUtility.hpp
gosu-0.7.12 GosuImpl/MacUtility.hpp