MAGE::Protocol(3pm)
okay bestie, deep breath, we're doing this π you just cracked open MAGE::Protocol(3pm), straight out of the User Contributed Perl Documentation pile, and it's a big one. Part 1 of 2, so don't you dare think we're done at the bottom. Let's go π«Ά
β¨ NAME β¨
Bio::MAGE::Protocol β it's the container module for all the classes living in the MAGE package called Protocol. Think of it as the group chat where all the Protocol-adjacent classes hang out π
πΈ SYNOPSIS πΈ
use Bio::MAGE::Protocol;
that's literally it, she's lowkey iconic for that
π¦ DESCRIPTION π¦
So, this is a package module. What that means, bestie, is that it's a lil wrapper that encapsulates a whole bunch of classes in the Bio::MAGE hierarchy π
And which hierarchy branch are we talking about? These classes belong to the Protocol package of the MAGE-OM object model. That's the vibe. No cap.
π CLASSES π
The Bio::MAGE::Protocol module contains the following Bio::MAGE classes, and yes, all ten of them, I'm not skipping a single one:
ProtocolParameterParameterValueProtocolApplicationSoftwareHardwareHardwareApplicationSoftwareApplicationParameterizableParameterizableApplication
look at that roster. main character energy across the board π
π CLASS METHODS π
these are the ones you call on the class, not on an object. iykyk.
β @class_list = Bio::MAGE::Protocol::classes();
This one hands you back a list of non-fully qualified class names β meaning they do not have Bio::MAGE:: stuck on the front as a prefix β that live in this package. Short names only, periodt.
β $obj = class->new(%parameters)
The new() method is the class constructor. Yeah, the classic.
- Parameters: if you pass it a list of name/value parameters, then the corresponding slots, attributes, or associations get their initial values set by the constructor. You feed it, it fills them in π
- Return value: it returns a reference to an object of the class.
- Side effects: it invokes the
initialize()method if the class defines one.
β @names = class->get_slot_names()
The get_slot_names() method is how you retrieve the name of all slots defined in a given class.
NOTE: the list of names does not include attribute or association names. Just slots. Don't come for me, that's what it says π
- 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.
β @name_list = get_association_names()
returns the list of association data members for this class.
β @class_list = get_superclasses()
returns the list of superclasses for this class.
β @class_list = get_subclasses()
returns the list of subclasses for this class.
β $name = class_name()
Returns the full class name for this class. The whole thing. Government name energy β¨
β $package_name = package_name()
Returns the base package name β i.e. with no namespace:: β of the package that contains this class.
β %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.
π«Ά INSTANCE METHODS π«Ά
okay now the ones you call on an actual object. this is where it gets fun.
π $obj_copy = $obj->new()
When you invoke new() with an existing object reference and not a class name, it acts as a copy constructor β the new object's initial values get set to be those of the existing object. it's giving clone, it's giving photocopy, it's giving slay π¦
- Parameters: no input parameters are used in the copy constructor β the initial values are taken directly from the object being copied.
- Return value: it returns a reference to an object of the class.
- Side effects: it invokes the
initialize()method if the class defines one.
π $obj->set_slots(%parameters)
π $obj->set_slots(\@name_list, \@value_list)
The set_slots() method sets a bunch of slots at the same time, and she has two different invocation methods, because why choose:
- the first takes a named parameter list
- the second takes two array references
- Return value: none
- Side effects: will call
croak()if aslot_nameis used that the class does not define. so don't try it π
π @obj_list = $obj->get_slots(@name_list)
The get_slots() method is used to get the values of a number of slots at the same time.
- 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
undefif the slot has not been initialized. - Side effects: none
π $val = $protocol->xml_lists()
π $inval = $protocol->xml_lists($inval)
This is the unified setter/getter method for the xml_lists slot.
If $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
- Input parameters: the optional
$invalwill invoke the setter method. - Return value: for both setter and getter, the current value of the
xml_listsslot - Side effects: none
- Exceptions: none
π $val = $protocol->tagname()
π $inval = $protocol->tagname($inval)
This is the unified setter/getter method for the tagname slot.
If $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
- Input parameters: the optional
$invalwill invoke the setter method. - Return value: for both setter and getter, the current value of the
tagnameslot - Side effects: none
- Exceptions: none
π $val = $protocol->hardware_list()
π $inval = $protocol->hardware_list($inval)
This is the unified setter/getter method for the hardware_list slot.
If $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
- Input parameters: the optional
$invalwill invoke the setter method. - Return value: for both setter and getter, the current value of the
hardware_listslot - Side effects: none
- Exceptions: none
π $val = $protocol->software_list()
π $inval = $protocol->software_list($inval)
This is the unified setter/getter method for the software_list slot.
If $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
- Input parameters: the optional
$invalwill invoke the setter method. - Return value: for both setter and getter, the current value of the
software_listslot - Side effects: none
- Exceptions: none
π $val = $protocol->protocol_list()
π $inval = $protocol->protocol_list($inval)
This is the unified setter/getter method for the protocol_list slot.
If $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
- Input parameters: the optional
$invalwill invoke the setter method. - Return value: for both setter and getter, the current value of the
protocol_listslot - Side effects: none
- Exceptions: none
π $array_ref = $protocol->getHardware_list()
This method handles the list for the Bio::MAGE::Protocol::Hardware class. It returns a reference to an array of the class objects that have been associated with the package instance.
This is useful when retrieving data from a parsed MAGE-ML file. very much a "read the receipts" situation π§
π $protocol->addHardware(@vals)
This method is an interface for adding Bio::MAGE::Protocol::Hardware objects to the hardware_list list. It is generally used by generic methods such as those in the XMLWriter.
- Input parameters: the list of values
@valsto add to the owner association. NOTE: submitting a single value is permitted. one is enough bestie, we don't judge π - Return value: none
- Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if any of the objects in@valsis not a subclass of classBio::MAGE::Protocol::Hardware
π $array_ref = $protocol->getSoftware_list()
This method handles the list for the Bio::MAGE::Protocol::Software class. It returns a reference to an array of the class objects that have been associated with the package instance.
This is useful when retrieving data from a parsed MAGE-ML file.
π $protocol->addSoftware(@vals)
This method is an interface for adding Bio::MAGE::Protocol::Software objects to the software_list list. It is generally used by generic methods such as those in the XMLWriter.
- Input parameters: the list of values
@valsto add to the owner association. NOTE: submitting a single value is permitted. - Return value: none
- Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if any of the objects in@valsis not a subclass of classBio::MAGE::Protocol::Software
π $array_ref = $protocol->getProtocol_list()
This method handles the list for the Bio::MAGE::Protocol::Protocol class. It returns a reference to an array of the class objects that have been associated with the package instance.
This is useful when retrieving data from a parsed MAGE-ML file.
π $protocol->addProtocol(@vals)
This method is an interface for adding Bio::MAGE::Protocol::Protocol objects to the protocol_list list. It is generally used by generic methods such as those in the XMLWriter.
- Input parameters: the list of values
@valsto add to the owner association. NOTE: submitting a single value is permitted. - Return value: none
- Side effects: none
- Exceptions: will call
croak()if no input parameters are specified, or if any of the objects in@valsis not a subclass of classBio::MAGE::Protocol::Protocol
π $protocol->obj2xml($writer)
Write out this object, and all sub-objects, as XML, using the supplied $writer to actually do the XML formatting. it's giving β¨ delegation β¨
- Input parameters:
$writermust be an XML writer, e.g. an instance ofBio::MAGE::XML::Writer. It must have methods:write_start_tag(),write_end_tag(), andobj2xml(). - Return value: none
- Side effects: all writing is delegated to the
$writerβ itswrite_start_tag()andwrite_end_tag()methods are invoked with the appropriate data, and all class sub-objects of theBio::MAGE::Protocolinstance will have theirobj2xml()methods invoked in turn. By allowing the$writerto do the actual formatting of the output XML, it enables the user to precisely control the format. so much power, honestly π - Exceptions: will call
croak()if no identifier has been set for theBio::MAGE::Protocolinstance.
π $protocol->register($obj)
Store an object for later writing as XML. it's literally a "save for later" button π
- Input parameters: object to be added to the list of registered objects.
- Return value: none
- Side effects: if
$objneeds to be stored by this class, a reference will be stored in the correct XML list for this class. - Exceptions: none
πΈ SLOTS, ATTRIBUTES, AND ASSOCIATIONS πΈ
okay so this is the part where we talk about the three β¨flavorsβ¨ of data members a class can have in the Perl implementation of MAGE-OM classes: slots, attributes, and associations. bestie, they are NOT the same thing and the API treats them differently, so let's get into it π
π SLOTS π
so, a "slot" is a data member of the class that was not present in the UML model. it exists for mainly internal purposes. the API's whole vibe here is: use only if you understand the inner workings of the API. like, this is the backstage area, not the stage π
most often slots get used by generic methods, like the ones in the XML writing and reading classes. iykyk.
slots are implemented using unified getter/setter methods, which look like this:
$var = $obj->slot_name();
Retrieves the current value of the slot.
$new_var = $obj->slot_name($new_var);
Store $new_var in the slot β the return value is also $new_var. cute, it hands it right back π«Ά
@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. zero. none. she does not check. proceed accordingly π
π ATTRIBUTES AND ASSOCIATIONS π
now, the terms "attribute" and "association" mean data members of the class that were specified directly from the UML model. so these are the legit, on-the-model ones, not the backstage slots.
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. (so like, you get a ref, not the list, bestie β don't get caught out π)
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, periodt.
NOTE: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using theadd*methods. like fr fr, just useadd*.
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. if it's not list-cardinality, this method simply does not exist, no cap.
Appends a list of objects to any values that may already be stored in the association. it adds, it does not replace. she's an accumulator β¨
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 base class to rule them all π
$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. (yes bestie, the full tea is on the rest of the page, go look π)
π BUGS π
found a bug? not the vibe, but okay β please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net)
π AUTHOR π
Jason E. Stewart (jasons 'at' cpan 'dot' org) β iconic, honestly π
β SEE ALSO β
and that's the whole page, bestie!! this one's MAGE::Protocol(3pm), from perl v5.32.0, dated 2020-11-27. you ate that read π«Άβ¨
π¦ where this page comes from
- debian bookworm: libbio-mage-perl 20030502.3-6 Β· MIT
- debian trixie: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu jammy: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu noble: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu resolute: libbio-mage-perl 20030502.3-6 Β· MIT
- ubuntu stonking: libbio-mage-perl 20030502.3-6 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms