home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Attribs.pm < prev    next >
Encoding:
Perl POD Document  |  2000-02-26  |  2.0 KB  |  85 lines

  1. package Class::Fields::Attribs;
  2.  
  3. use strict;
  4.  
  5. use vars qw( @EXPORT @ISA $VERSION );
  6. @EXPORT = qw(PUBLIC PRIVATE INHERITED PROTECTED);
  7. require Exporter;
  8. @ISA = qw(Exporter);
  9. $VERSION = '0.02';
  10.  
  11. # Inheritance constants.
  12. # Its too bad I can't use 0bXXX since its 5.6 only.
  13. use constant PUBLIC     => 2**0;    # Open to the public, will be inherited.
  14. use constant PRIVATE    => 2**1;    # Not to be used by anyone but that class, 
  15.                                     # will not be inherited
  16. use constant INHERITED  => 2**2;    # This member was inherited
  17. use constant PROTECTED  => 2**3;    # Not to be used by anyone but that class 
  18.                                     # and its subclasses, will be inherited.
  19.  
  20. # For backwards compatibility.
  21. # contant.pm doesn't like leading underscores.  Damn.
  22. sub _PUBLIC     () { PUBLIC     }
  23. sub _PRIVATE    () { PRIVATE    }
  24. sub _INHERITED  () { INHERITED  }
  25. sub _PROTECTED  () { PROTECTED  }
  26.  
  27. return 'FIRE!';
  28.  
  29. __END__
  30. =pod
  31.  
  32. =head1 NAME
  33.  
  34.   Class::Fields::Attribs - Attribute constants for use with data members
  35.  
  36.  
  37. =head1 SYNOPSIS
  38.  
  39.   # Export the attribute constants
  40.   use Class::Fields::Attribs;
  41.  
  42.  
  43. =head1 DESCRIPTION
  44.  
  45. Simply exports a set of constants used for low level work on data members.
  46. Each constant is a bitmask used to represent the type of a data member
  47. (as in Public, Private, etc...).
  48.  
  49. The exported attributes are:
  50.  
  51. =over 4
  52.  
  53. =item PUBLIC
  54.  
  55. =item PRIVATE
  56.  
  57. =item PROTECTED
  58.  
  59. =item INHERITED
  60.  
  61. Each of these constants is a bitmask representing a possible setting
  62. of a field attribute.  They can be combined by using a bitwise OR and
  63. attributes can be checked for using a bitwise AND.  For example:
  64.  
  65.     # Indicate a piece of data which is both public and inherited.
  66.     $attrib = PUBLIC | INHERITED;
  67.  
  68.     # Check to see if an attribute is protected.
  69.     print "Protected" if $attrib & PROTECTED;
  70.  
  71. It is rare that one has to use these constants and it is generally
  72. better to use the functions provided by Class::Fields.
  73.  
  74. =back
  75.  
  76. =head1 AUTHOR
  77.  
  78. Michael G Schwern <schwern@pobox.com>
  79.  
  80. =head1 SEE ALSO
  81.  
  82. L<Class::Fields>
  83.  
  84. =cut
  85.