libassa  3.5.1
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 
15 namespace ASSA {
16 
23 template <class T>
24 class Destroyer
25 {
26 public:
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 
47 private:
50 
51 private:
53  T* m_otg;
54 };
55 
56 } // end namespace ASSA
57 
58 #endif
Destroyer(const Destroyer< T > &)
Destroyer< T > & operator=(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
Definition: Acceptor.h:40