86 if (0 == --((R)->ref_count)) { \
98#define INC_COUNT_NULL(R) \
100 if ((R) != NULL) (R)->ref_count++; \
112#define DEC_COUNT_NULL(R) \
114 if ((R) != NULL && 0 == --((R)->ref_count)) { \
137#define CONCRETE(PTR) \
141 inline PTR (const PTR&); \
143 inline PTR##_rep* operator->(); \
144 inline PTR& operator= (PTR x)
159#define CONCRETE_CODE(PTR) \
160 inline PTR::PTR (const PTR& x) : rep (x.rep) { INC_COUNT (this->rep); } \
161 inline PTR::~PTR () { DEC_COUNT (this->rep); } \
162 inline PTR##_rep* PTR::operator->() { return rep; } \
163 inline PTR& PTR::operator= (PTR x) { \
165 DEC_COUNT (this->rep); \
190#define CONCRETE_TEMPLATE(PTR, T) \
194 inline PTR (const PTR<T>&); \
196 inline PTR##_rep<T>* operator->(); \
197 inline PTR<T>& operator= (PTR<T> x)
215#define CONCRETE_TEMPLATE_CODE(PTR, TT, T) \
216 template <TT T> inline PTR<T>::PTR (const PTR<T>& x) : rep (x.rep) { \
217 INC_COUNT (this->rep); \
219 template <TT T> inline PTR<T>::~PTR () { DEC_COUNT (this->rep); } \
220 template <TT T> inline PTR##_rep<T>* PTR<T>::operator->() { \
223 template <TT T> inline PTR<T>& PTR<T>::operator= (PTR<T> x) { \
225 DEC_COUNT (this->rep); \
251#define CONCRETE_TEMPLATE_2(PTR, T1, T2) \
252 PTR##_rep<T1, T2>* rep; \
255 inline PTR (const PTR<T1, T2>&); \
257 inline PTR##_rep<T1, T2>* operator->(); \
258 inline PTR<T1, T2>& operator= (PTR<T1, T2> x)
278#define CONCRETE_TEMPLATE_2_CODE(PTR, TT1, T1, TT2, T2) \
279 template <TT1 T1, TT2 T2> \
280 inline PTR<T1, T2>::PTR (const PTR<T1, T2>& x) : rep (x.rep) { \
281 INC_COUNT (this->rep); \
283 template <TT1 T1, TT2 T2> inline PTR<T1, T2>::~PTR () { \
284 DEC_COUNT (this->rep); \
286 template <TT1 T1, TT2 T2> \
287 inline PTR##_rep<T1, T2>* PTR<T1, T2>::operator->() { \
290 template <TT1 T1, TT2 T2> \
291 inline PTR<T1, T2>& PTR<T1, T2>::operator= (PTR<T1, T2> x) { \
293 DEC_COUNT (this->rep); \
306#define ABSTRACT(PTR) \
308 inline PTR (PTR##_rep*)
315#define ABSTRACT_CODE(PTR) \
316 CONCRETE_CODE (PTR); \
317 inline PTR::PTR (PTR##_rep* rep2) : rep (rep2) { INC_COUNT (this->rep); }
325#define ABSTRACT_TEMPLATE(PTR, T) \
326 CONCRETE_TEMPLATE (PTR, T); \
327 inline PTR (PTR##_rep<T>*)
336#define ABSTRACT_TEMPLATE_CODE(PTR, TT, T) \
337 CONCRETE_TEMPLATE_CODE (PTR, TT, T); \
338 template <TT T> inline PTR<T>::PTR (PTR##_rep<T>* rep2) : rep (rep2) { \
339 INC_COUNT (this->rep); \
354#define CONCRETE_NULL(PTR) \
357 friend bool is_nil (PTR x)
364#define CONCRETE_NULL_CODE(PTR) \
365 inline PTR::PTR () : rep (NULL) {} \
366 inline PTR::PTR (const PTR& x) : rep (x.rep) { INC_COUNT_NULL (this->rep); } \
367 inline PTR::~PTR () { DEC_COUNT_NULL (this->rep); } \
368 inline PTR##_rep* PTR::operator->() { return this->rep; } \
369 inline PTR& PTR::operator= (PTR x) { \
370 INC_COUNT_NULL (x.rep); \
371 DEC_COUNT_NULL (this->rep); \
375 inline bool is_nil (PTR x) { return x.rep == NULL; }
383#define CONCRETE_NULL_TEMPLATE(PTR, T) \
384 CONCRETE_TEMPLATE (PTR, T); \
386 friend bool is_nil LESSGTR (PTR<T> x)
395#define CONCRETE_NULL_TEMPLATE_CODE(PTR, TT, T) \
396 template <TT T> inline PTR<T>::PTR () : rep (NULL) {} \
397 template <TT T> inline PTR<T>::PTR (const PTR<T>& x) : rep (x.rep) { \
398 INC_COUNT_NULL (this->rep); \
400 template <TT T> inline PTR<T>::~PTR () { DEC_COUNT_NULL (this->rep); } \
401 template <TT T> inline PTR##_rep<T>* PTR<T>::operator->() { \
404 template <TT T> inline PTR<T>& PTR<T>::operator= (PTR<T> x) { \
405 INC_COUNT_NULL (x.rep); \
406 DEC_COUNT_NULL (this->rep); \
410 template <TT T> inline bool is_nil (PTR<T> x) { return x.rep == NULL; }
419#define CONCRETE_NULL_TEMPLATE_2(PTR, T1, T2) \
420 CONCRETE_TEMPLATE_2 (PTR, T1, T2); \
422 friend bool is_nil LESSGTR (PTR<T1, T2> x)
435#define CONCRETE_NULL_TEMPLATE_2_CODE(PTR, TT1, T1, TT2, T2) \
436 template <TT1 T1, TT2 T2> inline PTR<T1, T2>::PTR () : rep (NULL) {} \
437 template <TT1 T1, TT2 T2> \
438 inline PTR<T1, T2>::PTR (const PTR<T1, T2>& x) : rep (x.rep) { \
439 INC_COUNT_NULL (this->rep); \
441 template <TT1 T1, TT2 T2> inline PTR<T1, T2>::~PTR () { \
442 DEC_COUNT_NULL (this->rep); \
444 template <TT1 T1, TT2 T2> PTR##_rep<T1, T2>* PTR<T1, T2>::operator->() { \
447 template <TT1 T1, TT2 T2> \
448 inline PTR<T1, T2>& PTR<T1, T2>::operator= (PTR<T1, T2> x) { \
449 INC_COUNT_NULL (x.rep); \
450 DEC_COUNT_NULL (this->rep); \
454 template <TT1 T1, TT2 T2> inline bool is_nil (PTR<T1, T2> x) { \
455 return x.rep == NULL; \
466#define ABSTRACT_NULL(PTR) \
467 CONCRETE_NULL (PTR); \
468 inline PTR (PTR##_rep*)
474#define ABSTRACT_NULL_CODE(PTR) \
475 CONCRETE_NULL_CODE (PTR); \
476 inline PTR::PTR (PTR##_rep* rep2) : rep (rep2) { INC_COUNT_NULL (this->rep); }
483#define ABSTRACT_NULL_TEMPLATE(PTR, T) \
484 CONCRETE_NULL_TEMPLATE (PTR, T); \
485 inline PTR (PTR##_rep<T>*)
493#define ABSTRACT_NULL_TEMPLATE_CODE(PTR, TT, T) \
494 CONCRETE_NULL_TEMPLATE_CODE (PTR, TT, T); \
495 template <TT T> inline PTR<T>::PTR (PTR##_rep<T>* rep2) : rep (rep2) { \
496 INC_COUNT (this->rep); \
506#define ABSTRACT_NULL_TEMPLATE_2(PTR, T1, T2) \
507 CONCRETE_NULL_TEMPLATE_2 (PTR, T1, T2); \
508 inline PTR (PTR##_rep<T1, T2>*)
521#define ABSTRACT_NULL_TEMPLATE_2_CODE(PTR, TT1, T1, TT2, T2) \
522 CONCRETE_NULL_TEMPLATE_2_CODE (PTR, TT1, T1, TT2, T2); \
523 template <TT1 T1, TT2 T2> \
524 inline PTR<T1, T2>::PTR (PTR##_rep<T1, T2>* rep2) : rep (rep2) { \
525 INC_COUNT (this->rep); \
540#define EXTEND(BASE, PTR) \
542 inline PTR (BASE&); \
543 inline operator BASE ()
552#define EXTEND_CODE(BASE, PTR) \
553 ABSTRACT_CODE (PTR); \
554 inline PTR::PTR (BASE& x) : rep (static_cast<PTR##_rep*> (x.rep)) { \
555 INC_COUNT (this->rep); \
557 inline PTR::operator BASE () { return BASE (this->rep); }
569#define EXTEND_NULL(BASE, PTR) \
570 ABSTRACT_NULL (PTR); \
571 inline PTR (BASE&); \
572 inline operator BASE ()
581#define EXTEND_NULL_CODE(BASE, PTR) \
582 ABSTRACT_NULL_CODE (PTR); \
583 inline PTR::PTR (BASE& x) : rep (static_cast<PTR##_rep*> (x.rep)) { \
584 INC_COUNT_NULL (this->rep); \
586 inline PTR::operator BASE () { return BASE (this->rep); }
596#define EXTEND_NULL_TEMPLATE(BASE, PTR, T) \
597 ABSTRACT_NULL_TEMPLATE (PTR, T); \
598 inline PTR<T> (BASE&); \
599 inline operator BASE ()
610#define EXTEND_NULL_TEMPLATE_CODE(BASE, PTR, TT, T) \
611 ABSTRACT_NULL_TEMPLATE_CODE (PTR, TT, T); \
613 inline PTR<T>::PTR (BASE& x) : rep (static_cast<PTR##_rep<T>*> (x.rep)) { \
614 INC_COUNT_NULL (this->rep); \
616 template <TT T> inline PTR<T>::operator BASE () { return BASE (this->rep); }
int concrete_count
Global variable holding the number of concrete structures currently active.
#define TM_DEBUG(x)
Debugging macro used to disable debugging output.
int abstract_count
Global variable holding the number of abstract structures currently active.
Structure representing an abstract object with a reference count.
virtual ~abstract_struct()
Virtual destructor for the abstract object. Decrements the reference count.
abstract_struct()
Default constructor for the abstract object. Sets the reference count to 0.
int ref_count
The reference count for the abstract object.
Structure representing a concrete object with a reference count.
virtual ~concrete_struct()
Virtual destructor for the concrete object. Decrements the reference count.
concrete_struct()
Default constructor for the concrete object. Increments the reference count.
int ref_count
The reference count for the concrete object.