Namespace funnyqt.emf

Core functions for accessing and manipulating EMF models.

Other Namespaces

Show/Hide
funnyqt.bidi
Bidirectional transformations (BX).
funnyqt.coevo.tg
Co-Evolution transformations on TGraphs.
funnyqt.edn
Printing/persisting and reading/loading query results and transformation traces as EDN.
funnyqt.extensional
Specify models extensionally.
funnyqt.generic
Generic protocols extended upon many different types, and generic functions.
funnyqt.in-place
In-place transformation stuff.
funnyqt.model2model
Rule-base out-place transformations similar to ATL or QVTo.
funnyqt.pmatch
Graph Pattern Matching on arbitrary models.
funnyqt.polyfns
Polymorphic functions dispatching on types of model elements.
funnyqt.query
Generic query functions like regular path expressions & quantified expressions.
funnyqt.query.emf
EMF-specific query functions
funnyqt.query.tg
TG-specific query functions
funnyqt.relational
Relational Model Querying.
funnyqt.tg
Core functions for accessing and manipulating TGraphs.
funnyqt.utils
Generic utility functions, e.g., for signaling errors, debugging, and profiling,
funnyqt.visualization
Model visualization functions.
funnyqt.xmltg
Convert XML to DOM-like TGraphs.
Index Page
Alphabetic Var Index

Public Vars

Usage Documentation

Show/Hide
Core functions for accessing and manipulating EMF models.
Back to top

Details of Public Vars

Dynamic Var: *epackage-registry*

  The current EPackage Registry which is used for EClassifier registration and
  lookup.  The default value is the global registry.  Use

    (with-epackage-registry (.getPackageRegistry my-resource-set)
      ...)

  to use a ResourceSet's local registry instead.
Back to top View Source

Dynamic Var: *ns-uris*

  A set of namespace URIs to which the classifier lookup should be restricted.
  Also see `with-ns-uris'.
Back to top View Source

Function: eadd!

Arglists:
=========

  (eadd! eo sf value & more)
  (eadd! resource obj)

Docstring:
==========

  Adds `value` and `more` values to `eo`s list of attribute/reference values
  denoted by EStructuralFeature `sf`.  Returns `eo` again.  Throws an exception
  if there's no EStructuralFeature `sf`.

  In the arity-2 version, adds `obj` to `resource` and returns `resource`.
Back to top View Source

Function: eaddall!

Arglists:
=========

  (eaddall! eo sf coll)
  (eaddall! resource coll)

Docstring:
==========

  Adds all values in `coll` to `eo`s `sf` structural feature.
  In the arity 2 variant, adds all EObjects in `coll` to `resource` and
  returns `resource`.
Back to top View Source

Function: eallcontents

Arglists:
=========

  (eallcontents container)
  (eallcontents container ts)

Docstring:
==========

  Returns a lazy seq of `container`s direct and indirect contents
  matching the type spec `ts`.  `container` may be an EObject, a
  Collection, a Resource, or a ResourceSet.
Back to top View Source

Function: eallsubclasses

Arglists:
=========

  (eallsubclasses ec)

Docstring:
==========

  Returns the direct and indirect sub-EClasses of the given EClass `ec`.
Back to top View Source

Function: eallsubpackages

Arglists:
=========

  (eallsubpackages ep)

Docstring:
==========

  Returns all direct and indirect subpackages of EPackage `ep`.
Back to top View Source

Function: eallsuperclasses

Arglists:
=========

  (eallsuperclasses ec)

Docstring:
==========

  Returns the direct and indirect super classes of the given EClass `ec`.
Back to top View Source

Function: eattribute?

Arglists:
=========

  (eattribute? ea)

Docstring:
==========

  Returns true if `ea` is an EAttribute.
Back to top View Source

Function: eclass

Arglists:
=========

  (eclass eo)

Docstring:
==========

  Returns the EClass of the given EObject `eo`.
Back to top View Source

Function: eclass?

Arglists:
=========

  (eclass? ec)

Docstring:
==========

  Returns true if `ec` is an EClass.
Back to top View Source

Function: eclasses

Arglists:
=========

  (eclasses)
  (eclasses ecore-resource)

Docstring:
==========

  Returns the lazy seq of EClasses known by *epackage-registry*.
  Also see: `with-ns-uris` and `with-epackage-registry`
Back to top View Source

Function: eclassifier

Arglists:
=========

  (eclassifier name)

Docstring:
==========

  Returns the eclassifier with the given `name`.
  `name` may be a simple, qualified name, or a map of the form {nsURI name}.
  In the latter case, the lookup is restricted to the package with the given
  nsURI (and its subpackages).
  Throws an exception if no such classifier could be found, or if the given
  simple name is ambiguous.
  Also see: `with-ns-uris` and `with-epackage-registry`
Back to top View Source

Function: eclassifiers

Arglists:
=========

  (eclassifiers)

Docstring:
==========

  Returns the lazy seq of EClassifiers known by *epackage-registry*.
  Also see: `with-ns-uris` and `with-epackage-registry`.
Back to top View Source

Function: econtainer

Arglists:
=========

  (econtainer eo)
  (econtainer eo rs)

Docstring:
==========

  Returns the EObject containing `eo` (if any).
  If a reference spec `rs` is given, return only `eo`s container if it's
  referenced by a containment reference matching `rs`.
Back to top View Source

Function: econtentpairs

Arglists:
=========

  (econtentpairs r)
  (econtentpairs r src-rs trg-rs)
  (econtentpairs r src-rs trg-rs src-ts trg-ts)

Docstring:
==========

  Returns the lazy seq of all containment edges in `r` in terms of [src trg] pairs.
  `r` may be a Resource or ResourceSet.  src is the parent, trg is the child.
  Restrictions may be defined in terms of reference specs `src-rs` and
  `trg-rs`, and reference specs plus type specs `src-ts` and `trg-ts`.
Back to top View Source

Function: econtentrefs

Arglists:
=========

  (econtentrefs eo)
  (econtentrefs eo rs)

Docstring:
==========

  Returns a collection of EObjects contained by EObject`eo`, possibly
  restricted by the reference spec `rs`.  For the syntax and semantics of `rs`,
  see `eref-matcher`.
Back to top View Source

Function: econtents

Arglists:
=========

  (econtents container)
  (econtents container ts)

Docstring:
==========

  Returns a lazy seq of `containers`s direct contents matching the type spec `ts`.
  `container` may be an EObject, a Collection, a Resource, or a
  ResourceSet.
Back to top View Source

Function: ecreate!

Arglists:
=========

  (ecreate! resource ec)
  (ecreate! resource ec prop-map)

Docstring:
==========

  Creates an EObject of EClass `ec` and adds it to `resource` which may be nil.
  `ec` may be either an EClass or just an EClass name given as symbol.
  `prop-map` is an optional map of property names given as keywords to values
  to be set.  Since props are set using `eset!`, the value of a multi-valued
  reference must be a collection of EObjects.
Back to top View Source

Function: ecrosspairs

Arglists:
=========

  (ecrosspairs r)
  (ecrosspairs r src-rs trg-rs)
  (ecrosspairs r src-rs trg-rs src-ts trg-ts)

Docstring:
==========

  Returns the lazy seq of all cross-reference edges in `r` in terms of [src trg] pairs.
  `r` may be a Resource or ResourceSet.  Restrictions may be defined in terms
  of reference specs `src-rs` and `trg-rs`, and reference specs plus type specs
  `src-ts` and `trg-ts`.
Back to top View Source

Function: ecrossrefs

Arglists:
=========

  (ecrossrefs eo)
  (ecrossrefs eo rs)

Docstring:
==========

  Returns a collection of EObjects cross-referenced by EObject`eo`, possibly
  restricted by the reference spec `rs`.  For the syntax and semantics of `rs`,
  see `eref-matcher`.  In EMF, crossrefs are all non-containment refs.
Back to top View Source

Function: edelete!

Arglists:
=========

  (edelete! eo)
  (edelete! eo recursively)
  (edelete! eo recursively unset-uni-crossrefs)

Docstring:
==========

  Unsets all references of `eo` and removes it from its containing resource
  and containing EObject, and returns `eo`.  If `recursively` is true (the
  default), first edelete! all contents of `eo`.  If `unset-uni-crossrefs` is
  true (default is false), then also unset all unidirectional crossreferences
  pointing to `eo` from other objects contained in the same root object,
  resource, or resource set as `eo`.
Back to top View Source

Function: eenum-literal

Arglists:
=========

  (eenum-literal qname)

Docstring:
==========

  Returns the EEnumLiteral specified by its `qname`.
Back to top View Source

Function: eget

Arglists:
=========

  (eget eo sf)

Docstring:
==========

  Returns the value of `eo`s structural feature `sf`.
  The value is converted to some clojure type (see IEMFValues2ClojureValues protocol).
  Throws an exception, if there's no EStructuralFeature `sf`.
Back to top View Source

Function: eget-raw

Arglists:
=========

  (eget-raw eo sf)

Docstring:
==========

  Returns the value of `eo`s structural feature `sf`.
  Throws an exception, if there's no EStructuralFeature `sf`.

  The value is kept as-is, i.e., not converted to some immutable clojure data
  structure as `eget` does.  So if you eget-raw an EList, you can mutate it
  in-place.  That's totally not stylish, but it might be a last resort when
  optimizing for performance.  You've been warned!
Back to top View Source

Function: eobject?

Arglists:
=========

  (eobject? eo)

Docstring:
==========

  Returns true if `eo` is an EObject.
Back to top View Source

Function: epackage

Arglists:
=========

  (epackage name)

Docstring:
==========

  Returns the EPackage with the given (simple or qualified) `name`.
  In case there are several packages with the same (qualified) name, you can
  also disambiguate using {"http://ns/uri" pkg-name}, or by using
  `with-ns-uris`.
Back to top View Source

Function: epackage?

Arglists:
=========

  (epackage? ep)

Docstring:
==========

  Returns true if `ep` is an EPackage.
Back to top View Source

Function: epackages

Arglists:
=========

  (epackages)

Docstring:
==========

  The lazy seq of all registered EPackages and their subpackages.
Back to top View Source

Function: epairs

Arglists:
=========

  (epairs r)
  (epairs r src-rs trg-rs)
  (epairs r src-rs trg-rs src-ts trg-ts)

Docstring:
==========

  Returns the lazy seq of all edges in terms of [src trg] pairs in `r`.
  This includes both containment as well as crossreferences.  Restrictions may
  be defined in terms of reference specs `src-rs` and `trg-rs`, and reference
  specs plus type specs `src-ts` and `trg-ts`.  `r` may be a Resource or
  ResourceSet.
Back to top View Source

Function: eproxy?

Arglists:
=========

  (eproxy? eo)

Docstring:
==========

  Returns true if `eo` is a proxy EObject.
Back to top View Source

Function: ereference?

Arglists:
=========

  (ereference? er)

Docstring:
==========

  Returns true if `er` is an EReference.
Back to top View Source

Function: erefs

Arglists:
=========

  (erefs eo)
  (erefs eo rs)

Docstring:
==========

  Returns a set of EObjects referenced by EObject `eo`, possibly restricted by
  the reference spec `rs`.  For the syntax and semantics of `rs`, see
  `eref-matcher`.  In contrast to `ecrossrefs`, this function doesn't ignore
  containment refs.
Back to top View Source

Function: eremove!

Arglists:
=========

  (eremove! eo sf value & more)
  (eremove! resource eo)

Docstring:
==========

  Removes `value` and `more` values from `eo`s list of attribute/reference
  values denoted by `sf` and returns `eo`.  Throws an exception, if there's no
  EStructuralFeature `sf`.

  In the arity-2 version, removes `obj` from `resource` and returns `resource`.
  Note that it won't delete `obj` or remove references to it.

  Returns `eo` or `resource` again.
Back to top View Source

Function: eremoveall!

Arglists:
=========

  (eremoveall! eo sf coll)
  (eremoveall! resource coll)

Docstring:
==========

  Removes all objects in `coll` from `eo`s list of attribute/reference values
  denoted by `sf` and returns `eo`.  Throws an exception, if there's no
  EStructuralFeature `sf`.

  In the arity-2 version, removes all objects in `coll` from `resource`
  and returns `resource`.  Note that it won't delete the objects or
  remove references to it.

  Returns `eo` or `resource` again.
Back to top View Source

Function: eresource

Arglists:
=========

  (eresource eo)

Docstring:
==========

  Returns the Resource containing `eo` directly or indirectly (if any).
Back to top View Source

Function: eset!

Arglists:
=========

  (eset! eo sf value)

Docstring:
==========

  Sets `eo`s structural feature `sf` to `value` and returns `eo`.
  Throws an exception, if there's no EStructuralFeature `sf`.
Back to top View Source

Function: esubclasses

Arglists:
=========

  (esubclasses ec)

Docstring:
==========

  Returns the direct sub-EClasses of the given EClass `ec`.
Back to top View Source

Function: esubpackages

Arglists:
=========

  (esubpackages ep)

Docstring:
==========

  Returns all direct subpackages of EPackage `ep`.
Back to top View Source

Function: esuperclasses

Arglists:
=========

  (esuperclasses ec)

Docstring:
==========

  Returns the direct super classes of the given EClass `ec`.
Back to top View Source

Function: eunset!

Arglists:
=========

  (eunset! eo sf)

Docstring:
==========

  Unsets `eo`s structural feature `sf` and returns `eo`.
  Throws an exception, if there's no EStructuralFeature `sf`.
Back to top View Source

Macro: generate-ecore-model-functions

Arglists:
=========

  (generate-ecore-model-functions ecore-file)
  (generate-ecore-model-functions ecore-file nssym)
  (generate-ecore-model-functions ecore-file nssym alias)
  (generate-ecore-model-functions ecore-file nssym alias prefix)

Docstring:
==========

  Generates a Ecore-model-specific API consisting of functions for creating
  EObjects and functions for accessing properties (attributes and references).

  `ecore-file` is the ecore file containing the metamodel for which to generate
  the API.

  `nssym` is a symbol denoting the new namespace in which to generate.  It may
  be nil in which case the current namespace is used.

  `alias` is an alias under which the newly generated namespace will be
  required.

  `prefix` is an optional prefix all generated functions should use.  (That's
  mostly useful when generating in an existing namespace to prevent name
  clashes.)

  The following functions are generated.

  For any EClass Foo in the metamodel, a (create-Foo! resource)
  function, a (all-Foos resource) function, and a (isa-Foo? eo) type
  check predicate is generated.

  For any EAttribute name attr, the following functions are generated:

    (attr eo) ;; Returns the attr value of eo
    (set-attr! eo val) ;; Sets the attr value of eo to val

  For boolean attributes, the getter is named attr?.

  For any EReference name ref, the following functions are generated:

    (->ref eo) ;; Returns the object/objects in eo's ref role
    (->set-ref! eo refed) ;; Sets eo's ref reference to refed
    (->add-ref! eo r1 r2 r3...) ;; Adds r1, r2, and r3 to eo's ref reference
    (->addall-ref! eo rs) ;; Adds all objects in rs to eo's ref reference

  The add-* functions are only generated if ref occurs as a multi-valued
  reference.  If eo's ref-reference is multi-valued, then the setter wants a
  collection of eobjects, else a single eobject.

  Lastly, for any EEnumLiteral in the ecore file, a function of zero args
  returning this literal is created, e.g.:

    (enum-TheEnumName-LITERAL)
Back to top View Source

Function: get-resource

Arglists:
=========

  (get-resource rs uri load-on-demand)

Docstring:
==========

  Returns the Resource with the given `uri` contained in ResourceSet `rs`.
  See ResourceSet.getResource(URI, boolean)
Back to top View Source

Function: inv-ecrossrefs

Arglists:
=========

  (inv-ecrossrefs eo)
  (inv-ecrossrefs eo rs)
  (inv-ecrossrefs eo rs container)

Docstring:
==========

  Returns the seq of EOjects that cross-reference EObject `eo` with an
  EReference matching `rs` (see `eref-matcher`).  If no `container` is given,
  then only check the opposite refs of `eo`.  Else, all objects in `container`
  are tested if they cross-reference `eo`. `container` may be either an
  EObject, a Resource, a ResourceSet, or a collection of EObjects.  For the
  former three, direct and indirect contents are checked, for collections only
  direct contents.
Back to top View Source

Function: inv-erefs

Arglists:
=========

  (inv-erefs eo)
  (inv-erefs eo rs)
  (inv-erefs eo rs container)

Docstring:
==========

  Returns the seq of EOjects that reference EObject `eo` with an EReference
  matching `rs` (see `eref-matcher`).  If no `container` is given, then only
  check the opposite refs of `eo`.  Else, all objects in `container` are tested
  if they reference `eo`.  `container` may be either an EObject, a Resource,
  a ResourceSet, or a collection of EObjects.  For the former three, direct and
  indirect contents are checked, for collections only direct contents.
Back to top View Source

Function: load-ecore-resource

Arglists:
=========

  (load-ecore-resource f)

Docstring:
==========

  Loads an Ecore model from the ecore file `f`.
  All EPackages are registered at the *epackage-registry* which defaults to the
  global registry.  The Ecore model is returned as a Resource.  `f` may be a
  file name given as string, a java.io.File, an URI, or a java.net.URL.  Also
  see `with-epackage-registry`.
Back to top View Source

Function: load-resource

Arglists:
=========

  (load-resource f & additional-opts)

Docstring:
==========

  Loads an EMF resource from the XMI file `f`.
  `f` may be a file name given as string, a java.io.File, an URI, or a
  java.net.URL.  `additional-opts` may be additional many option-value pairs
  that are added to the default load options.
  Also see `load-ecore-resource`.
Back to top View Source

Function: new-resource

Arglists:
=========

  (new-resource)
  (new-resource rs uri)

Docstring:
==========

  Creates and returns a new, empty Resource.
  If ResourceSet `rs` and `uri` are given, then create a new Resource with that
  URI in the ResourceSet.
Back to top View Source

Function: new-resource-set

Arglists:
=========

  (new-resource-set)

Docstring:
==========

  Creates and returns a new ResourceSet.
  This resource set assumes any resources in it are XMIResources.
Back to top View Source

Function: save-resource

Arglists:
=========

  (save-resource resource)
  (save-resource resource f)

Docstring:
==========

  Saves the given `resource`.  If given a file `f`, saves to it.
  `f` may be a file name given as string, a java.io.File, an URI, or a
  java.net.URL.
Back to top View Source

Function: set-registry-access-classloader!

Arglists:
=========

  (set-registry-access-classloader! cl)

Docstring:
==========

  No docs attached.
Back to top View Source

Macro: with-epackage-registry

Arglists:
=========

  (with-epackage-registry registry & body)

Docstring:
==========

  Evaluate `body` with the current value of *epackage-registry* set to
  `registry`.
Back to top View Source

Macro: with-ns-uris

Arglists:
=========

  (with-ns-uris [uris] & body)

Docstring:
==========

  Restricts the EClassifier lookup in the dynamic scope of `body` to those
  contained in top-level EPackages registered with the given namespace `uris`
  at the EPackage registry and subpackages thereof.
Back to top View Source