| 110 | ***************************************************************************/ |
| 111 | |
| 112 | template< class T, class Data > class CleanUp { |
| 113 | public: |
| 114 | |
| 115 | static void Set( T* t, void c( Data* d, T* t ), Data* d = 0 ) |
| 116 | /* Sets the clean-up function of object BO(t) to be <c, d>, |
| 117 | replacing any previously defined clean-up function for BO(t); c |
| 118 | and d can be null, but t cannot. Sets the clean-up queue for |
| 119 | BO(t) to be the collector's queue. When t is removed from its |
| 120 | clean-up queue, its clean-up will be applied by calling c(d, |
| 121 | t). It is an error if *t is not a collected object. */ |
| 122 | {_CleanUp_Set( t, c, d );} |
| 123 | |
| 124 | static void Call( T* t ) |
| 125 | /* Sets the new clean-up function for BO(t) to be null and, if the |
| 126 | old one is non-null, calls it immediately, even if BO(t) is |
| 127 | still reachable. Deactivates any weak pointers to BO(t). */ |
| 128 | {_CleanUp_Call( t );} |
| 129 | |
| 130 | class Queue {public: |
| 131 | Queue() |
| 132 | /* Constructs a new queue. */ |
| 133 | {this->head = _CleanUp_Queue_NewHead();} |
| 134 | |
| 135 | void Set( T* t ) |
| 136 | /* q.Set(t) sets the clean-up queue of BO(t) to be q. */ |
| 137 | {_CleanUp_Queue_Set( this->head, t );} |
| 138 | |
| 139 | int Call() |
| 140 | /* If q is non-empty, q.Call() removes the first object and |
| 141 | calls its clean-up function; does nothing if q is |
| 142 | empty. Returns true if there are more objects in the |
| 143 | queue. */ |
| 144 | {return _CleanUp_Queue_Call( this->head );} |
| 145 | |
| 146 | private: |
| 147 | void* head; |
| 148 | }; |
| 149 | }; |
| 150 | |
| 151 | /********************************************************************** |
| 152 |
nothing calls this directly
no outgoing calls
no test coverage detected