public void registerPattern(final IQuerySpecification<?>... patterns) { IncQueryEngine engine = null; try { engine = key.getEngine(); if (engine.getBaseIndex().isInWildcardMode()) { addMatchersForPatterns(patterns); } else { engine .getBaseIndex() .coalesceTraversals( new Callable<Void>() { @Override public Void call() { addMatchersForPatterns(patterns); return null; } }); } contentStatus = Status.OK_STATUS; } catch (IncQueryException ex) { reportMatcherError("Cannot initialize pattern matcher engine.", ex); } catch (InvocationTargetException e) { reportMatcherError( "Error during pattern matcher construction: " + e.getCause().getMessage(), e.getCause()); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { if (KinectManager.INSTANCE.isSkeletonTrackingStarted()) { try { Notifier km = KinectManager.INSTANCE.getSkeletonModel(); IncQueryEngine e = IncQueryEngine.on(km); // ymca demo new IncQueryMatcherHelper(YMatcher.on(e)); new IncQueryMatcherHelper(MMatcher.on(e)); new IncQueryMatcherHelper(CMatcher.on(e)); new IncQueryMatcherHelper(AMatcher.on(e)); new IncQueryMatcherHelper(IMatcher.on(e)); new IncQueryMatcherHelper(QMatcher.on(e)); // robot demo new IncQueryMatcherHelper(FSMatcher.on(e)); new IncQueryMatcherHelper(FEMatcher.on(e)); new IncQueryMatcherHelper(BSMatcher.on(e)); new IncQueryMatcherHelper(BEMatcher.on(e)); // sheldon demo new IncQueryMatcherHelper(SEMatcher.on(e)); new IncQueryMatcherHelper(SMMatcher.on(e)); new IncQueryMatcherHelper(SEMatcher.on(e)); } catch (IncQueryException e) { e.printStackTrace(); } } else { System.out.println("Start skeleton simulator first!"); } return null; }
/** * Initializes the pattern matcher within an existing EMF-IncQuery engine. If the pattern matcher * is already constructed in the engine, only a light-weight reference is returned. The match set * will be incrementally refreshed upon updates. * * @param engine the existing EMF-IncQuery engine in which this matcher will be created. * @throws IncQueryException if an error occurs during pattern matcher creation */ public static RecordRoleValueMatcher on(final IncQueryEngine engine) throws IncQueryException { // check if matcher already exists RecordRoleValueMatcher matcher = engine.getExistingMatcher(querySpecification()); if (matcher == null) { matcher = new RecordRoleValueMatcher(engine); // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of // it } return matcher; }
/** * Initializes the pattern matcher over a given EMF model root (recommended: Resource or * ResourceSet). If a pattern matcher is already constructed with the same root, only a * light-weight reference is returned. The scope of pattern matching will be the given EMF model * root and below (see FAQ for more precise definition). The match set will be incrementally * refreshed upon updates from this scope. * * <p>The matcher will be created within the managed {@link IncQueryEngine} belonging to the EMF * model root, so multiple matchers will reuse the same engine and benefit from increased * performance and reduced memory footprint. * * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will * operate. Recommended: Resource or ResourceSet. * @throws IncQueryException if an error occurs during pattern matcher creation * @deprecated use {@link #on(IncQueryEngine)} instead, e.g. in conjunction with {@link * IncQueryEngine#on(Notifier)} */ @Deprecated public RecordRoleValueMatcher(final Notifier emfRoot) throws IncQueryException { this(IncQueryEngine.on(emfRoot)); }
/** * Initializes the pattern matcher over a given EMF model root (recommended: Resource or * ResourceSet). If a pattern matcher is already constructed with the same root, only a * light-weight reference is returned. The scope of pattern matching will be the given EMF model * root and below (see FAQ for more precise definition). The match set will be incrementally * refreshed upon updates from this scope. * * <p>The matcher will be created within the managed {@link IncQueryEngine} belonging to the EMF * model root, so multiple matchers will reuse the same engine and benefit from increased * performance and reduced memory footprint. * * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will * operate. Recommended: Resource or ResourceSet. * @throws IncQueryException if an error occurs during pattern matcher creation * @deprecated use {@link #on(IncQueryEngine)} instead, e.g. in conjunction with {@link * IncQueryEngine#on(Notifier)} */ @Deprecated public RouteSensorMatcher(final Notifier emfRoot) throws IncQueryException { this(IncQueryEngine.on(emfRoot)); }
/** * Initializes the pattern matcher over a given EMF model root (recommended: Resource or * ResourceSet). If a pattern matcher is already constructed with the same root, only a * light-weight reference is returned. The scope of pattern matching will be the given EMF model * root and below (see FAQ for more precise definition). The match set will be incrementally * refreshed upon updates from this scope. * * <p>The matcher will be created within the managed {@link IncQueryEngine} belonging to the EMF * model root, so multiple matchers will reuse the same engine and benefit from increased * performance and reduced memory footprint. * * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will * operate. Recommended: Resource or ResourceSet. * @throws IncQueryException if an error occurs during pattern matcher creation * @deprecated use {@link #on(IncQueryEngine)} instead, e.g. in conjunction with {@link * IncQueryEngine#on(Notifier)} */ @Deprecated public CoursesOfTeacherMatcher(final Notifier emfRoot) throws IncQueryException { this(IncQueryEngine.on(emfRoot)); }