Loading...
Searching...
No Matches
Destroyer.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// Destroyer.h
//------------------------------------------------------------------------------
// Copyright (C) 1997-2002 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef _Destroyer_h
#define _Destroyer_h
namespace ASSA {
template <class T>
class Destroyer
{
public:
Destroyer(T* d_=0) : m_otg (d_) { /* empty */ }
/* Destructor - deletes object T it owns.
*/
~Destroyer() {
if ( m_otg ) {
delete m_otg;
}
}
void setGuard(T* d_) {
m_otg = d_;
}
private:
Destroyer(const Destroyer<T>&);
Destroyer<T>& operator=(const Destroyer<T>&);
private:
T* m_otg;
};
} // end namespace ASSA
#endif
ASSA::Destroyer::Destroyer
Destroyer(const Destroyer< T > &)
ASSA::Destroyer::setGuard
void setGuard(T *d_)
Transfer ownership of object T to Destroyer class.
Definition Destroyer.h:43
ASSA::Destroyer::Destroyer
Destroyer(T *d_=0)
Constructor.
Definition Destroyer.h:30
ASSA::Destroyer::m_otg
T * m_otg
Object T to guard.
Definition Destroyer.h:53
ASSA::Destroyer::~Destroyer
~Destroyer()
Definition Destroyer.h:34
ASSA::Destroyer::operator=
Destroyer< T > & operator=(const Destroyer< T > &)
ASSA
Definition Acceptor.h:40