00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "odbcpp/object.h"
00025 #include <stdlib.h>
00026 #include <iostream>
00027
00028
00029 namespace odbcpp
00030 {
00031
00032
00072 object::object() :
00073 f_refcount(1)
00074 {
00075 }
00076
00077
00085 object::object(const object& obj) :
00086 f_refcount(1)
00087 {
00088
00089 (void) &obj;
00090 }
00091
00092
00103 object::~object()
00104 {
00105 if(f_refcount != 0 && f_refcount != 1) {
00106
00107 std::cerr << "object at " << this << " has a refcount of " << f_refcount << "\n";
00108 std::terminate();
00109 }
00110 }
00111
00112
00113
00123 object& object::operator = (const object& obj)
00124 {
00125
00126 (void) &obj;
00127 return *this;
00128 }
00129
00130
00141 unsigned long object::addref() const
00142 {
00143 if(this == 0) {
00144 return 0;
00145 }
00146
00147 return ++f_refcount;
00148 }
00149
00150
00162 unsigned long object::release() const
00163 {
00164 if(this == 0) {
00165 return 0;
00166 }
00167
00168 unsigned long result = --f_refcount;
00169
00170
00171 if(result == 0) {
00172 delete this;
00173 }
00174
00175 return result;
00176 }
00177
00178
00179
00180 }
00181
00182