UDestroyer.h
Go to the documentation of this file.
1 /*
2 * utilite is a cross-platform library with
3 * useful utilities for fast and small developing.
4 * Copyright (C) 2010 Mathieu Labbe
5 *
6 * utilite is free library: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * utilite is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef UDESTROYER_H
21 #define UDESTROYER_H
22 
23 //#include "utilite/UtiLiteExp.h" // DLL export/import defines
24 
33 template <class T>
35 {
36 public:
41  UDestroyer(T* doomed = 0) : doomed_(doomed) {}
42 
44  {
45  if(doomed_)
46  {
47  delete doomed_;
48  doomed_ = 0;
49  }
50  }
51 
57  bool setDoomed(T* doomed)
58  {
59  if(doomed_ && doomed)
60  {
61  return false;
62  }
63  doomed_ = doomed;
64  return true;
65  }
66 
67 private:
68  // Prevent users from making copies of a
69  // Destroyer to avoid double deletion:
70  UDestroyer(const UDestroyer<T>&);
71  void operator=(const UDestroyer<T>&);
72 
73 private:
74  T* doomed_;
75 };
76 
77 #endif // UDESTROYER_H
UDestroyer(T *doomed=0)
Definition: UDestroyer.h:41
bool setDoomed(T *doomed)
Definition: UDestroyer.h:57
T * doomed_
Definition: UDestroyer.h:74
void operator=(const UDestroyer< T > &)


find_object_2d
Author(s): Mathieu Labbe
autogenerated on Mon Jun 10 2019 13:21:31