libassa 3.5.1
Loading...
Searching...
No Matches
Destroyer.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// Destroyer.h
4//------------------------------------------------------------------------------
5// Copyright (C) 1997-2002 Vladislav Grinchenko
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//------------------------------------------------------------------------------
12#ifndef _Destroyer_h
13#define _Destroyer_h
14
15namespace ASSA {
16
23template <class T>
25{
26public:
30 Destroyer(T* d_=0) : m_otg (d_) { /* empty */ }
31
32 /* Destructor - deletes object T it owns.
33 */
35 if ( m_otg ) {
36 delete m_otg;
37 }
38 }
39
43 void setGuard(T* d_) {
44 m_otg = d_;
45 }
46
47private:
50
51private:
54};
55
56} // end namespace ASSA
57
58#endif
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
Destroyer(const Destroyer< T > &)
void setGuard(T *d_)
Transfer ownership of object T to Destroyer class.
Definition Destroyer.h:43
Destroyer(T *d_=0)
Constructor.
Definition Destroyer.h:30
T * m_otg
Object T to guard.
Definition Destroyer.h:53
Destroyer< T > & operator=(const Destroyer< T > &)