codeable_models.CBundle¶
-
class
codeable_models.CBundle(name=None, **kwargs)¶ CBundleis used to manage bundles, i.e., groups of modelling elements in Codeable Models.Superclasses:
CBundlable- Parameters
name (str) – An optional name.
**kwargs –
Pass in any kwargs acceptable to superclasses. In addition,
CBundleaccepts:elements.The
elementskwarg accepts a list of elements (same format as theelementsproperty).
All kinds of modelling elements in Codeable Models that inherit from
CBundlablecan be placed in a bundle, including bundles themselves. Thus bundles can be composed recursively in order to model composite structures. The relations ofCBundleare shown in the figure below.
For example, the following code creates the bundle of classes used to generate the figure above:
bundles_model = CBundle("bundles_model", elements=[cbundlable, cbundle, cenum, cobject, cclassifier, cclass, cmetaclass, cstereotype, cassociation, clink])
-
add(elt)¶ Add an element to the bundle.
- Parameters
elt (CBundlable) – Element to add to the bundle
- Returns
None
-
delete()¶ Delete the bundle. Delete all elements from the bundle. Calls
delete()on superclass.- Returns
None
-
property
elements¶ Getter and setter for the elements of the bundle.
- Type
List[CBundlable]
-
get_element(**kwargs)¶ Get a specific element from the bundle. Returns the first found element, if more than one are found. Returns
Noneif none is found.- Parameters
**kwargs – Used to specify in more detail which elements to get from the bundle. Accepts the arguments acceptable to
get_elements().- Returns
The element of the bundle.
- Return type
-
get_elements(**kwargs)¶ Get specific elements from the bundle. Per default returns all elements.
- Parameters
**kwargs –
Used to specify in more detail which elements to get from the bundle. Accepts the following arguments:
type: Return only elements which are instances of the specified type.name: Return only elements with the specified name.
- Returns
List of elements.
- Return type
List[CBundlable]
-
remove(element)¶ Remove an element from the bundle.
- Parameters
element (CBundlable) – Element to remove from the bundle.
- Returns
None