TDME2 1.9.121
ObjectDeleter.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <vector>
5
6#include <tdme/tdme.h>
8
9using std::find;
10using std::vector;
11
12namespace tdme {
13namespace utilities {
14
15/**
16 * Object deleter
17 * @author Andreas Drewke
18 * @version $Id$
19 */
20template<typename T>
21class ObjectDeleter final
22{
23private:
24 vector<T*> objects;
25
26public:
27 /**
28 * Public constructor
29 */
31 }
32
33 /**
34 * Public destructor
35 */
37 for (auto object: objects) delete object;
38 objects.clear();
39 }
40
41 /**
42 * Adds vector to iterator
43 * @param vector vector
44 */
45 T* add(T* object) {
46 if (find(objects.begin(), objects.end(), object) != objects.end()) return object;
47 objects.push_back(object);
48 return object;
49 }
50
51};
52
53};
54};
~ObjectDeleter()
Public destructor.
Definition: ObjectDeleter.h:36
T * add(T *object)
Adds vector to iterator.
Definition: ObjectDeleter.h:45
ObjectDeleter()
Public constructor.
Definition: ObjectDeleter.h:30
Definition: fwd-tdme.h:4