home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / source / listptr_3d.cp < prev    next >
Encoding:
Text File  |  1995-03-26  |  2.7 KB  |  52 lines  |  [TEXT/MPCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    listptr.cp
  3. //    Date:                    9/26/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class methods for a list pointer
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "listptr_3d.h"
  11.  
  12. //------------------------------------------------------------------------------
  13. //    constructor
  14. //------------------------------------------------------------------------------
  15. listptr::listptr (void)                                                                                                                    //    normal constructor
  16. {                                                                                                                                                                //    begin
  17.     list = new polylist;                                                                                                                    //    create the new list
  18.     list->ref_count++;                                                                                                                        //    increment the reference count
  19. }                                                                                                                                                                //    end
  20.  
  21. //------------------------------------------------------------------------------
  22. //    constructor
  23. //------------------------------------------------------------------------------
  24. listptr::listptr (const listptr &l)                                                                                            //    normal constructor
  25. {                                                                                                                                                                //    begin
  26.     list = l.list;                                                                                                                                //    copy the list pointer
  27.     list->ref_count++;                                                                                                                        //    increment the reference count
  28. }                                                                                                                                                                //    end
  29.  
  30. //------------------------------------------------------------------------------
  31. //    destructor
  32. //------------------------------------------------------------------------------
  33. listptr::~listptr (void)                                                                                                                //    destructor
  34. {                                                                                                                                                                //    begin
  35.     if (--list->ref_count == 0)                                                                                                        //    decrement the reference count, if it is 0
  36.         delete list;                                                                                                                                //    delete the list
  37. }                                                                                                                                                                //    end
  38.  
  39. //------------------------------------------------------------------------------
  40. //    assignment
  41. //------------------------------------------------------------------------------
  42. listptr        &listptr::operator = (const listptr &l)                                                                //    assignment operator
  43. {                                                                                                                                                                //    begin
  44.     l.list->ref_count++;                                                                                                                    //    increment the reference count for the other list
  45.     if (--list->ref_count == 0)                                                                                                        //    decrement the reference count, if it is 0
  46.         delete list;                                                                                                                                //    delete the list
  47.     list = l.list;                                                                                                                                //    copy the list value from the other list
  48.     return *this;                                                                                                                                    //    return a reference to this
  49. }                                                                                                                                                                //    end
  50.  
  51. //------------------------------------------------------------------------------
  52.