ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Garbage.cxx
Go to the documentation of this file.
1 
8 #include "Garbage.h"
9 
10 // ROOT object for signal
12 
13 Garbage::Garbage() : TObject() {
14 #ifdef DEBUG_CONT_FRAME
15  std::cout << "Constructor Garbage" << std::endl;
16 #endif
17 }
18 
20 //Garbage * Garbage::getInstance() {
21 #ifdef DEBUG_CONT_FRAME
22  std::cout << "Garbage::getInstance()" << std::endl;
23 #endif
24  // static assure it will be initialized only one, lazy initialization
25  // but maybe problem when deleted
26  static Garbage instance;
27  return instance;
28  //return &instance;
29 }
30 
31 // double free if nothing loaded in GUIStock
32 // but destructor never called explicitly, certainly not created
34 #ifdef DEBUG_CONT_FRAME
35  std::cout << "Destructor Garbage" << std::endl;
36 #endif
37 }
38 
39 void Garbage::Add(TObject * obj) {
40 #ifdef DEBUG_CONT_FRAME
41  std::cout << "Garbage::Add " << obj->GetName() << std::endl;
42 #endif
43 
44  list_object.push_back(obj);
45 }
46 
48 /* #ifdef DEBUG_CONT_FRAME
49  std::cout << "Garbage::HandleTimer" << std::endl;
50  std::cout << "Size list " << list_object.size() << std::endl;
51 #endif */
52 
53  for (it_l it_list = list_object.begin(); it_list != list_object.end(); it_list++ ) {
54 #ifdef DEBUG_CONT_FRAME
55  std::cout << "Garbage:: delete object: " << (*it_list)->GetName() << std::endl;
56 #endif
57  delete (*it_list);
58  }
59  list_object.clear();
60  return false;
61 }
void Add(TObject *)
Add a TOBject to be deleted.
Definition: Garbage.cxx:39
virtual Bool_t HandleTimer(TTimer *)
called by a TTImer and delete all objects in the list
Definition: Garbage.cxx:47
~Garbage()
Definition: Garbage.cxx:33
Garbage collector for ROOT TObjects.
Definition: Garbage.h:30
static Garbage & getInstance()
Definition: Garbage.cxx:19
std::list< TObject * >::iterator it_l
Definition: Garbage.h:46
std::list< TObject * > list_object
Definition: Garbage.h:45
ClassImp(Garbage) Garbage
Garbage.cxx.
Definition: Garbage.cxx:11