// // aegis - project change supervisor // Copyright (C) 2014 Peter Miller // // 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 3 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, see . // #include #include #include #include change_pointer::~change_pointer() { if (p) p->reference_count_down(); } change_pointer::change_pointer() : p(0) { } change_pointer::change_pointer(change *rhs) : p(rhs) { if (p) p->reference_count_up(); } change_pointer::change_pointer(const change *rhs) : p(const_cast(rhs)) { if (p) p->reference_count_up(); } change_pointer::change_pointer(change *cp, bool add_ref) : p(cp) { if (p && add_ref) p->reference_count_up(); } change_pointer::change_pointer(const change_pointer &rhs) : p(rhs.get()) { if (p) p->reference_count_up(); } change_pointer & change_pointer::operator=(const change_pointer &rhs) { change_pointer(rhs).swap(*this); return *this; } change_pointer & change_pointer::operator=(const change *rhs) { change_pointer(rhs).swap(*this); return *this; } change_pointer & change_pointer::operator=(change *rhs) { change_pointer(rhs).swap(*this); return *this; } void change_pointer::reset(void) { change_pointer().swap(*this); } void change_pointer::reset(change *rhs) { change_pointer(rhs).swap(*this); } void change_pointer::reset(const change_pointer &rhs) { change_pointer(rhs).swap(*this); } change & change_pointer::operator*() const { assert(p); return *p; } change * change_pointer::get(void) const { return p; } change * change_pointer::operator->() const { assert(p); return p; } void change_pointer::swap(change_pointer &rhs) { change *tmp = p; p = rhs.p; rhs.p = tmp; } bool change_pointer::operator==(const change_pointer &rhs) { return (p == rhs.p); } bool change_pointer::operator!=(const change_pointer &rhs) { return (p != rhs.p); } // vim: set ts=8 sw=4 et :