added refptr<T>::operator=(const T * ptr) method, including refptr in parser
git-svn-id: svn://anubis/fart/trunk@93 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
e2424337d6
commit
c6e1a2c7e4
@ -3,7 +3,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "main/Scene.h"
|
#include "main/Scene.h"
|
||||||
|
#include "main/Material.h"
|
||||||
#include "util/Vector.h"
|
#include "util/Vector.h"
|
||||||
|
#include "util/refptr.h"
|
||||||
|
#include "shapes/Shape.h" /* includes all shape types */
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,6 +30,8 @@ int main()
|
|||||||
refptr<S> brp(b);
|
refptr<S> brp(b);
|
||||||
cout << "Going to assign brp to arp" << endl;
|
cout << "Going to assign brp to arp" << endl;
|
||||||
arp = brp;
|
arp = brp;
|
||||||
|
cout << "Going to assign a new S to arp" << endl;
|
||||||
|
arp = new S(21);
|
||||||
cout << "ok, exiting" << endl;
|
cout << "ok, exiting" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ class refptr
|
|||||||
refptr<T>(const T * ptr);
|
refptr<T>(const T * ptr);
|
||||||
refptr<T>(const refptr<T> & orig);
|
refptr<T>(const refptr<T> & orig);
|
||||||
refptr<T> & operator=(const refptr<T> & orig);
|
refptr<T> & operator=(const refptr<T> & orig);
|
||||||
|
refptr<T> & operator=(const T * ptr);
|
||||||
~refptr<T>();
|
~refptr<T>();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -47,6 +48,15 @@ template <typename T> refptr<T> & refptr<T>::operator=(const refptr<T> & orig)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> refptr<T> & refptr<T>::operator=(const T * ptr)
|
||||||
|
{
|
||||||
|
destroy();
|
||||||
|
m_ptr = ptr;
|
||||||
|
m_refCount = new int;
|
||||||
|
*m_refCount = 1;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> void refptr<T>::cloneFrom(const refptr<T> & orig)
|
template <typename T> void refptr<T>::cloneFrom(const refptr<T> & orig)
|
||||||
{
|
{
|
||||||
this->m_ptr = orig.m_ptr;
|
this->m_ptr = orig.m_ptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user