Autodia

 view release on metacpan or  search on metacpan

lib/Autodia/Diagram/Class.pm  view on Meta::CPAN

  if (ref ($superclass->Inheritances)) {
    my @inheritances = @{$superclass->Inheritances};
    foreach my $inheritance (@inheritances) {
      $inheritance->Parent($self->Id);
    }
  }

  if (ref ($superclass->Relations)) {
    my @relations = @{$superclass->Relations};
    foreach my $relation (@relations) {
      $relation->Parent($self->Id);
    }
  }

  return 1;
}

sub replace_component {
  my $self = shift;
  my $component = shift;

  if (ref ($component->Dependancies) ) {
    my @dependancies = $component->Dependancies;
    foreach my $dependancy (@dependancies) {
      $dependancy->Parent($self->Id);
    }
  }

  return 1;
}

sub Operations {
  my $self = shift;

  if (defined $self->{"operations"}) {
    my @operations = $self->{"operations"};
    return @operations;
  } else {
    return;
  }
}

sub add_operation {
  my $self = shift;
  my $operation = shift();
  $operation->{_id} = ( ref $self->{"operations"} ) ? scalar @{$self->{"operations"}} : 0 ;
  push (@{$self->{"operations"}},$operation);
  $self->{operation_index}{$operation->{name}} = $operation;

  $self->_set_updated("operations");
  $self->_update;

  return scalar(@{$self->{"operations"}});
}

sub get_operation {
    my ($self, $name) = @_;
    return $self->{operation_index}{$name};
}

sub update_operation {
    my $self = shift;
    my $operation = shift;
    
    $self->{"operations"}[$operation->{_id}] = $operation;
    $self->{operation_index}{$operation->{name}} = $operation;

    $self->_set_updated("operations");
    $self->_update;

    return;
}

sub Realizations {
  my $self = shift;
  if( defined $self->{"realizations"} ) {
    my @realizations = @{ $self->{"realizations"} };
    return @realizations;
  }
  else {
    return;
  }
}
 
sub add_realization {
  my $self            = shift;
  my $new_realization = shift;
  my @realizations;
 
  if( defined $self->{"realizations"} ) {
    @realizations = @{ $self->{"realizations"} };
  }
 
  push( @realizations, $new_realization );
  $self->{"realizations"} = \@realizations;
 
  return scalar(@realizations);
}


#-----------------------------------------------------------------------

##################
# Internal Methods

# over-rides method in DiagramObject
sub _initialise {
  my $self = shift;
  $self->{"name"} = shift;
  $self->{"type"} = "class";
  $self->{"top_y"} = 1;
  $self->{"left_x"} = 1;
  $self->{"width"} = 2; # arbitary
  $self->{"height"} = 2; # arbitary
  #$self->{"operations"} = [];
  #$self->{"attributes"} = [];
  $self->{operation_index} = {};

  return 1;
}



( run in 1.671 second using v1.01-cache-2.11-cpan-9581c071862 )