Bio-MAGE-20030502.3/0000755000175000017500000000000010622037520012701 5ustar jasonsjasonsBio-MAGE-20030502.3/MAGE/0000755000175000017500000000000010622037520013412 5ustar jasonsjasonsBio-MAGE-20030502.3/MAGE/Measurement/0000755000175000017500000000000010622037520015677 5ustar jasonsjasonsBio-MAGE-20030502.3/MAGE/Measurement/QuantityUnit.pm0000644000175000017500000004445410472775113020740 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::QuantityUnit # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::QuantityUnit; use strict; use Carp; use base qw(Bio::MAGE::Measurement::Unit); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant UNITNAMECV_AMOL => 'amol'; use constant UNITNAMECV_MOLECULES => 'molecules'; use constant UNITNAMECV_NMOL => 'nmol'; use constant UNITNAMECV_OTHER => 'other'; use constant UNITNAMECV_MOL => 'mol'; use constant UNITNAMECV_MMOL => 'mmol'; use constant UNITNAMECV_UMOL => 'umol'; use constant UNITNAMECV_PMOL => 'pmol'; use constant UNITNAMECV_FMOL => 'fmol'; =head1 NAME Bio::MAGE::Measurement::QuantityUnit - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::QuantityUnit # creating an empty instance my $quantityunit = Bio::MAGE::Measurement::QuantityUnit->new(); # creating an instance with existing data my $quantityunit = Bio::MAGE::Measurement::QuantityUnit->new( unitNameCV=>$unitnamecv_val, unitName=>$unitname_val, propertySets=>\@namevaluetype_list, ); # 'unitNameCV' attribute my $unitNameCV_val = $quantityunit->unitNameCV(); # getter $quantityunit->unitNameCV($value); # setter # 'unitName' attribute my $unitName_val = $quantityunit->unitName(); # getter $quantityunit->unitName($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $quantityunit->propertySets(); # getter $quantityunit->propertySets(\@namevaluetype_list); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: Quantity =cut =head1 INHERITANCE Bio::MAGE::Measurement::QuantityUnit has the following superclasses: =over =item * Bio::MAGE::Measurement::Unit =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::QuantityUnit]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Measurement::Unit']; $__ATTRIBUTE_NAMES = ['unitNameCV', 'unitName']; $__ASSOCIATION_NAMES = ['propertySets']; $__ASSOCIATIONS = [] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::QuantityUnit->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * unitNameCV Sets the value of the C attribute =item * unitName Sets the value of the C attribute (this attribute was inherited from class C). =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item unitNameCV Methods for the C attribute. From the MAGE-OM documentation: =over =item $val = $quantityunit->setUnitNameCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: mol amol fmol pmol nmol umol mmol molecules other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: mol amol fmol pmol nmol umol mmol molecules other =cut sub setUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::setUnitNameCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitNameCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setUnitNameCV: expected one of enum values : mol amol fmol pmol nmol umol mmol molecules other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(mol amol fmol pmol nmol umol mmol molecules other)); return $self->{__UNITNAMECV} = $val; } =item $val = $quantityunit->getUnitNameCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::getUnitNameCV: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAMECV}; } =back =item unitName Methods for the C attribute. From the MAGE-OM documentation: The name of the unit. =over =item $val = $quantityunit->setUnitName($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setUnitName { my $self = shift; croak(__PACKAGE__ . "::setUnitName: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitName: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__UNITNAME} = $val; } =item $val = $quantityunit->getUnitName() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitName { my $self = shift; croak(__PACKAGE__ . "::getUnitName: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAME}; } =back =back =head2 ASSOCIATIONS Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association: =over =item 1 There B be exactly one item in the association, i.e. this is a mandatory data field. =item 0..1 There B be one item in the association, i.e. this is an optional data field. =item 1..N There B be one or more items in the association, i.e. this is a mandatory data field, with list cardinality. =item 0..N There B be one or more items in the association, i.e. this is an optional data field, with list cardinality. =back Bio::MAGE::Measurement::QuantityUnit has the following association accessor methods: =over =item propertySets Methods for the C association. From the MAGE-OM documentation: Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper. =over =item $array_ref = $quantityunit->setPropertySets($array_ref) The restricted setter method for the C association. Input parameters: the value to which the C association will be set : a reference to an array of objects of type C Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$array_ref> is not a reference to an array class C instances =cut sub setPropertySets { my $self = shift; croak(__PACKAGE__ . "::setPropertySets: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setPropertySets: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setPropertySets: expected array reference, got $self") unless (not defined $val) or UNIVERSAL::isa($val,'ARRAY'); if (defined $val) { foreach my $val_ent (@{$val}) { croak(__PACKAGE__ . "::setPropertySets: wrong type: " . ref($val_ent) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val_ent,'Bio::MAGE::NameValueType'); } } return $self->{__PROPERTYSETS} = $val; } =item $array_ref = $quantityunit->getPropertySets() The restricted getter method for the C association. Input parameters: none Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getPropertySets { my $self = shift; croak(__PACKAGE__ . "::getPropertySets: arguments passed to getter") if @_; my $val = shift; return $self->{__PROPERTYSETS}; } =item $val = $quantityunit->addPropertySets(@vals) Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association. Input parameters: the list of values C<@vals> to add to the propertySets association. B: submitting a single value is permitted. Return value: the number of items stored in the slot B adding C<@vals> Side effects: none Exceptions: will call C if no input parameters are specified, or if any of the objects in @vals is not an instance of class C =cut sub addPropertySets { my $self = shift; croak(__PACKAGE__ . "::addPropertySets: no arguments passed to adder") unless @_; my @vals = @_; foreach my $val (@vals) { croak(__PACKAGE__ . "::addPropertySets: wrong type: " . ref($val) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val,'Bio::MAGE::NameValueType'); } return push(@{$self->{__PROPERTYSETS}},@vals); } =back sub initialize { my $self = shift; return 1; } =back =cut =head1 SLOTS, ATTRIBUTES, AND ASSOCIATIONS In the Perl implementation of MAGE-OM classes, there are three types of class data members: C, C, and C. =head2 SLOTS This API uses the term C to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes - use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes. Slots are implemented using unified getter/setter methods: =over =item $var = $obj->slot_name(); Retrieves the current value of the slot. =item $new_var = $obj->slot_name($new_var); Store $new_var in the slot - the return value is also $new_var. =item @names = $obj->get_slot_names() Returns the list of all slots in the class. =back B: No data type checking is made for these methods. =head2 ATTRIBUTES AND ASSOCIATIONS The terms C and C indicate data members of the class that were specified directly from the UML model. In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods: =over =item get* Retrieves the current value. B: For associations, if the association has list cardinality, an array reference is returned. B: Ensure that no argument is provided. =item set* Sets the current value, B any existing value. B: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods. B: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class. =item add* B: Only present in associations with list cardinality. Appends a list of objects to any values that may already be stored in the association. B: Ensure that all arguments are of the correct MAGE-OM class. =back =head2 GENERIC METHODS The unified base class of all MAGE-OM classes, C, provides a set of generic methods that will operate on slots, attributes, and associations: =over =item $val = $obj->get_slot($name) =item \@list_ref = $obj->get_slots(@name_list); =item $val = $obj->set_slot($name,$val) =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) See elsewhere in this page for a detailed description of these methods. =back =cut =head1 BUGS Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) =head1 AUTHOR Jason E. Stewart (jasons 'at' cpan 'dot' org) =head1 SEE ALSO perl(1). =cut # all perl modules must be true... 1; Bio-MAGE-20030502.3/MAGE/Measurement/DistanceUnit.pm0000644000175000017500000004414610472775113020652 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::DistanceUnit # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::DistanceUnit; use strict; use Carp; use base qw(Bio::MAGE::Measurement::Unit); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant UNITNAMECV_MM => 'mm'; use constant UNITNAMECV_FM => 'fm'; use constant UNITNAMECV_PM => 'pm'; use constant UNITNAMECV_CM => 'cm'; use constant UNITNAMECV_OTHER => 'other'; use constant UNITNAMECV_M => 'm'; use constant UNITNAMECV_UM => 'um'; use constant UNITNAMECV_NM => 'nm'; =head1 NAME Bio::MAGE::Measurement::DistanceUnit - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::DistanceUnit # creating an empty instance my $distanceunit = Bio::MAGE::Measurement::DistanceUnit->new(); # creating an instance with existing data my $distanceunit = Bio::MAGE::Measurement::DistanceUnit->new( unitNameCV=>$unitnamecv_val, unitName=>$unitname_val, propertySets=>\@namevaluetype_list, ); # 'unitNameCV' attribute my $unitNameCV_val = $distanceunit->unitNameCV(); # getter $distanceunit->unitNameCV($value); # setter # 'unitName' attribute my $unitName_val = $distanceunit->unitName(); # getter $distanceunit->unitName($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $distanceunit->propertySets(); # getter $distanceunit->propertySets(\@namevaluetype_list); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: Distance =cut =head1 INHERITANCE Bio::MAGE::Measurement::DistanceUnit has the following superclasses: =over =item * Bio::MAGE::Measurement::Unit =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::DistanceUnit]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Measurement::Unit']; $__ATTRIBUTE_NAMES = ['unitNameCV', 'unitName']; $__ASSOCIATION_NAMES = ['propertySets']; $__ASSOCIATIONS = [] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::DistanceUnit->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * unitNameCV Sets the value of the C attribute =item * unitName Sets the value of the C attribute (this attribute was inherited from class C). =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item unitNameCV Methods for the C attribute. From the MAGE-OM documentation: =over =item $val = $distanceunit->setUnitNameCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: fm pm nm um mm cm m other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: fm pm nm um mm cm m other =cut sub setUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::setUnitNameCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitNameCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setUnitNameCV: expected one of enum values : fm pm nm um mm cm m other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(fm pm nm um mm cm m other)); return $self->{__UNITNAMECV} = $val; } =item $val = $distanceunit->getUnitNameCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::getUnitNameCV: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAMECV}; } =back =item unitName Methods for the C attribute. From the MAGE-OM documentation: The name of the unit. =over =item $val = $distanceunit->setUnitName($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setUnitName { my $self = shift; croak(__PACKAGE__ . "::setUnitName: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitName: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__UNITNAME} = $val; } =item $val = $distanceunit->getUnitName() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitName { my $self = shift; croak(__PACKAGE__ . "::getUnitName: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAME}; } =back =back =head2 ASSOCIATIONS Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association: =over =item 1 There B be exactly one item in the association, i.e. this is a mandatory data field. =item 0..1 There B be one item in the association, i.e. this is an optional data field. =item 1..N There B be one or more items in the association, i.e. this is a mandatory data field, with list cardinality. =item 0..N There B be one or more items in the association, i.e. this is an optional data field, with list cardinality. =back Bio::MAGE::Measurement::DistanceUnit has the following association accessor methods: =over =item propertySets Methods for the C association. From the MAGE-OM documentation: Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper. =over =item $array_ref = $distanceunit->setPropertySets($array_ref) The restricted setter method for the C association. Input parameters: the value to which the C association will be set : a reference to an array of objects of type C Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$array_ref> is not a reference to an array class C instances =cut sub setPropertySets { my $self = shift; croak(__PACKAGE__ . "::setPropertySets: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setPropertySets: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setPropertySets: expected array reference, got $self") unless (not defined $val) or UNIVERSAL::isa($val,'ARRAY'); if (defined $val) { foreach my $val_ent (@{$val}) { croak(__PACKAGE__ . "::setPropertySets: wrong type: " . ref($val_ent) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val_ent,'Bio::MAGE::NameValueType'); } } return $self->{__PROPERTYSETS} = $val; } =item $array_ref = $distanceunit->getPropertySets() The restricted getter method for the C association. Input parameters: none Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getPropertySets { my $self = shift; croak(__PACKAGE__ . "::getPropertySets: arguments passed to getter") if @_; my $val = shift; return $self->{__PROPERTYSETS}; } =item $val = $distanceunit->addPropertySets(@vals) Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association. Input parameters: the list of values C<@vals> to add to the propertySets association. B: submitting a single value is permitted. Return value: the number of items stored in the slot B adding C<@vals> Side effects: none Exceptions: will call C if no input parameters are specified, or if any of the objects in @vals is not an instance of class C =cut sub addPropertySets { my $self = shift; croak(__PACKAGE__ . "::addPropertySets: no arguments passed to adder") unless @_; my @vals = @_; foreach my $val (@vals) { croak(__PACKAGE__ . "::addPropertySets: wrong type: " . ref($val) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val,'Bio::MAGE::NameValueType'); } return push(@{$self->{__PROPERTYSETS}},@vals); } =back sub initialize { my $self = shift; return 1; } =back =cut =head1 SLOTS, ATTRIBUTES, AND ASSOCIATIONS In the Perl implementation of MAGE-OM classes, there are three types of class data members: C, C, and C. =head2 SLOTS This API uses the term C to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes - use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes. Slots are implemented using unified getter/setter methods: =over =item $var = $obj->slot_name(); Retrieves the current value of the slot. =item $new_var = $obj->slot_name($new_var); Store $new_var in the slot - the return value is also $new_var. =item @names = $obj->get_slot_names() Returns the list of all slots in the class. =back B: No data type checking is made for these methods. =head2 ATTRIBUTES AND ASSOCIATIONS The terms C and C indicate data members of the class that were specified directly from the UML model. In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods: =over =item get* Retrieves the current value. B: For associations, if the association has list cardinality, an array reference is returned. B: Ensure that no argument is provided. =item set* Sets the current value, B any existing value. B: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods. B: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class. =item add* B: Only present in associations with list cardinality. Appends a list of objects to any values that may already be stored in the association. B: Ensure that all arguments are of the correct MAGE-OM class. =back =head2 GENERIC METHODS The unified base class of all MAGE-OM classes, C, provides a set of generic methods that will operate on slots, attributes, and associations: =over =item $val = $obj->get_slot($name) =item \@list_ref = $obj->get_slots(@name_list); =item $val = $obj->set_slot($name,$val) =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) See elsewhere in this page for a detailed description of these methods. =back =cut =head1 BUGS Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) =head1 AUTHOR Jason E. Stewart (jasons 'at' cpan 'dot' org) =head1 SEE ALSO perl(1). =cut # all perl modules must be true... 1; Bio-MAGE-20030502.3/MAGE/Measurement/ConcentrationUnit.pm0000644000175000017500000004572210472775113021727 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::ConcentrationUnit # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::ConcentrationUnit; use strict; use Carp; use base qw(Bio::MAGE::Measurement::Unit); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant UNITNAMECV_ML_PER_L => 'mL_per_L'; use constant UNITNAMECV_MM => 'mM'; use constant UNITNAMECV_G_PER_L => 'g_per_L'; use constant UNITNAMECV_FM => 'fM'; use constant UNITNAMECV_PM => 'pM'; use constant UNITNAMECV_MG_PER_ML => 'mg_per_mL'; use constant UNITNAMECV_OTHER => 'other'; use constant UNITNAMECV_UM => 'uM'; use constant UNITNAMECV_M => 'M'; use constant UNITNAMECV_MASS_PER_VOLUME_PERCENT => 'mass_per_volume_percent'; use constant UNITNAMECV_GRAM_PERCENT => 'gram_percent'; use constant UNITNAMECV_MASS_PER_MASS_PERCENT => 'mass_per_mass_percent'; use constant UNITNAMECV_NM => 'nM'; =head1 NAME Bio::MAGE::Measurement::ConcentrationUnit - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::ConcentrationUnit # creating an empty instance my $concentrationunit = Bio::MAGE::Measurement::ConcentrationUnit->new(); # creating an instance with existing data my $concentrationunit = Bio::MAGE::Measurement::ConcentrationUnit->new( unitNameCV=>$unitnamecv_val, unitName=>$unitname_val, propertySets=>\@namevaluetype_list, ); # 'unitNameCV' attribute my $unitNameCV_val = $concentrationunit->unitNameCV(); # getter $concentrationunit->unitNameCV($value); # setter # 'unitName' attribute my $unitName_val = $concentrationunit->unitName(); # getter $concentrationunit->unitName($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $concentrationunit->propertySets(); # getter $concentrationunit->propertySets(\@namevaluetype_list); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: Concentration =cut =head1 INHERITANCE Bio::MAGE::Measurement::ConcentrationUnit has the following superclasses: =over =item * Bio::MAGE::Measurement::Unit =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::ConcentrationUnit]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Measurement::Unit']; $__ATTRIBUTE_NAMES = ['unitNameCV', 'unitName']; $__ASSOCIATION_NAMES = ['propertySets']; $__ASSOCIATIONS = [] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::ConcentrationUnit->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * unitNameCV Sets the value of the C attribute =item * unitName Sets the value of the C attribute (this attribute was inherited from class C). =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item unitNameCV Methods for the C attribute. From the MAGE-OM documentation: =over =item $val = $concentrationunit->setUnitNameCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other =cut sub setUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::setUnitNameCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitNameCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setUnitNameCV: expected one of enum values : M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(M mM uM nM pM fM mg_per_mL mL_per_L g_per_L gram_percent mass_per_volume_percent mass_per_mass_percent other)); return $self->{__UNITNAMECV} = $val; } =item $val = $concentrationunit->getUnitNameCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::getUnitNameCV: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAMECV}; } =back =item unitName Methods for the C attribute. From the MAGE-OM documentation: The name of the unit. =over =item $val = $concentrationunit->setUnitName($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setUnitName { my $self = shift; croak(__PACKAGE__ . "::setUnitName: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitName: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__UNITNAME} = $val; } =item $val = $concentrationunit->getUnitName() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitName { my $self = shift; croak(__PACKAGE__ . "::getUnitName: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAME}; } =back =back =head2 ASSOCIATIONS Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association: =over =item 1 There B be exactly one item in the association, i.e. this is a mandatory data field. =item 0..1 There B be one item in the association, i.e. this is an optional data field. =item 1..N There B be one or more items in the association, i.e. this is a mandatory data field, with list cardinality. =item 0..N There B be one or more items in the association, i.e. this is an optional data field, with list cardinality. =back Bio::MAGE::Measurement::ConcentrationUnit has the following association accessor methods: =over =item propertySets Methods for the C association. From the MAGE-OM documentation: Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper. =over =item $array_ref = $concentrationunit->setPropertySets($array_ref) The restricted setter method for the C association. Input parameters: the value to which the C association will be set : a reference to an array of objects of type C Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$array_ref> is not a reference to an array class C instances =cut sub setPropertySets { my $self = shift; croak(__PACKAGE__ . "::setPropertySets: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setPropertySets: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setPropertySets: expected array reference, got $self") unless (not defined $val) or UNIVERSAL::isa($val,'ARRAY'); if (defined $val) { foreach my $val_ent (@{$val}) { croak(__PACKAGE__ . "::setPropertySets: wrong type: " . ref($val_ent) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val_ent,'Bio::MAGE::NameValueType'); } } return $self->{__PROPERTYSETS} = $val; } =item $array_ref = $concentrationunit->getPropertySets() The restricted getter method for the C association. Input parameters: none Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getPropertySets { my $self = shift; croak(__PACKAGE__ . "::getPropertySets: arguments passed to getter") if @_; my $val = shift; return $self->{__PROPERTYSETS}; } =item $val = $concentrationunit->addPropertySets(@vals) Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association. Input parameters: the list of values C<@vals> to add to the propertySets association. B: submitting a single value is permitted. Return value: the number of items stored in the slot B adding C<@vals> Side effects: none Exceptions: will call C if no input parameters are specified, or if any of the objects in @vals is not an instance of class C =cut sub addPropertySets { my $self = shift; croak(__PACKAGE__ . "::addPropertySets: no arguments passed to adder") unless @_; my @vals = @_; foreach my $val (@vals) { croak(__PACKAGE__ . "::addPropertySets: wrong type: " . ref($val) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val,'Bio::MAGE::NameValueType'); } return push(@{$self->{__PROPERTYSETS}},@vals); } =back sub initialize { my $self = shift; return 1; } =back =cut =head1 SLOTS, ATTRIBUTES, AND ASSOCIATIONS In the Perl implementation of MAGE-OM classes, there are three types of class data members: C, C, and C. =head2 SLOTS This API uses the term C to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes - use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes. Slots are implemented using unified getter/setter methods: =over =item $var = $obj->slot_name(); Retrieves the current value of the slot. =item $new_var = $obj->slot_name($new_var); Store $new_var in the slot - the return value is also $new_var. =item @names = $obj->get_slot_names() Returns the list of all slots in the class. =back B: No data type checking is made for these methods. =head2 ATTRIBUTES AND ASSOCIATIONS The terms C and C indicate data members of the class that were specified directly from the UML model. In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods: =over =item get* Retrieves the current value. B: For associations, if the association has list cardinality, an array reference is returned. B: Ensure that no argument is provided. =item set* Sets the current value, B any existing value. B: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods. B: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class. =item add* B: Only present in associations with list cardinality. Appends a list of objects to any values that may already be stored in the association. B: Ensure that all arguments are of the correct MAGE-OM class. =back =head2 GENERIC METHODS The unified base class of all MAGE-OM classes, C, provides a set of generic methods that will operate on slots, attributes, and associations: =over =item $val = $obj->get_slot($name) =item \@list_ref = $obj->get_slots(@name_list); =item $val = $obj->set_slot($name,$val) =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) See elsewhere in this page for a detailed description of these methods. =back =cut =head1 BUGS Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) =head1 AUTHOR Jason E. Stewart (jasons 'at' cpan 'dot' org) =head1 SEE ALSO perl(1). =cut # all perl modules must be true... 1; Bio-MAGE-20030502.3/MAGE/Measurement/VolumeUnit.pm0000644000175000017500000004414110472775113020362 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::VolumeUnit # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::VolumeUnit; use strict; use Carp; use base qw(Bio::MAGE::Measurement::Unit); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant UNITNAMECV_FL => 'fL'; use constant UNITNAMECV_PL => 'pL'; use constant UNITNAMECV_L => 'L'; use constant UNITNAMECV_CC => 'cc'; use constant UNITNAMECV_OTHER => 'other'; use constant UNITNAMECV_NL => 'nL'; use constant UNITNAMECV_DL => 'dL'; use constant UNITNAMECV_ML => 'mL'; use constant UNITNAMECV_UL => 'uL'; =head1 NAME Bio::MAGE::Measurement::VolumeUnit - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::VolumeUnit # creating an empty instance my $volumeunit = Bio::MAGE::Measurement::VolumeUnit->new(); # creating an instance with existing data my $volumeunit = Bio::MAGE::Measurement::VolumeUnit->new( unitNameCV=>$unitnamecv_val, unitName=>$unitname_val, propertySets=>\@namevaluetype_list, ); # 'unitNameCV' attribute my $unitNameCV_val = $volumeunit->unitNameCV(); # getter $volumeunit->unitNameCV($value); # setter # 'unitName' attribute my $unitName_val = $volumeunit->unitName(); # getter $volumeunit->unitName($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $volumeunit->propertySets(); # getter $volumeunit->propertySets(\@namevaluetype_list); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: Volume =cut =head1 INHERITANCE Bio::MAGE::Measurement::VolumeUnit has the following superclasses: =over =item * Bio::MAGE::Measurement::Unit =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::VolumeUnit]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Measurement::Unit']; $__ATTRIBUTE_NAMES = ['unitNameCV', 'unitName']; $__ASSOCIATION_NAMES = ['propertySets']; $__ASSOCIATIONS = [] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::VolumeUnit->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * unitNameCV Sets the value of the C attribute =item * unitName Sets the value of the C attribute (this attribute was inherited from class C). =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item unitNameCV Methods for the C attribute. From the MAGE-OM documentation: =over =item $val = $volumeunit->setUnitNameCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: mL cc dL L uL nL pL fL other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: mL cc dL L uL nL pL fL other =cut sub setUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::setUnitNameCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitNameCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setUnitNameCV: expected one of enum values : mL cc dL L uL nL pL fL other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(mL cc dL L uL nL pL fL other)); return $self->{__UNITNAMECV} = $val; } =item $val = $volumeunit->getUnitNameCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::getUnitNameCV: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAMECV}; } =back =item unitName Methods for the C attribute. From the MAGE-OM documentation: The name of the unit. =over =item $val = $volumeunit->setUnitName($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setUnitName { my $self = shift; croak(__PACKAGE__ . "::setUnitName: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitName: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__UNITNAME} = $val; } =item $val = $volumeunit->getUnitName() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitName { my $self = shift; croak(__PACKAGE__ . "::getUnitName: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAME}; } =back =back =head2 ASSOCIATIONS Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association: =over =item 1 There B be exactly one item in the association, i.e. this is a mandatory data field. =item 0..1 There B be one item in the association, i.e. this is an optional data field. =item 1..N There B be one or more items in the association, i.e. this is a mandatory data field, with list cardinality. =item 0..N There B be one or more items in the association, i.e. this is an optional data field, with list cardinality. =back Bio::MAGE::Measurement::VolumeUnit has the following association accessor methods: =over =item propertySets Methods for the C association. From the MAGE-OM documentation: Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper. =over =item $array_ref = $volumeunit->setPropertySets($array_ref) The restricted setter method for the C association. Input parameters: the value to which the C association will be set : a reference to an array of objects of type C Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$array_ref> is not a reference to an array class C instances =cut sub setPropertySets { my $self = shift; croak(__PACKAGE__ . "::setPropertySets: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setPropertySets: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setPropertySets: expected array reference, got $self") unless (not defined $val) or UNIVERSAL::isa($val,'ARRAY'); if (defined $val) { foreach my $val_ent (@{$val}) { croak(__PACKAGE__ . "::setPropertySets: wrong type: " . ref($val_ent) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val_ent,'Bio::MAGE::NameValueType'); } } return $self->{__PROPERTYSETS} = $val; } =item $array_ref = $volumeunit->getPropertySets() The restricted getter method for the C association. Input parameters: none Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getPropertySets { my $self = shift; croak(__PACKAGE__ . "::getPropertySets: arguments passed to getter") if @_; my $val = shift; return $self->{__PROPERTYSETS}; } =item $val = $volumeunit->addPropertySets(@vals) Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association. Input parameters: the list of values C<@vals> to add to the propertySets association. B: submitting a single value is permitted. Return value: the number of items stored in the slot B adding C<@vals> Side effects: none Exceptions: will call C if no input parameters are specified, or if any of the objects in @vals is not an instance of class C =cut sub addPropertySets { my $self = shift; croak(__PACKAGE__ . "::addPropertySets: no arguments passed to adder") unless @_; my @vals = @_; foreach my $val (@vals) { croak(__PACKAGE__ . "::addPropertySets: wrong type: " . ref($val) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val,'Bio::MAGE::NameValueType'); } return push(@{$self->{__PROPERTYSETS}},@vals); } =back sub initialize { my $self = shift; return 1; } =back =cut =head1 SLOTS, ATTRIBUTES, AND ASSOCIATIONS In the Perl implementation of MAGE-OM classes, there are three types of class data members: C, C, and C. =head2 SLOTS This API uses the term C to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes - use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes. Slots are implemented using unified getter/setter methods: =over =item $var = $obj->slot_name(); Retrieves the current value of the slot. =item $new_var = $obj->slot_name($new_var); Store $new_var in the slot - the return value is also $new_var. =item @names = $obj->get_slot_names() Returns the list of all slots in the class. =back B: No data type checking is made for these methods. =head2 ATTRIBUTES AND ASSOCIATIONS The terms C and C indicate data members of the class that were specified directly from the UML model. In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods: =over =item get* Retrieves the current value. B: For associations, if the association has list cardinality, an array reference is returned. B: Ensure that no argument is provided. =item set* Sets the current value, B any existing value. B: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods. B: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class. =item add* B: Only present in associations with list cardinality. Appends a list of objects to any values that may already be stored in the association. B: Ensure that all arguments are of the correct MAGE-OM class. =back =head2 GENERIC METHODS The unified base class of all MAGE-OM classes, C, provides a set of generic methods that will operate on slots, attributes, and associations: =over =item $val = $obj->get_slot($name) =item \@list_ref = $obj->get_slots(@name_list); =item $val = $obj->set_slot($name,$val) =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) See elsewhere in this page for a detailed description of these methods. =back =cut =head1 BUGS Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) =head1 AUTHOR Jason E. Stewart (jasons 'at' cpan 'dot' org) =head1 SEE ALSO perl(1). =cut # all perl modules must be true... 1; Bio-MAGE-20030502.3/MAGE/Measurement/TimeUnit.pm0000644000175000017500000004413210472775113020011 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::TimeUnit # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::TimeUnit; use strict; use Carp; use base qw(Bio::MAGE::Measurement::Unit); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant UNITNAMECV_MONTHS => 'months'; use constant UNITNAMECV_D => 'd'; use constant UNITNAMECV_YEARS => 'years'; use constant UNITNAMECV_OTHER => 'other'; use constant UNITNAMECV_M => 'm'; use constant UNITNAMECV_S => 's'; use constant UNITNAMECV_H => 'h'; use constant UNITNAMECV_US => 'us'; use constant UNITNAMECV_WEEKS => 'weeks'; =head1 NAME Bio::MAGE::Measurement::TimeUnit - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::TimeUnit # creating an empty instance my $timeunit = Bio::MAGE::Measurement::TimeUnit->new(); # creating an instance with existing data my $timeunit = Bio::MAGE::Measurement::TimeUnit->new( unitNameCV=>$unitnamecv_val, unitName=>$unitname_val, propertySets=>\@namevaluetype_list, ); # 'unitNameCV' attribute my $unitNameCV_val = $timeunit->unitNameCV(); # getter $timeunit->unitNameCV($value); # setter # 'unitName' attribute my $unitName_val = $timeunit->unitName(); # getter $timeunit->unitName($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $timeunit->propertySets(); # getter $timeunit->propertySets(\@namevaluetype_list); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: Time =cut =head1 INHERITANCE Bio::MAGE::Measurement::TimeUnit has the following superclasses: =over =item * Bio::MAGE::Measurement::Unit =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::TimeUnit]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Measurement::Unit']; $__ATTRIBUTE_NAMES = ['unitNameCV', 'unitName']; $__ASSOCIATION_NAMES = ['propertySets']; $__ASSOCIATIONS = [] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::TimeUnit->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * unitNameCV Sets the value of the C attribute =item * unitName Sets the value of the C attribute (this attribute was inherited from class C). =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item unitNameCV Methods for the C attribute. From the MAGE-OM documentation: =over =item $val = $timeunit->setUnitNameCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: years months weeks d h m s us other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: years months weeks d h m s us other =cut sub setUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::setUnitNameCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitNameCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setUnitNameCV: expected one of enum values : years months weeks d h m s us other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(years months weeks d h m s us other)); return $self->{__UNITNAMECV} = $val; } =item $val = $timeunit->getUnitNameCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::getUnitNameCV: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAMECV}; } =back =item unitName Methods for the C attribute. From the MAGE-OM documentation: The name of the unit. =over =item $val = $timeunit->setUnitName($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setUnitName { my $self = shift; croak(__PACKAGE__ . "::setUnitName: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitName: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__UNITNAME} = $val; } =item $val = $timeunit->getUnitName() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitName { my $self = shift; croak(__PACKAGE__ . "::getUnitName: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAME}; } =back =back =head2 ASSOCIATIONS Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association: =over =item 1 There B be exactly one item in the association, i.e. this is a mandatory data field. =item 0..1 There B be one item in the association, i.e. this is an optional data field. =item 1..N There B be one or more items in the association, i.e. this is a mandatory data field, with list cardinality. =item 0..N There B be one or more items in the association, i.e. this is an optional data field, with list cardinality. =back Bio::MAGE::Measurement::TimeUnit has the following association accessor methods: =over =item propertySets Methods for the C association. From the MAGE-OM documentation: Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper. =over =item $array_ref = $timeunit->setPropertySets($array_ref) The restricted setter method for the C association. Input parameters: the value to which the C association will be set : a reference to an array of objects of type C Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$array_ref> is not a reference to an array class C instances =cut sub setPropertySets { my $self = shift; croak(__PACKAGE__ . "::setPropertySets: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setPropertySets: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setPropertySets: expected array reference, got $self") unless (not defined $val) or UNIVERSAL::isa($val,'ARRAY'); if (defined $val) { foreach my $val_ent (@{$val}) { croak(__PACKAGE__ . "::setPropertySets: wrong type: " . ref($val_ent) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val_ent,'Bio::MAGE::NameValueType'); } } return $self->{__PROPERTYSETS} = $val; } =item $array_ref = $timeunit->getPropertySets() The restricted getter method for the C association. Input parameters: none Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getPropertySets { my $self = shift; croak(__PACKAGE__ . "::getPropertySets: arguments passed to getter") if @_; my $val = shift; return $self->{__PROPERTYSETS}; } =item $val = $timeunit->addPropertySets(@vals) Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association. Input parameters: the list of values C<@vals> to add to the propertySets association. B: submitting a single value is permitted. Return value: the number of items stored in the slot B adding C<@vals> Side effects: none Exceptions: will call C if no input parameters are specified, or if any of the objects in @vals is not an instance of class C =cut sub addPropertySets { my $self = shift; croak(__PACKAGE__ . "::addPropertySets: no arguments passed to adder") unless @_; my @vals = @_; foreach my $val (@vals) { croak(__PACKAGE__ . "::addPropertySets: wrong type: " . ref($val) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val,'Bio::MAGE::NameValueType'); } return push(@{$self->{__PROPERTYSETS}},@vals); } =back sub initialize { my $self = shift; return 1; } =back =cut =head1 SLOTS, ATTRIBUTES, AND ASSOCIATIONS In the Perl implementation of MAGE-OM classes, there are three types of class data members: C, C, and C. =head2 SLOTS This API uses the term C to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes - use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes. Slots are implemented using unified getter/setter methods: =over =item $var = $obj->slot_name(); Retrieves the current value of the slot. =item $new_var = $obj->slot_name($new_var); Store $new_var in the slot - the return value is also $new_var. =item @names = $obj->get_slot_names() Returns the list of all slots in the class. =back B: No data type checking is made for these methods. =head2 ATTRIBUTES AND ASSOCIATIONS The terms C and C indicate data members of the class that were specified directly from the UML model. In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods: =over =item get* Retrieves the current value. B: For associations, if the association has list cardinality, an array reference is returned. B: Ensure that no argument is provided. =item set* Sets the current value, B any existing value. B: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods. B: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class. =item add* B: Only present in associations with list cardinality. Appends a list of objects to any values that may already be stored in the association. B: Ensure that all arguments are of the correct MAGE-OM class. =back =head2 GENERIC METHODS The unified base class of all MAGE-OM classes, C, provides a set of generic methods that will operate on slots, attributes, and associations: =over =item $val = $obj->get_slot($name) =item \@list_ref = $obj->get_slots(@name_list); =item $val = $obj->set_slot($name,$val) =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) See elsewhere in this page for a detailed description of these methods. =back =cut =head1 BUGS Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) =head1 AUTHOR Jason E. Stewart (jasons 'at' cpan 'dot' org) =head1 SEE ALSO perl(1). =cut # all perl modules must be true... 1; Bio-MAGE-20030502.3/MAGE/Measurement/MassUnit.pm0000644000175000017500000004376610472775113020032 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::MassUnit # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::MassUnit; use strict; use Carp; use base qw(Bio::MAGE::Measurement::Unit); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant UNITNAMECV_FG => 'fg'; use constant UNITNAMECV_NG => 'ng'; use constant UNITNAMECV_UG => 'ug'; use constant UNITNAMECV_PG => 'pg'; use constant UNITNAMECV_KG => 'kg'; use constant UNITNAMECV_OTHER => 'other'; use constant UNITNAMECV_MG => 'mg'; use constant UNITNAMECV_G => 'g'; =head1 NAME Bio::MAGE::Measurement::MassUnit - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::MassUnit # creating an empty instance my $massunit = Bio::MAGE::Measurement::MassUnit->new(); # creating an instance with existing data my $massunit = Bio::MAGE::Measurement::MassUnit->new( unitNameCV=>$unitnamecv_val, unitName=>$unitname_val, propertySets=>\@namevaluetype_list, ); # 'unitNameCV' attribute my $unitNameCV_val = $massunit->unitNameCV(); # getter $massunit->unitNameCV($value); # setter # 'unitName' attribute my $unitName_val = $massunit->unitName(); # getter $massunit->unitName($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $massunit->propertySets(); # getter $massunit->propertySets(\@namevaluetype_list); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: Mass =cut =head1 INHERITANCE Bio::MAGE::Measurement::MassUnit has the following superclasses: =over =item * Bio::MAGE::Measurement::Unit =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::MassUnit]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Measurement::Unit']; $__ATTRIBUTE_NAMES = ['unitNameCV', 'unitName']; $__ASSOCIATION_NAMES = ['propertySets']; $__ASSOCIATIONS = [] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::MassUnit->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * unitNameCV Sets the value of the C attribute =item * unitName Sets the value of the C attribute (this attribute was inherited from class C). =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item unitNameCV Methods for the C attribute. From the MAGE-OM documentation: =over =item $val = $massunit->setUnitNameCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: kg g mg ug ng pg fg other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: kg g mg ug ng pg fg other =cut sub setUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::setUnitNameCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitNameCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setUnitNameCV: expected one of enum values : kg g mg ug ng pg fg other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(kg g mg ug ng pg fg other)); return $self->{__UNITNAMECV} = $val; } =item $val = $massunit->getUnitNameCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitNameCV { my $self = shift; croak(__PACKAGE__ . "::getUnitNameCV: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAMECV}; } =back =item unitName Methods for the C attribute. From the MAGE-OM documentation: The name of the unit. =over =item $val = $massunit->setUnitName($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setUnitName { my $self = shift; croak(__PACKAGE__ . "::setUnitName: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setUnitName: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__UNITNAME} = $val; } =item $val = $massunit->getUnitName() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getUnitName { my $self = shift; croak(__PACKAGE__ . "::getUnitName: arguments passed to getter") if @_; my $val = shift; return $self->{__UNITNAME}; } =back =back =head2 ASSOCIATIONS Associations are references to other classes. Associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that maybe included in the association: =over =item 1 There B be exactly one item in the association, i.e. this is a mandatory data field. =item 0..1 There B be one item in the association, i.e. this is an optional data field. =item 1..N There B be one or more items in the association, i.e. this is a mandatory data field, with list cardinality. =item 0..N There B be one or more items in the association, i.e. this is an optional data field, with list cardinality. =back Bio::MAGE::Measurement::MassUnit has the following association accessor methods: =over =item propertySets Methods for the C association. From the MAGE-OM documentation: Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper. =over =item $array_ref = $massunit->setPropertySets($array_ref) The restricted setter method for the C association. Input parameters: the value to which the C association will be set : a reference to an array of objects of type C Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$array_ref> is not a reference to an array class C instances =cut sub setPropertySets { my $self = shift; croak(__PACKAGE__ . "::setPropertySets: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setPropertySets: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setPropertySets: expected array reference, got $self") unless (not defined $val) or UNIVERSAL::isa($val,'ARRAY'); if (defined $val) { foreach my $val_ent (@{$val}) { croak(__PACKAGE__ . "::setPropertySets: wrong type: " . ref($val_ent) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val_ent,'Bio::MAGE::NameValueType'); } } return $self->{__PROPERTYSETS} = $val; } =item $array_ref = $massunit->getPropertySets() The restricted getter method for the C association. Input parameters: none Return value: the current value of the C association : a reference to an array of objects of type C Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getPropertySets { my $self = shift; croak(__PACKAGE__ . "::getPropertySets: arguments passed to getter") if @_; my $val = shift; return $self->{__PROPERTYSETS}; } =item $val = $massunit->addPropertySets(@vals) Because the propertySets association has list cardinality, it may store more than one value. This method adds the current list of objects in the propertySets association. Input parameters: the list of values C<@vals> to add to the propertySets association. B: submitting a single value is permitted. Return value: the number of items stored in the slot B adding C<@vals> Side effects: none Exceptions: will call C if no input parameters are specified, or if any of the objects in @vals is not an instance of class C =cut sub addPropertySets { my $self = shift; croak(__PACKAGE__ . "::addPropertySets: no arguments passed to adder") unless @_; my @vals = @_; foreach my $val (@vals) { croak(__PACKAGE__ . "::addPropertySets: wrong type: " . ref($val) . " expected Bio::MAGE::NameValueType") unless UNIVERSAL::isa($val,'Bio::MAGE::NameValueType'); } return push(@{$self->{__PROPERTYSETS}},@vals); } =back sub initialize { my $self = shift; return 1; } =back =cut =head1 SLOTS, ATTRIBUTES, AND ASSOCIATIONS In the Perl implementation of MAGE-OM classes, there are three types of class data members: C, C, and C. =head2 SLOTS This API uses the term C to indicate a data member of the class that was not present in the UML model and is used for mainly internal purposes - use only if you understand the inner workings of the API. Most often slots are used by generic methods such as those in the XML writing and reading classes. Slots are implemented using unified getter/setter methods: =over =item $var = $obj->slot_name(); Retrieves the current value of the slot. =item $new_var = $obj->slot_name($new_var); Store $new_var in the slot - the return value is also $new_var. =item @names = $obj->get_slot_names() Returns the list of all slots in the class. =back B: No data type checking is made for these methods. =head2 ATTRIBUTES AND ASSOCIATIONS The terms C and C indicate data members of the class that were specified directly from the UML model. In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods: =over =item get* Retrieves the current value. B: For associations, if the association has list cardinality, an array reference is returned. B: Ensure that no argument is provided. =item set* Sets the current value, B any existing value. B: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods. B: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class, otherwise ensure that there is a single argument of the correct MAGE-OM class. =item add* B: Only present in associations with list cardinality. Appends a list of objects to any values that may already be stored in the association. B: Ensure that all arguments are of the correct MAGE-OM class. =back =head2 GENERIC METHODS The unified base class of all MAGE-OM classes, C, provides a set of generic methods that will operate on slots, attributes, and associations: =over =item $val = $obj->get_slot($name) =item \@list_ref = $obj->get_slots(@name_list); =item $val = $obj->set_slot($name,$val) =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) See elsewhere in this page for a detailed description of these methods. =back =cut =head1 BUGS Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) =head1 AUTHOR Jason E. Stewart (jasons 'at' cpan 'dot' org) =head1 SEE ALSO perl(1). =cut # all perl modules must be true... 1; Bio-MAGE-20030502.3/MAGE/Measurement/Measurement.pm0000644000175000017500000006152310472775113020543 0ustar jasonsjasons############################## # # Bio::MAGE::Measurement::Measurement # ############################## # C O P Y R I G H T N O T I C E # Copyright (c) 2001-2006 by: # * The MicroArray Gene Expression Database Society (MGED) # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. package Bio::MAGE::Measurement::Measurement; use strict; use Carp; use base qw(Bio::MAGE::Extendable); use Bio::MAGE::Association; use vars qw($__ASSOCIATIONS $__CLASS_NAME $__PACKAGE_NAME $__SUBCLASSES $__SUPERCLASSES $__ATTRIBUTE_NAMES $__ASSOCIATION_NAMES ); use constant TYPE_CHANGE => 'change'; use constant KINDCV_OTHER => 'other'; use constant KINDCV_CONCENTRATION => 'concentration'; use constant KINDCV_MASS => 'mass'; use constant KINDCV_VOLUME => 'volume'; use constant TYPE_ABSOLUTE => 'absolute'; use constant KINDCV_TEMPERATURE => 'temperature'; use constant KINDCV_QUANTITY => 'quantity'; use constant KINDCV_TIME => 'time'; use constant KINDCV_DISTANCE => 'distance'; =head1 NAME Bio::MAGE::Measurement::Measurement - Class for the MAGE-OM API =head1 SYNOPSIS use Bio::MAGE::Measurement::Measurement # creating an empty instance my $measurement = Bio::MAGE::Measurement::Measurement->new(); # creating an instance with existing data my $measurement = Bio::MAGE::Measurement::Measurement->new( otherKind=>$otherkind_val, value=>$value_val, type=>$type_val, kindCV=>$kindcv_val, propertySets=>\@namevaluetype_list, unit=>$unit_ref, ); # 'otherKind' attribute my $otherKind_val = $measurement->otherKind(); # getter $measurement->otherKind($value); # setter # 'value' attribute my $value_val = $measurement->value(); # getter $measurement->value($value); # setter # 'type' attribute my $type_val = $measurement->type(); # getter $measurement->type($value); # setter # 'kindCV' attribute my $kindCV_val = $measurement->kindCV(); # getter $measurement->kindCV($value); # setter # 'propertySets' association my $namevaluetype_array_ref = $measurement->propertySets(); # getter $measurement->propertySets(\@namevaluetype_list); # setter # 'unit' association my $unit_ref = $measurement->unit(); # getter $measurement->unit($unit_ref); # setter =head1 DESCRIPTION From the MAGE-OM documentation for the C class: A Measurement is a quantity with a unit. =cut =head1 INHERITANCE Bio::MAGE::Measurement::Measurement has the following superclasses: =over =item * Bio::MAGE::Extendable =back =cut BEGIN { $__CLASS_NAME = q[Bio::MAGE::Measurement::Measurement]; $__PACKAGE_NAME = q[Measurement]; $__SUBCLASSES = []; $__SUPERCLASSES = ['Bio::MAGE::Extendable']; $__ATTRIBUTE_NAMES = ['otherKind', 'value', 'type', 'kindCV']; $__ASSOCIATION_NAMES = ['propertySets', 'unit']; $__ASSOCIATIONS = [ 'unit', bless( { '__SELF' => bless( { '__NAME' => undef, '__IS_REF' => 0, '__CARDINALITY' => '1', '__DOCUMENTATION' => 'The Unit associated with the Measurement.', '__CLASS_NAME' => 'Measurement', '__RANK' => undef, '__ORDERED' => undef }, 'Bio::MAGE::Association::End' ), '__OTHER' => bless( { '__NAME' => 'unit', '__IS_REF' => 1, '__CARDINALITY' => '0..1', '__DOCUMENTATION' => 'The Unit associated with the Measurement.', '__CLASS_NAME' => 'Unit', '__RANK' => '1', '__ORDERED' => 0 }, 'Bio::MAGE::Association::End' ) }, 'Bio::MAGE::Association' ) ] } =head1 CLASS METHODS The following methods can all be called without first having an instance of the class via the Bio::MAGE::Measurement::Measurement->methodname() syntax. =over =item new() =item new(%args) The object constructor C accepts the following optional named-value style arguments: =over =item * otherKind Sets the value of the C attribute =item * value Sets the value of the C attribute =item * type Sets the value of the C attribute =item * kindCV Sets the value of the C attribute =item * propertySets Sets the value of the C association (this association was inherited from class C). The value must be of type: array of C. =item * unit Sets the value of the C association The value must be of type: instance of C. =back =item $obj = class->new(%parameters) The C method is the class constructor. B: if given a list of name/value parameters the corresponding slots, attributes, or associations will have their initial values set by the constructor. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item @names = class->get_slot_names() The C method is used to retrieve the name of all slots defined in a given class. B: the list of names does not include attribute or association names. B: A list of the names of all slots defined for this class. B: none =cut # # code for get_slot_names() inherited from Base.pm # =item @name_list = get_attribute_names() returns the list of attribute data members for this class. =cut # # code for get_attribute_names() inherited from Base.pm # =item @name_list = get_association_names() returns the list of association data members for this class. =cut # # code for get_association_names() inherited from Base.pm # =item @class_list = get_superclasses() returns the list of superclasses for this class. =cut # # code for get_superclasses() inherited from Base.pm # =item @class_list = get_subclasses() returns the list of subclasses for this class. =cut # # code for get_subclasses() inherited from Base.pm # =item $name = class_name() Returns the full class name for this class. =cut # # code for class_name() inherited from Base.pm # =item $package_name = package_name() Returns the base package name (i.e. no 'namespace::') of the package that contains this class. =cut # # code for package_name() inherited from Base.pm # =item %assns = associations() returns the association meta-information in a hash where the keys are the association names and the values are C objects that provide the meta-information for the association. =cut # # code for associations() inherited from Base.pm # =back =head1 INSTANCE METHODS =item $obj_copy = $obj->new() When invoked with an existing object reference and not a class name, the C method acts as a copy constructor - with the new object's initial values set to be those of the existing object. B: No input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied. B: It returns a reference to an object of the class. B: It invokes the C method if it is defined by the class. =cut # # code for new() inherited from Base.pm # =item $obj->set_slots(%parameters) =item $obj->set_slots(\@name_list, \@value_list) The C method is used to set a number of slots at the same time. It has two different invocation methods. The first takes a named parameter list, and the second takes two array references. B: none B: will call C if a slot_name is used that the class does not define. =cut # # code for set_slots() inherited from Base.pm # =item @obj_list = $obj->get_slots(@name_list) The C method is used to get the values of a number of slots at the same time. B: a list of instance objects B: none =cut # # code for get_slots() inherited from Base.pm # =item $val = $obj->set_slot($name,$val) The C method sets the slot C<$name> to the value C<$val> B: the new value of the slot, i.e. C<$val> B: none =cut # # code for set_slot() inherited from Base.pm # =item $val = $obj->get_slot($name) The C method is used to get the values of a number of slots at the same time. B: a single slot value, or undef if the slot has not been initialized. B: none =cut # # code for get_slot() inherited from Base.pm # =head2 ATTRIBUTES Attributes are simple data types that belong to a single instance of a class. In the Perl implementation of the MAGE-OM classes, the interface to attributes is implemented using separate setter and getter methods for each attribute. C has the following attribute accessor methods: =over =item otherKind Methods for the C attribute. From the MAGE-OM documentation: Name of the controlled vocabulary if it isn't one of the Unit subclasses. =over =item $val = $measurement->setOtherKind($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setOtherKind { my $self = shift; croak(__PACKAGE__ . "::setOtherKind: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setOtherKind: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__OTHERKIND} = $val; } =item $val = $measurement->getOtherKind() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getOtherKind { my $self = shift; croak(__PACKAGE__ . "::getOtherKind: arguments passed to getter") if @_; my $val = shift; return $self->{__OTHERKIND}; } =back =item value Methods for the C attribute. From the MAGE-OM documentation: The value of the measurement. kindCV (and otherKind) determine with Unit the datatype of value. =over =item $val = $measurement->setValue($val) The restricted setter method for the C attribute. Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified =cut sub setValue { my $self = shift; croak(__PACKAGE__ . "::setValue: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setValue: too many arguments passed to setter") if @_ > 1; my $val = shift; return $self->{__VALUE} = $val; } =item $val = $measurement->getValue() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getValue { my $self = shift; croak(__PACKAGE__ . "::getValue: arguments passed to getter") if @_; my $val = shift; return $self->{__VALUE}; } =back =item type Methods for the C attribute. From the MAGE-OM documentation: The type of measurement, for instance if the measurement is five feet, it can be either absolute (five feet tall) or change (five feet further along). =over =item $val = $measurement->setType($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: absolute change Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: absolute change =cut sub setType { my $self = shift; croak(__PACKAGE__ . "::setType: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setType: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setType: expected one of enum values : absolute change, got $val") unless (not defined $val) or (grep {$val eq $_} qw(absolute change)); return $self->{__TYPE} = $val; } =item $val = $measurement->getType() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C. Side effects: none Exceptions: will call C if any input parameters are specified =cut sub getType { my $self = shift; croak(__PACKAGE__ . "::getType: arguments passed to getter") if @_; my $val = shift; return $self->{__TYPE}; } =back =item kindCV Methods for the C attribute. From the MAGE-OM documentation: One of the enumeration values to determine the controlled vocabulary of the value. =over =item $val = $measurement->setKindCV($val) The restricted setter method for the C attribute. C is an B attribute - it can only be set to C or one of the following values: time distance temperature quantity mass volume concentration other Input parameters: the value to which the C attribute will be set Return value: the current value of the C attribute Side effects: none Exceptions: will call C if no input parameters are specified, or if too many input parameters are specified, or if C<$val> is not one of the accepted enumeration values: time distance temperature quantity mass volume concentration other =cut sub setKindCV { my $self = shift; croak(__PACKAGE__ . "::setKindCV: no arguments passed to setter") unless @_; croak(__PACKAGE__ . "::setKindCV: too many arguments passed to setter") if @_ > 1; my $val = shift; croak(__PACKAGE__ . "::setKindCV: expected one of enum values : time distance temperature quantity mass volume concentration other, got $val") unless (not defined $val) or (grep {$val eq $_} qw(time distance temperature quantity mass volume concentration other)); return $self->{__KINDCV} = $val; } =item $val = $measurement->getKindCV() The restricted getter method for the C attribute. Input parameters: none Return value: the current value of the C attribute : an instance of type C