This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
class_py.py and literal.py implemented with tests.
- Loading branch information
1 parent
63145dd
commit ac42bdf
Showing
44 changed files
with
806 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 0 additions & 118 deletions
118
docs/_sources/autoapi/ontouml_py/classes/concrete_classes/class/index.rst.txt
This file was deleted.
Oops, something went wrong.
139 changes: 139 additions & 0 deletions
139
docs/_sources/autoapi/ontouml_py/classes/concrete_classes/class_py/index.rst.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
:py:mod:`ontouml_py.classes.concrete_classes.class_py` | ||
====================================================== | ||
|
||
.. py:module:: ontouml_py.classes.concrete_classes.class_py | ||
.. autoapi-nested-parse:: | ||
|
||
This module defines classes and functionality for representing and manipulating ontological models. | ||
|
||
It includes the definition of the `Class` class, which is a key component in the ontological model, | ||
representing ontological classes with various attributes and behaviors. The module also includes | ||
definitions for handling literals associated with these classes, ensuring that operations on these | ||
classes adhere to certain ontological constraints. | ||
|
||
In this library, a `Class` is initialized as an enumeration by providing a list of literals, which are integral to its | ||
definition. These literals, typically dependent on their classes, represent the finite set of values for enumeration | ||
instances. To enhance object manipulation flexibility, this library allows the creation of 'free' literals, | ||
independent of any class. Users can create these literals separately and later insert them into the appropriate | ||
classes, offering a dynamic approach to class and literal management. | ||
|
||
The module is named class_py instead of class due to the fact that class is a reserved keyword in Python. | ||
As reserved keywords cannot be used as module names, class_py was chosen to maintain clarity and consistency with the | ||
module's purpose, while avoiding naming conflicts within the Python language." | ||
|
||
|
||
|
||
Module Contents | ||
--------------- | ||
|
||
Classes | ||
~~~~~~~ | ||
|
||
.. autoapisummary:: | ||
|
||
ontouml_py.classes.concrete_classes.class_py.Class | ||
|
||
|
||
|
||
|
||
.. py:class:: Class(**data) | ||
Bases: :py:obj:`ontouml_py.classes.abstract_classes.classifier.Classifier` | ||
|
||
Represent a class in an ontological model. | ||
|
||
This class extends the Classifier class and includes additional properties and methods specific to | ||
ontological classes. It supports operations like adding and removing literals, provided the class | ||
conforms to certain constraints based on its stereotype. | ||
|
||
:ivar is_powertype: Indicates if the class is a powertype. | ||
:vartype is_powertype: bool | ||
:ivar order: Represents the order of the class. | ||
:vartype order: str | ||
:ivar restricted_to: A set of ontological natures that the class is restricted to. | ||
:vartype restricted_to: set[OntologicalNature] | ||
:ivar stereotype: The stereotype of the class. | ||
:vartype stereotype: ClassStereotype | ||
:ivar literals: A set of literals associated with the class. | ||
:vartype literals: set[Literal] | ||
|
||
.. py:property:: literals | ||
:type: set[ontouml_py.classes.concrete_classes.literal.Literal] | ||
|
||
Provide a read-only view of the class's literals. | ||
|
||
This property is a safeguard to prevent direct modification of the 'literals' set. To add or remove literals, | ||
use the 'add_literal' and 'remove_literal' methods. This design ensures that the integrity of the class's | ||
literals collection is maintained. | ||
|
||
:return: A set of Literal objects that are part of the class. | ||
:rtype: set[Literal] | ||
|
||
|
||
.. py:attribute:: _literals | ||
:type: set[ontouml_py.classes.concrete_classes.literal.Literal] | ||
|
||
|
||
|
||
.. py:attribute:: is_powertype | ||
:type: bool | ||
|
||
|
||
|
||
.. py:attribute:: order | ||
:type: str | ||
|
||
|
||
|
||
.. py:attribute:: restricted_to | ||
:type: set[ontouml_py.classes.enumerations.ontologicalnature.OntologicalNature] | ||
|
||
|
||
|
||
.. py:attribute:: stereotype | ||
:type: ontouml_py.classes.enumerations.classstereotype.ClassStereotype | ||
|
||
|
||
|
||
.. py:attribute:: model_config | ||
.. py:method:: validate_class() | ||
Validate the class based on its literals and stereotype. | ||
|
||
This method checks if the class conforms to the rules based on its stereotype. Specifically, | ||
it ensures that only classes with the Enumeration stereotype can have literals. | ||
|
||
:raises ValueError: If the class has literals but does not have an Enumeration stereotype. | ||
|
||
|
||
.. py:method:: add_literal(new_literal) | ||
Add a new literal to the class's collection of literals. | ||
|
||
This method ensures that only instances of Literal or its subclasses are added to the class. It also | ||
establishes a bidirectional relationship between the class and the literal. | ||
|
||
:param new_literal: The Literal to be added. | ||
:type new_literal: Literal | ||
:raises TypeError: If the provided new_literal is not an instance of Literal or if a class attempts to add itself. | ||
|
||
|
||
.. py:method:: remove_literal(old_literal) | ||
Remove an existing content from the class's collection of literals. | ||
|
||
This method ensures that the content to be removed is actually part of the class. It also updates the | ||
content's 'in_class' attribute to None, effectively breaking the bidirectional relationship. | ||
|
||
:param old_literal: The Literal content to be removed. | ||
:type old_literal: Literal | ||
:raises TypeError: If the content is not a valid Literal. | ||
:raises ValueError: If the content is not part of the class. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.