| 1 | ###################################################################### | ||||||||||
| 2 | # Copyright (c)2010-2011, David L. Armstrong. | ||||||||||
| 3 | # | ||||||||||
| 4 | # P4::OO.pm | ||||||||||
| 5 | # | ||||||||||
| 6 | # See COPYRIGHT AND LICENSE section in pod text below for usage | ||||||||||
| 7 | # and distribution rights. | ||||||||||
| 8 | # | ||||||||||
| 9 | ###################################################################### | ||||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | P4::OO - First class objects for Perforce specs | ||||||||||
| 14 | |||||||||||
| 15 | =head1 SYNOPSIS | ||||||||||
| 16 | |||||||||||
| 17 | # use P4PERL and P4PORT/P4CLIENT environment by default | ||||||||||
| 18 | my $p4oo = P4::OO->new(); | ||||||||||
| 19 | |||||||||||
| 20 | =head1 ENVIRONMENT | ||||||||||
| 21 | |||||||||||
| 22 | P4::OO requires P4PERL to talk directly to Perforce | ||||||||||
| 23 | |||||||||||
| 24 | P4::OO uses reasonable defaults, and using the caller's P4PORT | ||||||||||
| 25 | and P4CLIENT environment variables to find the Perforce client to use. | ||||||||||
| 26 | |||||||||||
| 27 | =head1 DESCRIPTION | ||||||||||
| 28 | |||||||||||
| 29 | P4::OO is distinguished from P4PERL in that P4PERL provides a | ||||||||||
| 30 | handle for talking to Perforce in a manner similar to the 'p4' | ||||||||||
| 31 | command. P4::OO represents Perforce specs as first class objects | ||||||||||
| 32 | (similar to type-specific versions of P4::Spec objects), | ||||||||||
| 33 | and provides capability for added functionality for each type of | ||||||||||
| 34 | object. | ||||||||||
| 35 | |||||||||||
| 36 | =head2 First Class Objects | ||||||||||
| 37 | |||||||||||
| 38 | These objects are provided and corresspond directly to the 'p4' | ||||||||||
| 39 | subcommands by the same names: | ||||||||||
| 40 | P4:OO::Branch | ||||||||||
| 41 | P4:OO::Change | ||||||||||
| 42 | P4:OO::Changelist - P4:OO::Change by another name. | ||||||||||
| 43 | P4:OO::Client | ||||||||||
| 44 | P4:OO::Depot | ||||||||||
| 45 | P4:OO::Group | ||||||||||
| 46 | P4:OO::Job | ||||||||||
| 47 | P4:OO::Label | ||||||||||
| 48 | P4:OO::User | ||||||||||
| 49 | P4:OO::Workspace - P4:OO::Client by another name. | ||||||||||
| 50 | |||||||||||
| 51 | =head2 Connecting P4::OO to your Perforce database | ||||||||||
| 52 | |||||||||||
| 53 | If you initialize your own P4PERL connection, you can have P4::OO | ||||||||||
| 54 | use it instead of constructing it's own. You will also have to | ||||||||||
| 55 | disconnect it when you're done. If P4:OO constructs it's | ||||||||||
| 56 | own P4PERL connection, P4::OO will also attempt to destroy it at | ||||||||||
| 57 | garbage collection time. | ||||||||||
| 58 | |||||||||||
| 59 | # Connect to P4PERL and have have P4::OO reuse connection | ||||||||||
| 60 | my $p4PerlObj = P4->new(); | ||||||||||
| 61 | $p4PerlObj->SetClient( $clientname ); | ||||||||||
| 62 | $p4PerlObj->SetPort ( $p4port ); | ||||||||||
| 63 | $p4PerlObj->Connect(); | ||||||||||
| 64 | |||||||||||
| 65 | # Initialize P4::OO with this P4PERL connection | ||||||||||
| 66 | my $p4ooObj = P4::OO->new( 'p4PerlObj' => $p4PerlObj ); | ||||||||||
| 67 | |||||||||||
| 68 | # When you're done with P4::OO and your P4PERL connection | ||||||||||
| 69 | $p4PerlObj->Disconnect(); | ||||||||||
| 70 | |||||||||||
| 71 | |||||||||||
| 72 | =head1 SEE ALSO | ||||||||||
| 73 | |||||||||||
| 74 | P4PERL - http://public.perforce.com/guest/tony_smith/perforce/API/Perl/index.html | ||||||||||
| 75 | |||||||||||
| 76 | =cut | ||||||||||
| 77 | |||||||||||
| 78 | ###################################################################### | ||||||||||
| 79 | # Package Initialization | ||||||||||
| 80 | # | ||||||||||
| 81 | package P4::OO; | ||||||||||
| 82 | 28 | our $VERSION = '0.00_02'; | |||||||||
| 83 | |||||||||||
| 84 | # bring in the _getAttr/_setAttr methods for our use | ||||||||||
| 85 | 28 | ▶ | use base 'P4::OO::_Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 86 | |||||||||||
| 87 | # Import exception methods and hierarchy for all of our subclasses | ||||||||||
| 88 | 28 | ▶ | use P4::OO::_Error; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 89 | |||||||||||
| 90 | |||||||||||
| 91 | ###################################################################### | ||||||||||
| 92 | # Globals | ||||||||||
| 93 | # | ||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | ###################################################################### | ||||||||||
| 97 | # Public Methods | ||||||||||
| 98 | # | ||||||||||
| 99 | |||||||||||
| 100 | |||||||||||
| 101 | ###################################################################### | ||||||||||
| 102 | # Internal Methods | ||||||||||
| 103 | # | ||||||||||
| 104 | |||||||||||
| 105 | sub _getP4Connection | ||||||||||
| 106 | 0 | ▶ | { | ||||||||
|
Subroutine
_getP4Connection: not called CC=3 SCAR=24.8
| |||||||||||
| 107 | 0 | my $self = shift(); | |||||||||
| 108 | |||||||||||
| 109 | 0 | my $p4Conn = $self->_getAttr( '_p4Conn' ); | |||||||||
| 110 | |||||||||||
| 111 | 0 | ▶ | if( ! defined( $p4Conn ) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | { | ||||||||||
| 113 | 0 | require P4::OO::_Connection; | |||||||||
| 114 | |||||||||||
| 115 | 0 | my $p4PerlObj = $self->_getAttr( 'p4PerlObj' ); | |||||||||
| 116 | |||||||||||
| 117 | 0 | ▶ | if( defined( $p4PerlObj ) ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | { | ||||||||||
| 119 | # P4PERL takes precedence | ||||||||||
| 120 | 0 | require P4::OO::_Connection::P4PERL; | |||||||||
| 121 | 0 | $p4Conn = P4::OO::_Connection::P4PERL->new( 'p4PerlObj' => $self->_getAttr( 'p4PerlObj' ) ); | |||||||||
| 122 | } | ||||||||||
| 123 | else | ||||||||||
| 124 | { | ||||||||||
| 125 | # P4PERL is also the default | ||||||||||
| 126 | 0 | require P4::OO::_Connection::P4PERL; | |||||||||
| 127 | 0 | $p4Conn = P4::OO::_Connection::P4PERL->new(); | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 0 | $self->_setAttr( '_p4Conn', $p4Conn ); | |||||||||
| 131 | } | ||||||||||
| 132 | |||||||||||
| 133 | 0 | return( $p4Conn ); | |||||||||
| 134 | } | ||||||||||
| 135 | |||||||||||
| 136 | |||||||||||
| 137 | ###################################################################### | ||||||||||
| 138 | # Standard authorship and copyright for documentation | ||||||||||
| 139 | # | ||||||||||
| 140 | |||||||||||
| 141 | =head1 AUTHOR | ||||||||||
| 142 | |||||||||||
| 143 | David L. Armstrong <armstd@cpan.org> | ||||||||||
| 144 | |||||||||||
| 145 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 146 | |||||||||||
| 147 | P4::OO is Copyright (c)2010-2011, David L. Armstrong. | ||||||||||
| 148 | |||||||||||
| 149 | This module is free software; you can redistribute it and/or | ||||||||||
| 150 | modify it under the same terms as Perl itself, either Perl | ||||||||||
| 151 | version 5.8.8 or, at your option, any later version of Perl 5 | ||||||||||
| 152 | you may have available. | ||||||||||
| 153 | |||||||||||
| 154 | =head1 SUPPORT AND WARRANTY | ||||||||||
| 155 | |||||||||||
| 156 | This program is distributed in the hope that it will be | ||||||||||
| 157 | useful, but it is provided "as is" and without any expressed | ||||||||||
| 158 | or implied warranties. | ||||||||||
| 159 | |||||||||||
| 160 | =cut | ||||||||||
| 161 | |||||||||||
| 162 | 28 | 1; | |||||||||