MAGE::...lueType(3pm)

MAGE::...lueType πŸ’…

User Contributed Perl Documentation Β· MAGE::...lueType(3pm)

okay bestie sit DOWN because we're doing Bio::MAGE::NameValueType today and it's giving very "small class, big energy" πŸ’–


✨ NAME ✨

Bio::MAGE::NameValueType β€” the Class for the MAGE-OM API, no cap πŸŽ€


🌸 SYNOPSIS 🌸

here's the whole vibe in code form, copy it exactly, don't freestyle it:

use Bio::MAGE::NameValueType

# creating an empty instance
my $namevaluetype = Bio::MAGE::NameValueType->new();

# creating an instance with existing data
my $namevaluetype = Bio::MAGE::NameValueType->new(
      value=>$value_val,
      name=>$name_val,
      type=>$type_val,
      propertySets=>\@namevaluetype_list,
);

# 'value' attribute
my $value_val = $namevaluetype->value(); # getter
$namevaluetype->value($value); # setter

# 'name' attribute
my $name_val = $namevaluetype->name(); # getter
$namevaluetype->name($value); # setter

# 'type' attribute
my $type_val = $namevaluetype->type(); # getter
$namevaluetype->type($value); # setter

# 'propertySets' association
my $namevaluetype_array_ref = $namevaluetype->propertySets(); # getter
$namevaluetype->propertySets(\@namevaluetype_list); # setter

πŸ¦‹ DESCRIPTION πŸ¦‹

straight from the MAGE-OM documentation for the "NameValueType" class, and I'm quoting this verbatim because it ate:

A tuple designed to store data, keyed by a name and type.

that's it. that's the whole personality. a little keyed tuple just doing its thing 🫢


πŸ’œ INHERITANCE πŸ’œ

ngl bestie, this section is literally empty in the source. nothing here. we move. πŸ™ˆ


πŸ‘‘ CLASS METHODS πŸ‘‘

the way that all of these can be called without ever having an instance of the class first?? main character behavior fr fr. you just hit them with the Bio::MAGE::NameValueType->methodname() syntax and you're good πŸ’…

🌟 new()

🌟 new(%args)

the object constructor new() accepts the following optional named-value style arguments β€” and yes, they're all optional, she's flexible:

  • value β€” Sets the value of the "value" attribute ✨
  • name β€” Sets the value of the "name" attribute ✨
  • type β€” Sets the value of the "type" attribute ✨
  • propertySets β€” Sets the value of the "propertySets" association
The value must be of type: array of "Bio::MAGE::NameValueType".

🌟 $obj = class->new(%parameters)

The "new()" method is the class constructor. the blueprint. the origin story πŸ’–

Parameters: if you hand her a list of name/value parameters, the corresponding slots, attributes, or associations will have their initial values set by the constructor.

Return value: she returns a reference to an object of the class. slay.

Side effects: it invokes the "initialize()" method if it is defined by the class. so like, if your class defines it, it's happening πŸ”₯


🌟 @names = class->get_slot_names()

The "get_slot_names()" method is used to retrieve the name of all slots defined in a given class. a lil roll call πŸ“‹

NOTE: the list of names does not include attribute or association names. like, at all. don't come for me.

Return value: A list of the names of all slots defined for this class.

Side effects: none 🌸


🌟 @name_list = get_attribute_names()

returns the list of attribute data members for this class. just the names, bestie, just the names πŸŽ€


🌟 @name_list = get_association_names()

returns the list of association data members for this class. the association girlies get their own list πŸ’œ


🌟 @class_list = get_superclasses()

returns the list of superclasses for this class. who's above her in the family tree 🌳


🌟 @class_list = get_subclasses()

returns the list of subclasses for this class. who's below her. her little descendants 🧚


🌟 $name = class_name()

Returns the full class name for this class. government name and everything ⭐


🌟 $package_name = package_name()

Returns the base package name (i.e. no 'namespace::') of the package that contains this class. she's giving "first name only, we're not doing formalities" 😌


🌟 %assns = associations()

returns the association meta-information in a hash where the keys are the association names and the values are "Association" objects that provide the meta-information for the association. it's giving receipts for every association, organized πŸ—‚οΈ


okay and that's part 1, don't go anywhere, more is coming πŸ’–

πŸ’… INSTANCE METHODS πŸ’…

Okay bestie, this is where it gets good. These are the methods you call on an actual object, not on the class. Let's go 🫢


  • $obj_copy = $obj->new() β€” so when you hit up new() on an existing object reference instead of a class name, it switches gears and becomes a copy constructor πŸͺ„ β€” the new object's initial values get set to whatever the old object's values were. Iconic.

Parameters: fr fr, no input parameters are used in the copy constructor. The initial values come straight off the object you're copying. No notes πŸ’…

Return value: it hands you back a reference to an object of the class.

Side effects: it invokes the initialize() method if the class defines one. So yeah, that happens.

  • $obj->set_slots(%parameters)
  • $obj->set_slots(\@name_list, \@value_list)

The set_slots() method is your "set a whole bunch of slots at once" bestie. It's got two whole invocation styles: the first one takes a named parameter list, and the second one takes two array references. Pick your fighter.

Return value: none. Nothing. Nada.

Side effects: it will call croak() if you use a slot_name that the class doesn't define. So don't do that πŸ™ˆ

  • @obj_list = $obj->get_slots(@name_list)

The get_slots() method grabs the values of a bunch of slots all at the same time. Efficiency queen πŸ‘‘

Return value: a list of instance objects

Side effects: none ✨

  • $val = $obj->set_slot($name,$val)

The set_slot() method sets the slot $name to the value $val.

Return value: the new value of the slot, i.e. $val

Side effects: none

  • $val = $obj->get_slot($name)

The get_slot() method is used to get the values of a number of slots at the same time.

Return value: a single slot value, or undef if the slot has not been initialized 😭

Side effects: none


✨ ATTRIBUTES ✨

So, attributes are like… simple data types that belong to one single instance of a class. Very exclusive, very main character energy. In the Perl implementation of the MAGE-OM classes, you talk to attributes through separate setter and getter methods for each one β€” no shared entryway, everyone gets their own door πŸšͺ

Bio::MAGE::NameValueType has the following attribute accessor methods:

🌸 value

Methods for the value attribute.

From the MAGE-OM documentation:

The value of the name.
  • $val = $namevaluetype->setValue($val) β€” the restricted setter for the value attribute.

Input parameters: the value to which the value attribute will be set

Return value: the current value of the value attribute

Side effects: none

Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified πŸ’€

  • $val = $namevaluetype->getValue() β€” the restricted getter for the value attribute.

Input parameters: none

Return value: the current value of the value attribute

Side effects: none

Exceptions: will call croak() if any input parameters are specified

🌸 name

Methods for the name attribute.

From the MAGE-OM documentation:

The name of the key.
  • $val = $namevaluetype->setName($val) β€” the restricted setter for the name attribute.

Input parameters: the value to which the name attribute will be set

Return value: the current value of the name attribute

Side effects: none

Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified

  • $val = $namevaluetype->getName() β€” the restricted getter for the name attribute.

Input parameters: none

Return value: the current value of the name attribute

Side effects: none

Exceptions: will call croak() if any input parameters are specified

🌸 type

Methods for the type attribute.

From the MAGE-OM documentation:

The type of the key.
  • $val = $namevaluetype->setType($val) β€” the restricted setter for the type attribute.

Input parameters: the value to which the type attribute will be set

Return value: the current value of the type attribute

Side effects: none

Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified

  • $val = $namevaluetype->getType() β€” the restricted getter for the type attribute.

Input parameters: none

Return value: the current value of the type attribute

Side effects: none

Exceptions: will call croak() if any input parameters are specified


πŸ¦‹ ASSOCIATIONS πŸ¦‹

Associations are references to other classes. It's giving networking, it's giving "my friends know your friends". In MAGE-OM, an association has a cardinality that decides the minimum and maximum number of instances of the 'other' class that may be included in the association:

  1. There must be exactly one item in the association, i.e. this is a mandatory data field.
  2. 0..1

There may be one item in the association, i.e. this is an optional data field.

  1. 1..N

There must be one or more items in the association, i.e. this is a mandatory data field, with list cardinality.

  1. 0..N

There may be one or more items in the association, i.e. this is an optional data field, with list cardinality.

Bio::MAGE::NameValueType has the following association accessor methods:

πŸ’œ propertySets

Methods for the propertySets association.

From the MAGE-OM documentation:

Allows nested specification of name/value pairs
  • $array_ref = $namevaluetype->setPropertySets($array_ref) β€” the restricted setter for the propertySets association.

Input parameters: the value to which the propertySets association will be set : a reference to an array of objects of type Bio::MAGE::NameValueType

Return value: the current value of the propertySets association : a reference to an array of objects of type Bio::MAGE::NameValueType

Side effects: none

Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $array_ref is not a reference to an array class Bio::MAGE::NameValueType instances 😀

  • $array_ref = $namevaluetype->getPropertySets() β€” the restricted getter for the propertySets association.

Input parameters: none

Return value: the current value of the propertySets association : a reference to an array of objects of type Bio::MAGE::NameValueType

Side effects: none

Exceptions: will call croak() if any input parameters are specified

  • $val = $namevaluetype->addPropertySets(@vals) β€” okay so because the propertySets association has list cardinality, it can hold more than one value (she contains multitudes πŸ’…). This method adds the current list of objects in the propertySets association.

Input parameters: the list of values @vals to add to the propertySets association. NOTE: submitting a single value is permitted 🫢

Return value: the number of items stored in the slot after adding @vals

Side effects: none

Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not an instance of class Bio::MAGE::NameValueType

And then there's this lil guy hanging out at the end:

sub initialize {

  my $self = shift;
  return 1;

}

πŸŽ€ SLOTS, ATTRIBUTES, AND ASSOCIATIONS πŸŽ€

In the Perl implementation of MAGE-OM classes, there are three types of class data members: slots, attributes, and associations. Three! A trio! The friend group of class data πŸ’–

⭐ SLOTS ⭐

This API uses the term "slot" to mean a data member of the class that was not present in the UML model, and it's mostly there for internal purposes β€” so bestie, only touch it if you genuinely understand the inner workings of the API, no cap. Most often, slots get used by generic methods like the ones in the XML writing and reading classes.

Slots are implemented using unified getter/setter methods:

  • $var = $obj->slot_name(); β€” retrieves the current value of the slot.
  • $new_var = $obj->slot_name($new_var); β€” stores $new_var in the slot β€” and the return value is also $new_var. Double duty, we love that.
  • @names = $obj->get_slot_names() β€” returns the list of all slots in the class.

DATA CHECKING: No data type checking is made for these methods. None. Zero. It trusts you completely 🫣

πŸ’« ATTRIBUTES AND ASSOCIATIONS πŸ’«

The terms "attribute" and "association" indicate data members of the class that were specified directly from the UML model. Official business only ✨

In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods:

  • get* β€” retrieves the current value.

NOTE: for associations, if the association has list cardinality, an array reference is returned.

DATA CHECKING: ensure that no argument is provided.

  • set* β€” sets the current value, replacing any existing value. Out with the old, in with the new πŸ’…

NOTE: 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 instead. Lowkey a hint, highkey a warning.

DATA CHECKING: 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.

  • add* β€” NOTE: only present in associations with list cardinality.

Appends a list of objects to any values that may already be stored in the association.

DATA CHECKING: ensure that all arguments are of the correct MAGE-OM class.

🌈 GENERIC METHODS 🌈

The unified base class of all MAGE-OM classes, Bio::MAGE::Base, provides a set of generic methods that will operate on slots, attributes, and associations. One class to rule them all, periodt πŸ‘‘

  • $val = $obj->get_slot($name)
  • \@list_ref = $obj->get_slots(@name_list);
  • $val = $obj->set_slot($name,$val)
  • $obj->set_slots(%parameters)
  • $obj->set_slots(\@name_list, \@value_list)

See elsewhere in this page for a detailed description of these methods. (Spoiler: they're up in INSTANCE METHODS, go scroll bestie πŸ“œ)


πŸ› BUGS πŸ›

Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net)

Not me asking you to email the mailing list β€” but yes, genuinely, that's where the bugs go 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Jason E. Stewart (jasons 'at' cpan 'dot' org)


πŸ¦‹ SEE ALSO πŸ¦‹

perl(1).

🫠 POD ERRORS 🫠

Okay bestie, plot twist 😭 the doc you just read? It's a little messy. Not in a cute way. In a "the pod parser is side-eyeing us" way πŸ’€

So basically the man page above had some coding errors, and here's the breakdown of what went wrong and where, explained below:

  • Around line 293: '=item' outside of any '=over' β€” yeah, there's an =item just vibing out there with no =over to hold it. Orphan behavior fr fr πŸ™ˆ
  • Around line 378: You forgot a '=back' before '=head2' β€” you jumped into a new =head2 without closing the previous list with =back. Rude? A little. Fixable? Absolutely πŸ’…
  • Around line 622: Expected '=item 2' β€” the list wanted =item 2 and did not get it.
  • Around line 627: Expected '=item 3' β€” same energy, next number, =item 3 was expected.
  • Around line 632: Expected '=item 4' β€” and again 😭 =item 4 was expected.
No cap: none of this breaks the actual Perl module. It's just the POD being a tiny bit chaotic. The code ate, the documentation tripped on a rug 🌈

And that's the whole page, bestie 🫢 This one comes to you from the User Contributed Perl Documentation crew, running on perl v5.32.0, dated 2020-11-27, and yeah, the page title is literally MAGE::...lueType(3pm) because apparently even the filename was feeling mysterious that day ✨

Go forth, read your value types, and remember: close your lists with =back. Periodt πŸ‘‘πŸ’–