org.eclipse.viatra.query.runtime.emf

## Class EMFScope

- java.lang.Object
- - org.eclipse.viatra.query.runtime.internal.apiimpl.EngineContextFactory
  - - org.eclipse.viatra.query.runtime.api.scope.QueryScope
    - - org.eclipse.viatra.query.runtime.emf.EMFScope

-     public class EMFScope
      extends QueryScope

  An `QueryScope` consisting of EMF objects contained in multiple `ResourceSet`s, a single `ResourceSet`, `Resource` or a containment subtree below a given `EObject`.

  The scope is characterized by a root and some options (see `BaseIndexOptions`) such as dynamic EMF mode, subtree filtering etc.

  The scope of pattern matching will be the given EMF model root(s) and below (see FAQ for more precise definition).

  Note on cross-resource containment: in case of `EObject` scopes, cross-resource containments will be considered part of the scope. The same goes for `ResourceSet` scopes, provided that the resource of the contained element is successfully loaded into the resource set. In case of a `Resource` scope, containments pointing out from the resource will be excluded from the scope. Thus the boundaries of `EObject` scopes conform to the notion of EMF logical containment, while `Resource` and `ResourceSet` scopes adhere to persistence boundaries.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EMFScope(org.eclipse.emf.common.notify.Notifier scopeRoot)` Creates an EMF scope at the given root, with default options (recommended for most users).
    `EMFScope(org.eclipse.emf.common.notify.Notifier scopeRoot, BaseIndexOptions options)` Creates an EMF scope at the given root, with customizable options.
    `EMFScope(java.util.Set<? extends org.eclipse.emf.common.notify.Notifier> scopeRoots, BaseIndexOptions options)` Creates an EMF scope at the given roots, with customizable options.
    `EMFScope(java.util.Set<? extends org.eclipse.emf.ecore.resource.ResourceSet> scopeRoots)` Creates an EMF scope at the given roots, with default options (recommended for most users).

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected IEngineContext` | `createEngineContext(ViatraQueryEngine engine, IIndexingErrorListener errorListener, org.apache.log4j.Logger logger)`
    `boolean` | `equals(java.lang.Object obj)`
    `static NavigationHelper` | `extractUnderlyingEMFIndex(ViatraQueryEngine engine)` Provides access to the underlying EMF model index (`NavigationHelper`) from a VIATRA Query engine instantiated on an EMFScope
    `BaseIndexOptions` | `getOptions()`
    `java.util.Set<? extends org.eclipse.emf.common.notify.Notifier>` | `getScopeRoots()`
    `int` | `hashCode()`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.api.scope.QueryScope

      `isCompatibleWithQueryScope`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### EMFScope

          public EMFScope(org.eclipse.emf.common.notify.Notifier scopeRoot)

      Creates an EMF scope at the given root, with default options (recommended for most users).
      Parameters:
        `scopeRoot` - the root of the EMF scope
      Throws:
        `ViatraQueryRuntimeException-` - if scopeRoot is not an EMF ResourceSet, Resource or EObject

    - #### EMFScope

          public EMFScope(org.eclipse.emf.common.notify.Notifier scopeRoot,
                          BaseIndexOptions options)

      Creates an EMF scope at the given root, with customizable options.

      Most users should consider `EMFScope(Notifier)` instead.

      Parameters:
        `scopeRoot` - the root of the EMF scope
        `options` - the base index building settings
      Throws:
        `ViatraQueryRuntimeException` - if scopeRoot is not an EMF ResourceSet, Resource or EObject

    - #### EMFScope

          public EMFScope(java.util.Set<? extends org.eclipse.emf.ecore.resource.ResourceSet> scopeRoots)

      Creates an EMF scope at the given roots, with default options (recommended for most users).
      Parameters:
        `scopeRoots` - the roots of the EMF scope, must be `ResourceSet`s
      Throws:
        `ViatraQueryRuntimeException` - if not all scopeRoots are `ResourceSet`s

    - #### EMFScope

          public EMFScope(java.util.Set<? extends org.eclipse.emf.common.notify.Notifier> scopeRoots,
                          BaseIndexOptions options)

      Creates an EMF scope at the given roots, with customizable options.

      Most users should consider `EMFScope(Set)` instead.

      Parameters:
        `scopeRoots` - the roots of the EMF scope, must be `ResourceSet`s
        `options` - the base index building settings
      Throws:
        `ViatraQueryRuntimeException` - if not all scopeRoots are `ResourceSet`s

  - ### Method Detail

    - #### getScopeRoots

          public java.util.Set<? extends org.eclipse.emf.common.notify.Notifier> getScopeRoots()

      Returns:
        the scope roots (`ResourceSet`s) containing the model

    - #### getOptions

          public BaseIndexOptions getOptions()

      Returns:
        the options

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### createEngineContext

          protected IEngineContext createEngineContext(ViatraQueryEngine engine,
                                                       IIndexingErrorListener errorListener,
                                                       org.apache.log4j.Logger logger)

      Specified by:
        `createEngineContext` in class `org.eclipse.viatra.query.runtime.internal.apiimpl.EngineContextFactory`

    - #### extractUnderlyingEMFIndex

          public static NavigationHelper extractUnderlyingEMFIndex(ViatraQueryEngine engine)

      Provides access to the underlying EMF model index (`NavigationHelper`) from a VIATRA Query engine instantiated on an EMFScope
      Parameters:
        `engine` - an already existing VIATRA Query engine instantiated on an EMFScope
      Returns:
        the underlying EMF base index that indexes the contents of the EMF model
      Throws:
        `ViatraQueryRuntimeException` - if base index initialization fails