title color fader/tweaks, bg_color bcbitmap fix, inst.sh fix, lang fr pref tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / garbage.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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 General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef GARBAGE_H
23 #define GARBAGE_H
24
25
26 #include "arraylist.h"
27 #include "garbage.inc"
28 #include "mutex.inc"
29
30 // Garbage collection
31 // The objects inherit from GarbageObject.
32 // The constructor sets users to 1 so the caller must call
33 // Garbage::remove_user when it's done.
34 // Other users of the object must call add_user to increment the user count
35 // and Garbage::remove_user to decriment the user count.
36 // The object is only deleted if a call to Garbage::delete_object is made and
37 // the user count is 0.  returns 0 when no more users, 1 if still in use.
38
39 // Can't make graphics elements inherit because they must be deleted
40 // when the window is locked and they change their parent pointers.
41
42 // Elements of link lists must first be unlinked with remove_pointer and then
43 // passed to delete_object.
44
45 // ArrayList objects must be deleted one at a time with delete_object.
46 // Then the pointers must be deleted with remove_all.
47 //
48 // NOTE: Garbage must be first base class or this!=0 test is broken
49
50 class Garbage
51 {
52         Garbage(Garbage &v) {} //disallow copy constructor
53         Garbage &operator=(Garbage &v) { return *this=v; } //disallow = operator
54 public:
55         Garbage(const char *title);
56         virtual ~Garbage();
57
58 // Called when user begins to use the object.
59         void add_user();
60         int remove_user();
61
62         int users;
63         int deleted;
64         char *title;
65         Mutex *lock;
66 };
67
68
69
70 // class Garbage
71 // {
72 // public:
73 //      Garbage();
74 //      ~Garbage();
75 //
76 // // Called by GarbageObject constructor
77 // //   void add_object(GarbageObject *ptr);
78 //
79 // // Called by user to delete the object.
80 // // Flags the object for deletion as soon as it has no users.
81 //      static void delete_object(GarbageObject *ptr);
82 //
83 //
84 // // Called by remove_user and delete_object
85 // //   static void remove_expired();
86 //      Mutex *lock;
87 // //   ArrayList<GarbageObject*> objects;
88 //
89 // // Global garbage collector
90 //      static Garbage *garbage;
91 // };
92
93
94
95 #endif