# -*- perl -*-
# DO NOT EDIT - This file is generated by UML2CODE.
# From template: $Id: PerlTemplate.txt,v 1.12 2003/05/11 06:16:02 stephens Exp $

package UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal;

use 5.6.1;
use strict;
use warnings;

#################################################################
# Version
#

our $VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d." . "%03d" x $#r, @r };

#################################################################
# Dependencies
#



use Carp qw(croak confess);

#################################################################
# Generalizations
#

use base qw(
  UML::MetaModel::Foundation::Core::ModelElement


);

#################################################################
# Exports
#

our @EXPORT_OK = qw(
);
our %EXPORT_TAGS = ( ':all' => \@EXPORT_OK );





#################################################################
# Validation
#


=head2 __validate_type

  UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal->__validate_type($value);

Returns true if $value is a valid value of UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.

=cut
sub __validate_type($$)
{
  my ($self, $x) = @_;

  no warnings;

  UNIVERSAL::isa($x, 'UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal')  ;
}


=head2 __typecheck

  UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal->__typecheck($value, $msg);

Calls C<confess()> with C<$msg> if C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal-E<GT>__validate_type($value)> is false.

=cut
sub __typecheck
{
  my ($self, $x, $msg) = @_;

  confess("typecheck: $msg: type 'UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal': value '$x'")
    unless __validate_type($self, $x);
}


=head2 isaSignal

Returns true if receiver is a C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal>.
Other receivers will return false.

=cut
sub isaSignal { 1 }


=head2 isaBehavioral_Elements__Common_Behavior__Signal

Returns true if receiver is a C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal>.
Other receivers will return false.
This is the fully qualified version of the C<isaSignal> method.

=cut
sub isaBehavioral_Elements__Common_Behavior__Signal { 1 }


#################################################################
# Introspection
#

=head2 __model_name 

  my $name = $obj_or_package->__model_name;

Returns the UML Model name (C<'Behavioral_Elements::Common_Behavior::Signal'>) for an object or package of
this Classifier.

=cut
sub __model_name { 'Behavioral_Elements::Common_Behavior::Signal' }





# ASSOC: raisedSignal

  

# ASSOC: signal

  

# ASSOC: signal

  


#################################################################
# Class Attributes
#


    

#################################################################
# Initialization
#

 
=head2 __intialize

Initialize all slots in this Classifier.
Does not initlaize slots in Generalizations.

See also: C<_initialize>.

=cut
sub __initialize
{
  my ($self) = @_;

  # Attributes



  # Associations

  # AssociationEnd 
  #  raisedSignal 0..*
  #  <--> 
  #  context 0..* UML::MetaModel::Foundation::Core::BehavioralFeature.
    if ( defined $self->{'context'} && @{$self->{'context'}} ) {
    my $x = $self->{'context'};
    $self->{'context'} = [ ];
    $self->set_context(@$x);
  }
  
  # AssociationEnd 
  #  signal 1
  #  <--> 
  #  reception 0..* UML::MetaModel::Behavioral_Elements::Common_Behavior::Reception.
    if ( defined $self->{'reception'} && @{$self->{'reception'}} ) {
    my $x = $self->{'reception'};
    $self->{'reception'} = [ ];
    $self->set_reception(@$x);
  }
  
  # AssociationEnd 
  #  signal 1
  #  <--> 
  #  occurance 0..* UML::MetaModel::Behavioral_Elements::State_Machines::SignalEvent.
    if ( defined $self->{'occurance'} && @{$self->{'occurance'}} ) {
    my $x = $self->{'occurance'};
    $self->{'occurance'} = [ ];
    $self->set_occurance(@$x);
  }
  

  $self;
}


my $__initialize_use;

=head2 _intialize

Initialize all slots in this Classifier and all Generalizations.

See also: C<__initialize>.

=cut
sub _initialize
{
  my ($self) = @_;

  # $DB::single = 1;

  unless ( ! $__initialize_use ) {
    $__initialize_use = 1;
    $self->__use('UML::MetaModel::Foundation::Core::Element');
    $self->__use('UML::MetaModel::Foundation::Core::ModelElement');
  }

  $self->UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal::__initialize;
  $self->UML::MetaModel::Foundation::Core::Element::__initialize;
  $self->UML::MetaModel::Foundation::Core::ModelElement::__initialize;

  $self;
}
      

#################################################################
# Attributes
#




#################################################################
# Association
#


#################################################################
# AssociationEnd raisedSignal => context
# type = UML::MetaModel::Foundation::Core::BehavioralFeature
# multiplicity = 0..*

=head2 context

  my @val = $obj->context;
  my $ary_val = $obj->context;

Returns the AssociationEnd value.
In array context, returns all the objects in the Association.
In scalar context, returns an array ref of all the objects in the Association.

=cut
sub context ($)
{
  my ($self) = @_;
		  
  my $x = $self->{'context'} ||= [ ];
  wantarray ? @{$x} : $x;
}


=head2 set_context

  $obj->set_context(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Foundation::Core::BehavioralFeature>.
Returns C<$obj>.

=cut
sub set_context ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_context;
  $self->add_context(@val);
}


=head2 add_context

  $obj->add_context(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Foundation::Core::BehavioralFeature>.
Returns C<$obj>.

=cut
sub add_context ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'context'} ||= [ ];
  my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    next if grep($_ eq $val, @$x);   # Recursion lock
    $self->__use('UML::MetaModel::Foundation::Core::BehavioralFeature')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.context");

    push(@{$x}, $val);               # Recursion lock

    # Remove and add associations with other ends.
        
    $old->remove_raisedSignal($self) if $old;
    $val->add_raisedSignal($self)    if $val;

  
  }
  
  $self;
}


=head2 remove_context

  $obj->remove_context($val);

Removes the Association to C<$val>.
Returns C<$obj>.

=cut
sub remove_context ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'context'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Foundation::Core::BehavioralFeature')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.context");

    @$x = grep($_ ne $old, @$x);       # Recursion lock
    $val = undef;

    # Remove associations with other ends.

        
    $old->remove_raisedSignal($self) if $old;
    $val->add_raisedSignal($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_context

  $obj->clear_context;

Clears the Association.
Returns C<$obj>.

=cut
sub clear_context ($) 
{
  my ($self) = @_;
  
  my $x = $self->{'context'} ||= [ ];
  my $val; # Place holder for other MACRO.
  
  $self->{'context'} = [ ];  # Recursion lock
  for my $old ( @$x ) { # Recursion lock

    # Remove associations with other ends.

        
    $old->remove_raisedSignal($self) if $old;
    $val->add_raisedSignal($self)    if $val;

  ;

  }
  
  $self;
}


#################################################################
# AssociationEnd signal => reception
# type = UML::MetaModel::Behavioral_Elements::Common_Behavior::Reception
# multiplicity = 0..*

=head2 reception

  my @val = $obj->reception;
  my $ary_val = $obj->reception;

Returns the AssociationEnd value.
In array context, returns all the objects in the Association.
In scalar context, returns an array ref of all the objects in the Association.

=cut
sub reception ($)
{
  my ($self) = @_;
		  
  my $x = $self->{'reception'} ||= [ ];
  wantarray ? @{$x} : $x;
}


=head2 set_reception

  $obj->set_reception(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Reception>.
Returns C<$obj>.

=cut
sub set_reception ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_reception;
  $self->add_reception(@val);
}


=head2 add_reception

  $obj->add_reception(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Behavioral_Elements::Common_Behavior::Reception>.
Returns C<$obj>.

=cut
sub add_reception ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'reception'} ||= [ ];
  my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    next if grep($_ eq $val, @$x);   # Recursion lock
    $self->__use('UML::MetaModel::Behavioral_Elements::Common_Behavior::Reception')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.reception");

    push(@{$x}, $val);               # Recursion lock

    # Remove and add associations with other ends.
        
    $old->remove_signal($self) if $old;
    $val->add_signal($self)    if $val;

  
  }
  
  $self;
}


=head2 remove_reception

  $obj->remove_reception($val);

Removes the Association to C<$val>.
Returns C<$obj>.

=cut
sub remove_reception ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'reception'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Behavioral_Elements::Common_Behavior::Reception')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.reception");

    @$x = grep($_ ne $old, @$x);       # Recursion lock
    $val = undef;

    # Remove associations with other ends.

        
    $old->remove_signal($self) if $old;
    $val->add_signal($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_reception

  $obj->clear_reception;

Clears the Association.
Returns C<$obj>.

=cut
sub clear_reception ($) 
{
  my ($self) = @_;
  
  my $x = $self->{'reception'} ||= [ ];
  my $val; # Place holder for other MACRO.
  
  $self->{'reception'} = [ ];  # Recursion lock
  for my $old ( @$x ) { # Recursion lock

    # Remove associations with other ends.

        
    $old->remove_signal($self) if $old;
    $val->add_signal($self)    if $val;

  ;

  }
  
  $self;
}


#################################################################
# AssociationEnd signal => occurance
# type = UML::MetaModel::Behavioral_Elements::State_Machines::SignalEvent
# multiplicity = 0..*

=head2 occurance

  my @val = $obj->occurance;
  my $ary_val = $obj->occurance;

Returns the AssociationEnd value.
In array context, returns all the objects in the Association.
In scalar context, returns an array ref of all the objects in the Association.

=cut
sub occurance ($)
{
  my ($self) = @_;
		  
  my $x = $self->{'occurance'} ||= [ ];
  wantarray ? @{$x} : $x;
}


=head2 set_occurance

  $obj->set_occurance(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Behavioral_Elements::State_Machines::SignalEvent>.
Returns C<$obj>.

=cut
sub set_occurance ($@)
{
  my ($self, @val) = @_;
  
  $self->clear_occurance;
  $self->add_occurance(@val);
}


=head2 add_occurance

  $obj->add_occurance(@val);

Sets the AssociationEnd value.
Elements of C<@val> must of of type C<UML::MetaModel::Behavioral_Elements::State_Machines::SignalEvent>.
Returns C<$obj>.

=cut
sub add_occurance ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'occurance'} ||= [ ];
  my $old; # Place holder for other MACRO.
  
  for my $val ( @val ) {
    next if grep($_ eq $val, @$x);   # Recursion lock
    $self->__use('UML::MetaModel::Behavioral_Elements::State_Machines::SignalEvent')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.occurance");

    push(@{$x}, $val);               # Recursion lock

    # Remove and add associations with other ends.
        
    $old->remove_signal($self) if $old;
    $val->add_signal($self)    if $val;

  
  }
  
  $self;
}


=head2 remove_occurance

  $obj->remove_occurance($val);

Removes the Association to C<$val>.
Returns C<$obj>.

=cut
sub remove_occurance ($@)
{
  my ($self, @val) = @_;
  
  my $x = $self->{'occurance'} ||= [ ];
  
  for my $old ( @val ) {
    next unless grep($_ eq $old, @$x); # Recursion lock
    my $val = $old;
      
    $self->__use('UML::MetaModel::Behavioral_Elements::State_Machines::SignalEvent')->__typecheck($val, "UML::MetaModel::Behavioral_Elements::Common_Behavior::Signal.occurance");

    @$x = grep($_ ne $old, @$x);       # Recursion lock
    $val = undef;

    # Remove associations with other ends.

        
    $old->remove_signal($self) if $old;
    $val->add_signal($self)    if $val;

  ;

  }
  
  $self;
}


=head2 clear_occurance

  $obj->clear_occurance;

Clears the Association.
Returns C<$obj>.

=cut
sub clear_occurance ($) 
{
  my ($self) = @_;
  
  my $x = $self->{'occurance'} ||= [ ];
  my $val; # Place holder for other MACRO.
  
  $self->{'occurance'} = [ ];  # Recursion lock
  for my $old ( @$x ) { # Recursion lock

    # Remove associations with other ends.

        
    $old->remove_signal($self) if $old;
    $val->add_signal($self)    if $val;

  ;

  }
  
  $self;
}




############################################################################

1; # is true!

############################################################################

### Keep these comments at end of file: ks.perl@kurtstephens.com 2003/04/06 ###
### Local Variables: ###
### mode:perl ###
### perl-indent-level:2 ###
### perl-continued-statement-offset:0 ###
### perl-brace-offset:0 ###
### perl-label-offset:0 ###
### End: ###

