From e904f9d4b1d2d15ab4ec6d72ee881f4c7de34eef Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 15 May 2019 13:46:38 -0400 Subject: Formalize CPS case study for optimization --- .../.classpath | 2 + .../.gitignore | 1 + .../.project | 12 + .../META-INF/MANIFEST.MF | 22 +- .../build.properties | 9 + .../domains/cps/ApplicationInstance.java | 110 ++ .../dslreasoner/domains/cps/ApplicationType.java | 61 + .../inf/dslreasoner/domains/cps/CpsFactory.java | 105 ++ .../inf/dslreasoner/domains/cps/CpsPackage.java | 1253 ++++++++++++++++++++ .../domains/cps/CyberPhysicalSystem.java | 112 ++ .../inf/dslreasoner/domains/cps/HostInstance.java | 141 +++ .../mit/inf/dslreasoner/domains/cps/HostType.java | 125 ++ .../mit/inf/dslreasoner/domains/cps/Request.java | 44 + .../inf/dslreasoner/domains/cps/Requirement.java | 127 ++ .../domains/cps/ResourceRequirement.java | 104 ++ .../domains/cps/impl/ApplicationInstanceImpl.java | 405 +++++++ .../domains/cps/impl/ApplicationTypeImpl.java | 209 ++++ .../domains/cps/impl/CpsFactoryImpl.java | 188 +++ .../domains/cps/impl/CpsPackageImpl.java | 765 ++++++++++++ .../domains/cps/impl/CyberPhysicalSystemImpl.java | 289 +++++ .../domains/cps/impl/HostInstanceImpl.java | 355 ++++++ .../dslreasoner/domains/cps/impl/HostTypeImpl.java | 356 ++++++ .../dslreasoner/domains/cps/impl/RequestImpl.java | 169 +++ .../domains/cps/impl/RequirementImpl.java | 387 ++++++ .../domains/cps/impl/ResourceRequirementImpl.java | 291 +++++ .../domains/cps/util/CpsAdapterFactory.java | 252 ++++ .../dslreasoner/domains/cps/util/CpsSwitch.java | 266 +++++ .../model/cps.aird | 1167 +++++++++++++++--- .../model/cps.ecore | 53 +- .../model/cps.genmodel | 5 +- .../plugin.properties | 4 + .../plugin.xml | 44 + .../inf/dslreasoner/domains/cps/queries/.gitignore | 16 + .../AllocationWithoutResourceRequirement.java | 717 +++++++++++ .../domains/cps/queries/AvailableHdd.java | 743 ++++++++++++ .../domains/cps/queries/AvailableMemory.java | 743 ++++++++++++ .../domains/cps/queries/AverageFreeHddMetric.java | 540 +++++++++ .../cps/queries/AverageFreeMemoryMetric.java | 540 +++++++++ .../domains/cps/queries/CostMetric.java | 540 +++++++++ .../domains/cps/queries/CpsApplications.java | 705 +++++++++++ .../dslreasoner/domains/cps/queries/CpsCost.java | 738 ++++++++++++ .../dslreasoner/domains/cps/queries/CpsHosts.java | 705 +++++++++++ .../domains/cps/queries/CpsQueries.java | 207 ++++ .../queries/InstanceDoesNotSatisfyRequirement.java | 716 +++++++++++ .../domains/cps/queries/NotEnoughAvailableHdd.java | 579 +++++++++ .../cps/queries/NotEnoughAvailableMemory.java | 579 +++++++++ .../cps/queries/RequirementNotSatisfied.java | 597 ++++++++++ .../dslreasoner/domains/cps/queries/TotalHdd.java | 706 +++++++++++ .../domains/cps/queries/TotalMemory.java | 706 +++++++++++ .../domains/cps/queries/internal/.gitignore | 11 + .../cps/queries/internal/CpsQueriesAll.java | 105 ++ .../cps/queries/internal/FreeHddPercentage.java | 172 +++ .../cps/queries/internal/FreeMemoryPercentage.java | 172 +++ .../cps/queries/internal/HddRequirement.java | 151 +++ .../cps/queries/internal/HostInstanceCost.java | 153 +++ .../cps/queries/internal/MemoryRequirement.java | 151 +++ .../cps/queries/internal/ResourceRequirement.java | 168 +++ .../cps/queries/internal/SatisfyingInstance.java | 153 +++ .../dslreasoner/domains/cps/queries/CpsQueries.vql | 132 +++ 59 files changed, 18710 insertions(+), 168 deletions(-) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps') diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath index 22f30643..00cbac94 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath @@ -1,7 +1,9 @@ + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project index 994e7632..69c44278 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project @@ -5,6 +5,16 @@ + + org.eclipse.viatra.query.tooling.ui.projectbuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + org.eclipse.jdt.core.javabuilder @@ -25,5 +35,7 @@ org.eclipse.sirius.nature.modelingproject org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + org.eclipse.viatra.query.projectnature + org.eclipse.xtext.ui.shared.xtextNature diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF index 4d2fd769..7fd7252c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF @@ -1,7 +1,23 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: hu.bme.mit.inf.dslreasoner.domains.cps -Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.domains.cps; singleton:=true +Bundle-Name: %pluginName +Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.domains.cps;singleton:=true Bundle-Version: 0.1.0.qualifier -Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport, +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Export-Package: hu.bme.mit.inf.dslreasoner.domains.cps, + hu.bme.mit.inf.dslreasoner.domains.cps.impl, + hu.bme.mit.inf.dslreasoner.domains.cps.queries, + hu.bme.mit.inf.dslreasoner.domains.cps.util +Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, + org.eclipse.viatra.query.runtime, + org.eclipse.viatra.query.runtime.rete, + org.eclipse.viatra.query.runtime.localsearch, + org.eclipse.xtext.xbase.lib, + org.eclipse.emf.ecore;visibility:=reexport, org.eclipse.core.runtime +Import-Package: org.apache.log4j +Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.cps +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties new file mode 100644 index 00000000..37a7e53b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties @@ -0,0 +1,9 @@ +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = ecore-gen/,\ + src-gen/ +output.. = bin/ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java new file mode 100644 index 00000000..dc9426f2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java @@ -0,0 +1,110 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Application Instance'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance() + * @model + * @generated + */ +public interface ApplicationInstance extends EObject { + /** + * Returns the value of the 'Requirement' reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances Instances}'. + * + *

+ * If the meaning of the 'Requirement' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requirement' reference. + * @see #setRequirement(Requirement) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_Requirement() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances + * @model opposite="instances" + * @generated + */ + Requirement getRequirement(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}' reference. + * + * + * @param value the new value of the 'Requirement' reference. + * @see #getRequirement() + * @generated + */ + void setRequirement(Requirement value); + + /** + * Returns the value of the 'Type' container reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances Instances}'. + * + *

+ * If the meaning of the 'Type' container reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Type' container reference. + * @see #setType(ApplicationType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_Type() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances + * @model opposite="instances" required="true" transient="false" + * @generated + */ + ApplicationType getType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}' container reference. + * + * + * @param value the new value of the 'Type' container reference. + * @see #getType() + * @generated + */ + void setType(ApplicationType value); + + /** + * Returns the value of the 'Allocated To' reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}'. + * + *

+ * If the meaning of the 'Allocated To' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Allocated To' reference. + * @see #setAllocatedTo(HostInstance) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_AllocatedTo() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications + * @model opposite="applications" required="true" + * @generated + */ + HostInstance getAllocatedTo(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}' reference. + * + * + * @param value the new value of the 'Allocated To' reference. + * @see #getAllocatedTo() + * @generated + */ + void setAllocatedTo(HostInstance value); + +} // ApplicationInstance diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java new file mode 100644 index 00000000..f44287ae --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java @@ -0,0 +1,61 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Application Type'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements Requirements}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType() + * @model + * @generated + */ +public interface ApplicationType extends EObject { + /** + * Returns the value of the 'Instances' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}'. + * + *

+ * If the meaning of the 'Instances' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Instances' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType_Instances() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType + * @model opposite="type" containment="true" + * @generated + */ + EList getInstances(); + + /** + * Returns the value of the 'Requirements' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement}. + * + *

+ * If the meaning of the 'Requirements' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requirements' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType_Requirements() + * @model containment="true" + * @generated + */ + EList getRequirements(); + +} // ApplicationType diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java new file mode 100644 index 00000000..93a5fc95 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java @@ -0,0 +1,105 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage + * @generated + */ +public interface CpsFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + CpsFactory eINSTANCE = hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsFactoryImpl.init(); + + /** + * Returns a new object of class 'Cyber Physical System'. + * + * + * @return a new object of class 'Cyber Physical System'. + * @generated + */ + CyberPhysicalSystem createCyberPhysicalSystem(); + + /** + * Returns a new object of class 'Application Type'. + * + * + * @return a new object of class 'Application Type'. + * @generated + */ + ApplicationType createApplicationType(); + + /** + * Returns a new object of class 'Host Type'. + * + * + * @return a new object of class 'Host Type'. + * @generated + */ + HostType createHostType(); + + /** + * Returns a new object of class 'Request'. + * + * + * @return a new object of class 'Request'. + * @generated + */ + Request createRequest(); + + /** + * Returns a new object of class 'Requirement'. + * + * + * @return a new object of class 'Requirement'. + * @generated + */ + Requirement createRequirement(); + + /** + * Returns a new object of class 'Application Instance'. + * + * + * @return a new object of class 'Application Instance'. + * @generated + */ + ApplicationInstance createApplicationInstance(); + + /** + * Returns a new object of class 'Resource Requirement'. + * + * + * @return a new object of class 'Resource Requirement'. + * @generated + */ + ResourceRequirement createResourceRequirement(); + + /** + * Returns a new object of class 'Host Instance'. + * + * + * @return a new object of class 'Host Instance'. + * @generated + */ + HostInstance createHostInstance(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + CpsPackage getCpsPackage(); + +} //CpsFactory diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java new file mode 100644 index 00000000..2d7e0660 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java @@ -0,0 +1,1253 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory + * @model kind="package" + * annotation="http://www.eclipse.org/emf/2002/Ecore settingDelegates='org.eclipse.viatra.query.querybasedfeature'" + * @generated + */ +public interface CpsPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "cps"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.example.org/cps"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "cps"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + CpsPackage eINSTANCE = hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl.init(); + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl Cyber Physical System}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getCyberPhysicalSystem() + * @generated + */ + int CYBER_PHYSICAL_SYSTEM = 0; + + /** + * The feature id for the 'Requests' containment reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__REQUESTS = 0; + + /** + * The feature id for the 'Application Types' containment reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES = 1; + + /** + * The feature id for the 'Host Types' containment reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__HOST_TYPES = 2; + + /** + * The feature id for the 'Hosts' reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__HOSTS = 3; + + /** + * The feature id for the 'Applications' reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__APPLICATIONS = 4; + + /** + * The number of structural features of the 'Cyber Physical System' class. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM_FEATURE_COUNT = 5; + + /** + * The number of operations of the 'Cyber Physical System' class. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl Application Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationType() + * @generated + */ + int APPLICATION_TYPE = 1; + + /** + * The feature id for the 'Instances' containment reference list. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE__INSTANCES = 0; + + /** + * The feature id for the 'Requirements' containment reference list. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE__REQUIREMENTS = 1; + + /** + * The number of structural features of the 'Application Type' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE_FEATURE_COUNT = 2; + + /** + * The number of operations of the 'Application Type' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl Host Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostType() + * @generated + */ + int HOST_TYPE = 2; + + /** + * The feature id for the 'Default Memory' attribute. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__DEFAULT_MEMORY = 0; + + /** + * The feature id for the 'Default Hdd' attribute. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__DEFAULT_HDD = 1; + + /** + * The feature id for the 'Instances' containment reference list. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__INSTANCES = 2; + + /** + * The feature id for the 'Cost' attribute. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__COST = 3; + + /** + * The number of structural features of the 'Host Type' class. + * + * + * @generated + * @ordered + */ + int HOST_TYPE_FEATURE_COUNT = 4; + + /** + * The number of operations of the 'Host Type' class. + * + * + * @generated + * @ordered + */ + int HOST_TYPE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl Request}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequest() + * @generated + */ + int REQUEST = 3; + + /** + * The feature id for the 'Requirements' containment reference list. + * + * + * @generated + * @ordered + */ + int REQUEST__REQUIREMENTS = 0; + + /** + * The number of structural features of the 'Request' class. + * + * + * @generated + * @ordered + */ + int REQUEST_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'Request' class. + * + * + * @generated + * @ordered + */ + int REQUEST_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequirement() + * @generated + */ + int REQUIREMENT = 4; + + /** + * The feature id for the 'Request' container reference. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__REQUEST = 0; + + /** + * The feature id for the 'Count' attribute. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__COUNT = 1; + + /** + * The feature id for the 'Type' reference. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__TYPE = 2; + + /** + * The feature id for the 'Instances' reference list. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__INSTANCES = 3; + + /** + * The number of structural features of the 'Requirement' class. + * + * + * @generated + * @ordered + */ + int REQUIREMENT_FEATURE_COUNT = 4; + + /** + * The number of operations of the 'Requirement' class. + * + * + * @generated + * @ordered + */ + int REQUIREMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl Application Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationInstance() + * @generated + */ + int APPLICATION_INSTANCE = 5; + + /** + * The feature id for the 'Requirement' reference. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE__REQUIREMENT = 0; + + /** + * The feature id for the 'Type' container reference. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE__TYPE = 1; + + /** + * The feature id for the 'Allocated To' reference. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE__ALLOCATED_TO = 2; + + /** + * The number of structural features of the 'Application Instance' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE_FEATURE_COUNT = 3; + + /** + * The number of operations of the 'Application Instance' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl Resource Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getResourceRequirement() + * @generated + */ + int RESOURCE_REQUIREMENT = 6; + + /** + * The feature id for the 'Required Memory' attribute. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT__REQUIRED_MEMORY = 0; + + /** + * The feature id for the 'Required Hdd' attribute. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT__REQUIRED_HDD = 1; + + /** + * The feature id for the 'Host Type' reference. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT__HOST_TYPE = 2; + + /** + * The number of structural features of the 'Resource Requirement' class. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT_FEATURE_COUNT = 3; + + /** + * The number of operations of the 'Resource Requirement' class. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl Host Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostInstance() + * @generated + */ + int HOST_INSTANCE = 7; + + /** + * The feature id for the 'Type' container reference. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__TYPE = 0; + + /** + * The feature id for the 'Available Memory' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__AVAILABLE_MEMORY = 1; + + /** + * The feature id for the 'Available Hdd' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__AVAILABLE_HDD = 2; + + /** + * The feature id for the 'Total Memory' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__TOTAL_MEMORY = 3; + + /** + * The feature id for the 'Total Hdd' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__TOTAL_HDD = 4; + + /** + * The feature id for the 'Applications' reference list. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__APPLICATIONS = 5; + + /** + * The number of structural features of the 'Host Instance' class. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE_FEATURE_COUNT = 6; + + /** + * The number of operations of the 'Host Instance' class. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE_OPERATION_COUNT = 0; + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem Cyber Physical System}'. + * + * + * @return the meta object for class 'Cyber Physical System'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem + * @generated + */ + EClass getCyberPhysicalSystem(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests Requests}'. + * + * + * @return the meta object for the containment reference list 'Requests'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_Requests(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes Application Types}'. + * + * + * @return the meta object for the containment reference list 'Application Types'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_ApplicationTypes(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes Host Types}'. + * + * + * @return the meta object for the containment reference list 'Host Types'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_HostTypes(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts Hosts}'. + * + * + * @return the meta object for the reference list 'Hosts'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_Hosts(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications Applications}'. + * + * + * @return the meta object for the reference list 'Applications'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_Applications(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType Application Type}'. + * + * + * @return the meta object for class 'Application Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType + * @generated + */ + EClass getApplicationType(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances Instances}'. + * + * + * @return the meta object for the containment reference list 'Instances'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances() + * @see #getApplicationType() + * @generated + */ + EReference getApplicationType_Instances(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements Requirements}'. + * + * + * @return the meta object for the containment reference list 'Requirements'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements() + * @see #getApplicationType() + * @generated + */ + EReference getApplicationType_Requirements(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType Host Type}'. + * + * + * @return the meta object for class 'Host Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType + * @generated + */ + EClass getHostType(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory Default Memory}'. + * + * + * @return the meta object for the attribute 'Default Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory() + * @see #getHostType() + * @generated + */ + EAttribute getHostType_DefaultMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd Default Hdd}'. + * + * + * @return the meta object for the attribute 'Default Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd() + * @see #getHostType() + * @generated + */ + EAttribute getHostType_DefaultHdd(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances Instances}'. + * + * + * @return the meta object for the containment reference list 'Instances'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances() + * @see #getHostType() + * @generated + */ + EReference getHostType_Instances(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost Cost}'. + * + * + * @return the meta object for the attribute 'Cost'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost() + * @see #getHostType() + * @generated + */ + EAttribute getHostType_Cost(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request Request}'. + * + * + * @return the meta object for class 'Request'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request + * @generated + */ + EClass getRequest(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements Requirements}'. + * + * + * @return the meta object for the containment reference list 'Requirements'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements() + * @see #getRequest() + * @generated + */ + EReference getRequest_Requirements(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement Requirement}'. + * + * + * @return the meta object for class 'Requirement'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement + * @generated + */ + EClass getRequirement(); + + /** + * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}'. + * + * + * @return the meta object for the container reference 'Request'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest() + * @see #getRequirement() + * @generated + */ + EReference getRequirement_Request(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount Count}'. + * + * + * @return the meta object for the attribute 'Count'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount() + * @see #getRequirement() + * @generated + */ + EAttribute getRequirement_Count(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType Type}'. + * + * + * @return the meta object for the reference 'Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType() + * @see #getRequirement() + * @generated + */ + EReference getRequirement_Type(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances Instances}'. + * + * + * @return the meta object for the reference list 'Instances'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances() + * @see #getRequirement() + * @generated + */ + EReference getRequirement_Instances(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance Application Instance}'. + * + * + * @return the meta object for class 'Application Instance'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance + * @generated + */ + EClass getApplicationInstance(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}'. + * + * + * @return the meta object for the reference 'Requirement'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement() + * @see #getApplicationInstance() + * @generated + */ + EReference getApplicationInstance_Requirement(); + + /** + * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}'. + * + * + * @return the meta object for the container reference 'Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType() + * @see #getApplicationInstance() + * @generated + */ + EReference getApplicationInstance_Type(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}'. + * + * + * @return the meta object for the reference 'Allocated To'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo() + * @see #getApplicationInstance() + * @generated + */ + EReference getApplicationInstance_AllocatedTo(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement Resource Requirement}'. + * + * + * @return the meta object for class 'Resource Requirement'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement + * @generated + */ + EClass getResourceRequirement(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory Required Memory}'. + * + * + * @return the meta object for the attribute 'Required Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory() + * @see #getResourceRequirement() + * @generated + */ + EAttribute getResourceRequirement_RequiredMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd Required Hdd}'. + * + * + * @return the meta object for the attribute 'Required Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd() + * @see #getResourceRequirement() + * @generated + */ + EAttribute getResourceRequirement_RequiredHdd(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType Host Type}'. + * + * + * @return the meta object for the reference 'Host Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType() + * @see #getResourceRequirement() + * @generated + */ + EReference getResourceRequirement_HostType(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance Host Instance}'. + * + * + * @return the meta object for class 'Host Instance'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance + * @generated + */ + EClass getHostInstance(); + + /** + * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}'. + * + * + * @return the meta object for the container reference 'Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType() + * @see #getHostInstance() + * @generated + */ + EReference getHostInstance_Type(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory Available Memory}'. + * + * + * @return the meta object for the attribute 'Available Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_AvailableMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd Available Hdd}'. + * + * + * @return the meta object for the attribute 'Available Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_AvailableHdd(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory Total Memory}'. + * + * + * @return the meta object for the attribute 'Total Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_TotalMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd Total Hdd}'. + * + * + * @return the meta object for the attribute 'Total Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_TotalHdd(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}'. + * + * + * @return the meta object for the reference list 'Applications'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications() + * @see #getHostInstance() + * @generated + */ + EReference getHostInstance_Applications(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + CpsFactory getCpsFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl Cyber Physical System}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getCyberPhysicalSystem() + * @generated + */ + EClass CYBER_PHYSICAL_SYSTEM = eINSTANCE.getCyberPhysicalSystem(); + + /** + * The meta object literal for the 'Requests' containment reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__REQUESTS = eINSTANCE.getCyberPhysicalSystem_Requests(); + + /** + * The meta object literal for the 'Application Types' containment reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES = eINSTANCE.getCyberPhysicalSystem_ApplicationTypes(); + + /** + * The meta object literal for the 'Host Types' containment reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__HOST_TYPES = eINSTANCE.getCyberPhysicalSystem_HostTypes(); + + /** + * The meta object literal for the 'Hosts' reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__HOSTS = eINSTANCE.getCyberPhysicalSystem_Hosts(); + + /** + * The meta object literal for the 'Applications' reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__APPLICATIONS = eINSTANCE.getCyberPhysicalSystem_Applications(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl Application Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationType() + * @generated + */ + EClass APPLICATION_TYPE = eINSTANCE.getApplicationType(); + + /** + * The meta object literal for the 'Instances' containment reference list feature. + * + * + * @generated + */ + EReference APPLICATION_TYPE__INSTANCES = eINSTANCE.getApplicationType_Instances(); + + /** + * The meta object literal for the 'Requirements' containment reference list feature. + * + * + * @generated + */ + EReference APPLICATION_TYPE__REQUIREMENTS = eINSTANCE.getApplicationType_Requirements(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl Host Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostType() + * @generated + */ + EClass HOST_TYPE = eINSTANCE.getHostType(); + + /** + * The meta object literal for the 'Default Memory' attribute feature. + * + * + * @generated + */ + EAttribute HOST_TYPE__DEFAULT_MEMORY = eINSTANCE.getHostType_DefaultMemory(); + + /** + * The meta object literal for the 'Default Hdd' attribute feature. + * + * + * @generated + */ + EAttribute HOST_TYPE__DEFAULT_HDD = eINSTANCE.getHostType_DefaultHdd(); + + /** + * The meta object literal for the 'Instances' containment reference list feature. + * + * + * @generated + */ + EReference HOST_TYPE__INSTANCES = eINSTANCE.getHostType_Instances(); + + /** + * The meta object literal for the 'Cost' attribute feature. + * + * + * @generated + */ + EAttribute HOST_TYPE__COST = eINSTANCE.getHostType_Cost(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl Request}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequest() + * @generated + */ + EClass REQUEST = eINSTANCE.getRequest(); + + /** + * The meta object literal for the 'Requirements' containment reference list feature. + * + * + * @generated + */ + EReference REQUEST__REQUIREMENTS = eINSTANCE.getRequest_Requirements(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequirement() + * @generated + */ + EClass REQUIREMENT = eINSTANCE.getRequirement(); + + /** + * The meta object literal for the 'Request' container reference feature. + * + * + * @generated + */ + EReference REQUIREMENT__REQUEST = eINSTANCE.getRequirement_Request(); + + /** + * The meta object literal for the 'Count' attribute feature. + * + * + * @generated + */ + EAttribute REQUIREMENT__COUNT = eINSTANCE.getRequirement_Count(); + + /** + * The meta object literal for the 'Type' reference feature. + * + * + * @generated + */ + EReference REQUIREMENT__TYPE = eINSTANCE.getRequirement_Type(); + + /** + * The meta object literal for the 'Instances' reference list feature. + * + * + * @generated + */ + EReference REQUIREMENT__INSTANCES = eINSTANCE.getRequirement_Instances(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl Application Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationInstance() + * @generated + */ + EClass APPLICATION_INSTANCE = eINSTANCE.getApplicationInstance(); + + /** + * The meta object literal for the 'Requirement' reference feature. + * + * + * @generated + */ + EReference APPLICATION_INSTANCE__REQUIREMENT = eINSTANCE.getApplicationInstance_Requirement(); + + /** + * The meta object literal for the 'Type' container reference feature. + * + * + * @generated + */ + EReference APPLICATION_INSTANCE__TYPE = eINSTANCE.getApplicationInstance_Type(); + + /** + * The meta object literal for the 'Allocated To' reference feature. + * + * + * @generated + */ + EReference APPLICATION_INSTANCE__ALLOCATED_TO = eINSTANCE.getApplicationInstance_AllocatedTo(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl Resource Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getResourceRequirement() + * @generated + */ + EClass RESOURCE_REQUIREMENT = eINSTANCE.getResourceRequirement(); + + /** + * The meta object literal for the 'Required Memory' attribute feature. + * + * + * @generated + */ + EAttribute RESOURCE_REQUIREMENT__REQUIRED_MEMORY = eINSTANCE.getResourceRequirement_RequiredMemory(); + + /** + * The meta object literal for the 'Required Hdd' attribute feature. + * + * + * @generated + */ + EAttribute RESOURCE_REQUIREMENT__REQUIRED_HDD = eINSTANCE.getResourceRequirement_RequiredHdd(); + + /** + * The meta object literal for the 'Host Type' reference feature. + * + * + * @generated + */ + EReference RESOURCE_REQUIREMENT__HOST_TYPE = eINSTANCE.getResourceRequirement_HostType(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl Host Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostInstance() + * @generated + */ + EClass HOST_INSTANCE = eINSTANCE.getHostInstance(); + + /** + * The meta object literal for the 'Type' container reference feature. + * + * + * @generated + */ + EReference HOST_INSTANCE__TYPE = eINSTANCE.getHostInstance_Type(); + + /** + * The meta object literal for the 'Available Memory' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__AVAILABLE_MEMORY = eINSTANCE.getHostInstance_AvailableMemory(); + + /** + * The meta object literal for the 'Available Hdd' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__AVAILABLE_HDD = eINSTANCE.getHostInstance_AvailableHdd(); + + /** + * The meta object literal for the 'Total Memory' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__TOTAL_MEMORY = eINSTANCE.getHostInstance_TotalMemory(); + + /** + * The meta object literal for the 'Total Hdd' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__TOTAL_HDD = eINSTANCE.getHostInstance_TotalHdd(); + + /** + * The meta object literal for the 'Applications' reference list feature. + * + * + * @generated + */ + EReference HOST_INSTANCE__APPLICATIONS = eINSTANCE.getHostInstance_Applications(); + + } + +} //CpsPackage diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java new file mode 100644 index 00000000..541916ba --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java @@ -0,0 +1,112 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Cyber Physical System'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests Requests}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes Application Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes Host Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts Hosts}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications Applications}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem() + * @model + * @generated + */ +public interface CyberPhysicalSystem extends EObject { + /** + * Returns the value of the 'Requests' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.Request}. + * + *

+ * If the meaning of the 'Requests' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requests' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Requests() + * @model containment="true" + * @generated + */ + EList getRequests(); + + /** + * Returns the value of the 'Application Types' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType}. + * + *

+ * If the meaning of the 'Application Types' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Application Types' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_ApplicationTypes() + * @model containment="true" + * @generated + */ + EList getApplicationTypes(); + + /** + * Returns the value of the 'Host Types' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType}. + * + *

+ * If the meaning of the 'Host Types' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Host Types' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_HostTypes() + * @model containment="true" + * @generated + */ + EList getHostTypes(); + + /** + * Returns the value of the 'Hosts' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance}. + * + *

+ * If the meaning of the 'Hosts' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Hosts' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Hosts() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts'" + * @generated + */ + EList getHosts(); + + /** + * Returns the value of the 'Applications' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * + *

+ * If the meaning of the 'Applications' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Applications' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Applications() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications'" + * @generated + */ + EList getApplications(); + +} // CyberPhysicalSystem diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java new file mode 100644 index 00000000..43379e0f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java @@ -0,0 +1,141 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Host Instance'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory Available Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd Available Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory Total Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd Total Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance() + * @model + * @generated + */ +public interface HostInstance extends EObject { + /** + * Returns the value of the 'Type' container reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances Instances}'. + * + *

+ * If the meaning of the 'Type' container reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Type' container reference. + * @see #setType(HostType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_Type() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances + * @model opposite="instances" required="true" transient="false" + * @generated + */ + HostType getType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}' container reference. + * + * + * @param value the new value of the 'Type' container reference. + * @see #getType() + * @generated + */ + void setType(HostType value); + + /** + * Returns the value of the 'Available Memory' attribute. + * + *

+ * If the meaning of the 'Available Memory' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Available Memory' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_AvailableMemory() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory'" + * @generated + */ + int getAvailableMemory(); + + /** + * Returns the value of the 'Available Hdd' attribute. + * + *

+ * If the meaning of the 'Available Hdd' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Available Hdd' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_AvailableHdd() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd'" + * @generated + */ + int getAvailableHdd(); + + /** + * Returns the value of the 'Total Memory' attribute. + * + *

+ * If the meaning of the 'Total Memory' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Total Memory' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_TotalMemory() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory'" + * @generated + */ + int getTotalMemory(); + + /** + * Returns the value of the 'Total Hdd' attribute. + * + *

+ * If the meaning of the 'Total Hdd' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Total Hdd' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_TotalHdd() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd'" + * @generated + */ + int getTotalHdd(); + + /** + * Returns the value of the 'Applications' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}'. + * + *

+ * If the meaning of the 'Applications' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Applications' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_Applications() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo + * @model opposite="allocatedTo" + * @generated + */ + EList getApplications(); + +} // HostInstance diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java new file mode 100644 index 00000000..45201930 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java @@ -0,0 +1,125 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Host Type'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory Default Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd Default Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost Cost}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType() + * @model + * @generated + */ +public interface HostType extends EObject { + /** + * Returns the value of the 'Default Memory' attribute. + * + *

+ * If the meaning of the 'Default Memory' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Default Memory' attribute. + * @see #setDefaultMemory(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_DefaultMemory() + * @model required="true" + * @generated + */ + int getDefaultMemory(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory Default Memory}' attribute. + * + * + * @param value the new value of the 'Default Memory' attribute. + * @see #getDefaultMemory() + * @generated + */ + void setDefaultMemory(int value); + + /** + * Returns the value of the 'Default Hdd' attribute. + * + *

+ * If the meaning of the 'Default Hdd' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Default Hdd' attribute. + * @see #setDefaultHdd(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_DefaultHdd() + * @model required="true" + * @generated + */ + int getDefaultHdd(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd Default Hdd}' attribute. + * + * + * @param value the new value of the 'Default Hdd' attribute. + * @see #getDefaultHdd() + * @generated + */ + void setDefaultHdd(int value); + + /** + * Returns the value of the 'Instances' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}'. + * + *

+ * If the meaning of the 'Instances' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Instances' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_Instances() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType + * @model opposite="type" containment="true" + * @generated + */ + EList getInstances(); + + /** + * Returns the value of the 'Cost' attribute. + * + *

+ * If the meaning of the 'Cost' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Cost' attribute. + * @see #setCost(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_Cost() + * @model required="true" + * @generated + */ + int getCost(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost Cost}' attribute. + * + * + * @param value the new value of the 'Cost' attribute. + * @see #getCost() + * @generated + */ + void setCost(int value); + +} // HostType diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java new file mode 100644 index 00000000..261562a0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java @@ -0,0 +1,44 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Request'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements Requirements}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequest() + * @model + * @generated + */ +public interface Request extends EObject { + /** + * Returns the value of the 'Requirements' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}'. + * + *

+ * If the meaning of the 'Requirements' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requirements' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequest_Requirements() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest + * @model opposite="request" containment="true" + * @generated + */ + EList getRequirements(); + +} // Request diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java new file mode 100644 index 00000000..a1d494e4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java @@ -0,0 +1,127 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Requirement'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount Count}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances Instances}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement() + * @model + * @generated + */ +public interface Requirement extends EObject { + /** + * Returns the value of the 'Request' container reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements Requirements}'. + * + *

+ * If the meaning of the 'Request' container reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Request' container reference. + * @see #setRequest(Request) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Request() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements + * @model opposite="requirements" required="true" transient="false" + * @generated + */ + Request getRequest(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}' container reference. + * + * + * @param value the new value of the 'Request' container reference. + * @see #getRequest() + * @generated + */ + void setRequest(Request value); + + /** + * Returns the value of the 'Count' attribute. + * + *

+ * If the meaning of the 'Count' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Count' attribute. + * @see #setCount(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Count() + * @model required="true" + * @generated + */ + int getCount(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount Count}' attribute. + * + * + * @param value the new value of the 'Count' attribute. + * @see #getCount() + * @generated + */ + void setCount(int value); + + /** + * Returns the value of the 'Type' reference. + * + *

+ * If the meaning of the 'Type' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Type' reference. + * @see #setType(ApplicationType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Type() + * @model + * @generated + */ + ApplicationType getType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType Type}' reference. + * + * + * @param value the new value of the 'Type' reference. + * @see #getType() + * @generated + */ + void setType(ApplicationType value); + + /** + * Returns the value of the 'Instances' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}'. + * + *

+ * If the meaning of the 'Instances' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Instances' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Instances() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement + * @model opposite="requirement" + * @generated + */ + EList getInstances(); + +} // Requirement diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java new file mode 100644 index 00000000..a99cc12e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java @@ -0,0 +1,104 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Resource Requirement'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory Required Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd Required Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType Host Type}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement() + * @model + * @generated + */ +public interface ResourceRequirement extends EObject { + /** + * Returns the value of the 'Required Memory' attribute. + * + *

+ * If the meaning of the 'Required Memory' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Required Memory' attribute. + * @see #setRequiredMemory(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_RequiredMemory() + * @model required="true" + * @generated + */ + int getRequiredMemory(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory Required Memory}' attribute. + * + * + * @param value the new value of the 'Required Memory' attribute. + * @see #getRequiredMemory() + * @generated + */ + void setRequiredMemory(int value); + + /** + * Returns the value of the 'Required Hdd' attribute. + * + *

+ * If the meaning of the 'Required Hdd' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Required Hdd' attribute. + * @see #setRequiredHdd(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_RequiredHdd() + * @model required="true" + * @generated + */ + int getRequiredHdd(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd Required Hdd}' attribute. + * + * + * @param value the new value of the 'Required Hdd' attribute. + * @see #getRequiredHdd() + * @generated + */ + void setRequiredHdd(int value); + + /** + * Returns the value of the 'Host Type' reference. + * + *

+ * If the meaning of the 'Host Type' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Host Type' reference. + * @see #setHostType(HostType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_HostType() + * @model required="true" + * @generated + */ + HostType getHostType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType Host Type}' reference. + * + * + * @param value the new value of the 'Host Type' reference. + * @see #getHostType() + * @generated + */ + void setHostType(HostType value); + +} // ResourceRequirement diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java new file mode 100644 index 00000000..cea2d6f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java @@ -0,0 +1,405 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Application Instance'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getRequirement Requirement}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getAllocatedTo Allocated To}
  • + *
+ * + * @generated + */ +public class ApplicationInstanceImpl extends MinimalEObjectImpl.Container implements ApplicationInstance { + /** + * The cached value of the '{@link #getRequirement() Requirement}' reference. + * + * + * @see #getRequirement() + * @generated + * @ordered + */ + protected Requirement requirement; + + /** + * The cached value of the '{@link #getAllocatedTo() Allocated To}' reference. + * + * + * @see #getAllocatedTo() + * @generated + * @ordered + */ + protected HostInstance allocatedTo; + + /** + * + * + * @generated + */ + protected ApplicationInstanceImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.APPLICATION_INSTANCE; + } + + /** + * + * + * @generated + */ + @Override + public Requirement getRequirement() { + if (requirement != null && requirement.eIsProxy()) { + InternalEObject oldRequirement = (InternalEObject) requirement; + requirement = (Requirement) eResolveProxy(oldRequirement); + if (requirement != oldRequirement) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, + CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, oldRequirement, requirement)); + } + } + return requirement; + } + + /** + * + * + * @generated + */ + public Requirement basicGetRequirement() { + return requirement; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetRequirement(Requirement newRequirement, NotificationChain msgs) { + Requirement oldRequirement = requirement; + requirement = newRequirement; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, + CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, oldRequirement, newRequirement); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setRequirement(Requirement newRequirement) { + if (newRequirement != requirement) { + NotificationChain msgs = null; + if (requirement != null) + msgs = ((InternalEObject) requirement).eInverseRemove(this, CpsPackage.REQUIREMENT__INSTANCES, + Requirement.class, msgs); + if (newRequirement != null) + msgs = ((InternalEObject) newRequirement).eInverseAdd(this, CpsPackage.REQUIREMENT__INSTANCES, + Requirement.class, msgs); + msgs = basicSetRequirement(newRequirement, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, + newRequirement, newRequirement)); + } + + /** + * + * + * @generated + */ + @Override + public ApplicationType getType() { + if (eContainerFeatureID() != CpsPackage.APPLICATION_INSTANCE__TYPE) + return null; + return (ApplicationType) eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetType(ApplicationType newType, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.APPLICATION_INSTANCE__TYPE, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setType(ApplicationType newType) { + if (newType != eInternalContainer() + || (eContainerFeatureID() != CpsPackage.APPLICATION_INSTANCE__TYPE && newType != null)) { + if (EcoreUtil.isAncestor(this, newType)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newType != null) + msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.APPLICATION_TYPE__INSTANCES, + ApplicationType.class, msgs); + msgs = basicSetType(newType, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__TYPE, newType, + newType)); + } + + /** + * + * + * @generated + */ + @Override + public HostInstance getAllocatedTo() { + if (allocatedTo != null && allocatedTo.eIsProxy()) { + InternalEObject oldAllocatedTo = (InternalEObject) allocatedTo; + allocatedTo = (HostInstance) eResolveProxy(oldAllocatedTo); + if (allocatedTo != oldAllocatedTo) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, + CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, oldAllocatedTo, allocatedTo)); + } + } + return allocatedTo; + } + + /** + * + * + * @generated + */ + public HostInstance basicGetAllocatedTo() { + return allocatedTo; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetAllocatedTo(HostInstance newAllocatedTo, NotificationChain msgs) { + HostInstance oldAllocatedTo = allocatedTo; + allocatedTo = newAllocatedTo; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, + CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, oldAllocatedTo, newAllocatedTo); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setAllocatedTo(HostInstance newAllocatedTo) { + if (newAllocatedTo != allocatedTo) { + NotificationChain msgs = null; + if (allocatedTo != null) + msgs = ((InternalEObject) allocatedTo).eInverseRemove(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, + HostInstance.class, msgs); + if (newAllocatedTo != null) + msgs = ((InternalEObject) newAllocatedTo).eInverseAdd(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, + HostInstance.class, msgs); + msgs = basicSetAllocatedTo(newAllocatedTo, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, + newAllocatedTo, newAllocatedTo)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + if (requirement != null) + msgs = ((InternalEObject) requirement).eInverseRemove(this, CpsPackage.REQUIREMENT__INSTANCES, + Requirement.class, msgs); + return basicSetRequirement((Requirement) otherEnd, msgs); + case CpsPackage.APPLICATION_INSTANCE__TYPE: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetType((ApplicationType) otherEnd, msgs); + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + if (allocatedTo != null) + msgs = ((InternalEObject) allocatedTo).eInverseRemove(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, + HostInstance.class, msgs); + return basicSetAllocatedTo((HostInstance) otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + return basicSetRequirement(null, msgs); + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return basicSetType(null, msgs); + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + return basicSetAllocatedTo(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return eInternalContainer().eInverseRemove(this, CpsPackage.APPLICATION_TYPE__INSTANCES, + ApplicationType.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + if (resolve) + return getRequirement(); + return basicGetRequirement(); + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return getType(); + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + if (resolve) + return getAllocatedTo(); + return basicGetAllocatedTo(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + setRequirement((Requirement) newValue); + return; + case CpsPackage.APPLICATION_INSTANCE__TYPE: + setType((ApplicationType) newValue); + return; + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + setAllocatedTo((HostInstance) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + setRequirement((Requirement) null); + return; + case CpsPackage.APPLICATION_INSTANCE__TYPE: + setType((ApplicationType) null); + return; + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + setAllocatedTo((HostInstance) null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + return requirement != null; + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return getType() != null; + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + return allocatedTo != null; + } + return super.eIsSet(featureID); + } + +} //ApplicationInstanceImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java new file mode 100644 index 00000000..f8793e30 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java @@ -0,0 +1,209 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Application Type'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl#getRequirements Requirements}
  • + *
+ * + * @generated + */ +public class ApplicationTypeImpl extends MinimalEObjectImpl.Container implements ApplicationType { + /** + * The cached value of the '{@link #getInstances() Instances}' containment reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * The cached value of the '{@link #getRequirements() Requirements}' containment reference list. + * + * + * @see #getRequirements() + * @generated + * @ordered + */ + protected EList requirements; + + /** + * + * + * @generated + */ + protected ApplicationTypeImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.APPLICATION_TYPE; + } + + /** + * + * + * @generated + */ + @Override + public EList getInstances() { + if (instances == null) { + instances = new EObjectContainmentWithInverseEList(ApplicationInstance.class, this, + CpsPackage.APPLICATION_TYPE__INSTANCES, CpsPackage.APPLICATION_INSTANCE__TYPE); + } + return instances; + } + + /** + * + * + * @generated + */ + @Override + public EList getRequirements() { + if (requirements == null) { + requirements = new EObjectContainmentEList(ResourceRequirement.class, this, + CpsPackage.APPLICATION_TYPE__REQUIREMENTS); + } + return requirements; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + return ((InternalEList) getRequirements()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return getInstances(); + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + return getRequirements(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection) newValue); + return; + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + getRequirements().clear(); + getRequirements().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + getInstances().clear(); + return; + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + getRequirements().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return instances != null && !instances.isEmpty(); + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + return requirements != null && !requirements.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //ApplicationTypeImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java new file mode 100644 index 00000000..110f5abb --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java @@ -0,0 +1,188 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class CpsFactoryImpl extends EFactoryImpl implements CpsFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static CpsFactory init() { + try { + CpsFactory theCpsFactory = (CpsFactory) EPackage.Registry.INSTANCE.getEFactory(CpsPackage.eNS_URI); + if (theCpsFactory != null) { + return theCpsFactory; + } + } catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new CpsFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public CpsFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM: + return createCyberPhysicalSystem(); + case CpsPackage.APPLICATION_TYPE: + return createApplicationType(); + case CpsPackage.HOST_TYPE: + return createHostType(); + case CpsPackage.REQUEST: + return createRequest(); + case CpsPackage.REQUIREMENT: + return createRequirement(); + case CpsPackage.APPLICATION_INSTANCE: + return createApplicationInstance(); + case CpsPackage.RESOURCE_REQUIREMENT: + return createResourceRequirement(); + case CpsPackage.HOST_INSTANCE: + return createHostInstance(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public CyberPhysicalSystem createCyberPhysicalSystem() { + CyberPhysicalSystemImpl cyberPhysicalSystem = new CyberPhysicalSystemImpl(); + return cyberPhysicalSystem; + } + + /** + * + * + * @generated + */ + @Override + public ApplicationType createApplicationType() { + ApplicationTypeImpl applicationType = new ApplicationTypeImpl(); + return applicationType; + } + + /** + * + * + * @generated + */ + @Override + public HostType createHostType() { + HostTypeImpl hostType = new HostTypeImpl(); + return hostType; + } + + /** + * + * + * @generated + */ + @Override + public Request createRequest() { + RequestImpl request = new RequestImpl(); + return request; + } + + /** + * + * + * @generated + */ + @Override + public Requirement createRequirement() { + RequirementImpl requirement = new RequirementImpl(); + return requirement; + } + + /** + * + * + * @generated + */ + @Override + public ApplicationInstance createApplicationInstance() { + ApplicationInstanceImpl applicationInstance = new ApplicationInstanceImpl(); + return applicationInstance; + } + + /** + * + * + * @generated + */ + @Override + public ResourceRequirement createResourceRequirement() { + ResourceRequirementImpl resourceRequirement = new ResourceRequirementImpl(); + return resourceRequirement; + } + + /** + * + * + * @generated + */ + @Override + public HostInstance createHostInstance() { + HostInstanceImpl hostInstance = new HostInstanceImpl(); + return hostInstance; + } + + /** + * + * + * @generated + */ + @Override + public CpsPackage getCpsPackage() { + return (CpsPackage) getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static CpsPackage getPackage() { + return CpsPackage.eINSTANCE; + } + +} //CpsFactoryImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java new file mode 100644 index 00000000..1f143a64 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java @@ -0,0 +1,765 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class CpsPackageImpl extends EPackageImpl implements CpsPackage { + /** + * + * + * @generated + */ + private EClass cyberPhysicalSystemEClass = null; + + /** + * + * + * @generated + */ + private EClass applicationTypeEClass = null; + + /** + * + * + * @generated + */ + private EClass hostTypeEClass = null; + + /** + * + * + * @generated + */ + private EClass requestEClass = null; + + /** + * + * + * @generated + */ + private EClass requirementEClass = null; + + /** + * + * + * @generated + */ + private EClass applicationInstanceEClass = null; + + /** + * + * + * @generated + */ + private EClass resourceRequirementEClass = null; + + /** + * + * + * @generated + */ + private EClass hostInstanceEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#eNS_URI + * @see #init() + * @generated + */ + private CpsPackageImpl() { + super(eNS_URI, CpsFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link CpsPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static CpsPackage init() { + if (isInited) + return (CpsPackage) EPackage.Registry.INSTANCE.getEPackage(CpsPackage.eNS_URI); + + // Obtain or create and register package + Object registeredCpsPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + CpsPackageImpl theCpsPackage = registeredCpsPackage instanceof CpsPackageImpl + ? (CpsPackageImpl) registeredCpsPackage + : new CpsPackageImpl(); + + isInited = true; + + // Create package meta-data objects + theCpsPackage.createPackageContents(); + + // Initialize created meta-data + theCpsPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theCpsPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, theCpsPackage); + return theCpsPackage; + } + + /** + * + * + * @generated + */ + @Override + public EClass getCyberPhysicalSystem() { + return cyberPhysicalSystemEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_Requests() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_ApplicationTypes() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_HostTypes() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_Hosts() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_Applications() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + @Override + public EClass getApplicationType() { + return applicationTypeEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationType_Instances() { + return (EReference) applicationTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationType_Requirements() { + return (EReference) applicationTypeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EClass getHostType() { + return hostTypeEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostType_DefaultMemory() { + return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostType_DefaultHdd() { + return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getHostType_Instances() { + return (EReference) hostTypeEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostType_Cost() { + return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EClass getRequest() { + return requestEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequest_Requirements() { + return (EReference) requestEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getRequirement() { + return requirementEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequirement_Request() { + return (EReference) requirementEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getRequirement_Count() { + return (EAttribute) requirementEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequirement_Type() { + return (EReference) requirementEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequirement_Instances() { + return (EReference) requirementEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EClass getApplicationInstance() { + return applicationInstanceEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationInstance_Requirement() { + return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationInstance_Type() { + return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationInstance_AllocatedTo() { + return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getResourceRequirement() { + return resourceRequirementEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getResourceRequirement_RequiredMemory() { + return (EAttribute) resourceRequirementEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getResourceRequirement_RequiredHdd() { + return (EAttribute) resourceRequirementEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getResourceRequirement_HostType() { + return (EReference) resourceRequirementEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getHostInstance() { + return hostInstanceEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getHostInstance_Type() { + return (EReference) hostInstanceEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_AvailableMemory() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_AvailableHdd() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_TotalMemory() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_TotalHdd() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + @Override + public EReference getHostInstance_Applications() { + return (EReference) hostInstanceEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + @Override + public CpsFactory getCpsFactory() { + return (CpsFactory) getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) + return; + isCreated = true; + + // Create classes and their features + cyberPhysicalSystemEClass = createEClass(CYBER_PHYSICAL_SYSTEM); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__REQUESTS); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOST_TYPES); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOSTS); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATIONS); + + applicationTypeEClass = createEClass(APPLICATION_TYPE); + createEReference(applicationTypeEClass, APPLICATION_TYPE__INSTANCES); + createEReference(applicationTypeEClass, APPLICATION_TYPE__REQUIREMENTS); + + hostTypeEClass = createEClass(HOST_TYPE); + createEAttribute(hostTypeEClass, HOST_TYPE__DEFAULT_MEMORY); + createEAttribute(hostTypeEClass, HOST_TYPE__DEFAULT_HDD); + createEReference(hostTypeEClass, HOST_TYPE__INSTANCES); + createEAttribute(hostTypeEClass, HOST_TYPE__COST); + + requestEClass = createEClass(REQUEST); + createEReference(requestEClass, REQUEST__REQUIREMENTS); + + requirementEClass = createEClass(REQUIREMENT); + createEReference(requirementEClass, REQUIREMENT__REQUEST); + createEAttribute(requirementEClass, REQUIREMENT__COUNT); + createEReference(requirementEClass, REQUIREMENT__TYPE); + createEReference(requirementEClass, REQUIREMENT__INSTANCES); + + applicationInstanceEClass = createEClass(APPLICATION_INSTANCE); + createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__REQUIREMENT); + createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__TYPE); + createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__ALLOCATED_TO); + + resourceRequirementEClass = createEClass(RESOURCE_REQUIREMENT); + createEAttribute(resourceRequirementEClass, RESOURCE_REQUIREMENT__REQUIRED_MEMORY); + createEAttribute(resourceRequirementEClass, RESOURCE_REQUIREMENT__REQUIRED_HDD); + createEReference(resourceRequirementEClass, RESOURCE_REQUIREMENT__HOST_TYPE); + + hostInstanceEClass = createEClass(HOST_INSTANCE); + createEReference(hostInstanceEClass, HOST_INSTANCE__TYPE); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__AVAILABLE_MEMORY); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__AVAILABLE_HDD); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__TOTAL_MEMORY); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__TOTAL_HDD); + createEReference(hostInstanceEClass, HOST_INSTANCE__APPLICATIONS); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) + return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(cyberPhysicalSystemEClass, CyberPhysicalSystem.class, "CyberPhysicalSystem", !IS_ABSTRACT, + !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getCyberPhysicalSystem_Requests(), this.getRequest(), null, "requests", null, 0, -1, + CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_ApplicationTypes(), this.getApplicationType(), null, "applicationTypes", + null, 0, -1, CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_HostTypes(), this.getHostType(), null, "hostTypes", null, 0, -1, + CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_Hosts(), this.getHostInstance(), null, "hosts", null, 0, -1, + CyberPhysicalSystem.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_Applications(), this.getApplicationInstance(), null, "applications", null, + 0, -1, CyberPhysicalSystem.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, + IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + initEClass(applicationTypeEClass, ApplicationType.class, "ApplicationType", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getApplicationType_Instances(), this.getApplicationInstance(), + this.getApplicationInstance_Type(), "instances", null, 0, -1, ApplicationType.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, + IS_ORDERED); + initEReference(getApplicationType_Requirements(), this.getResourceRequirement(), null, "requirements", null, 0, + -1, ApplicationType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(hostTypeEClass, HostType.class, "HostType", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getHostType_DefaultMemory(), ecorePackage.getEInt(), "defaultMemory", null, 1, 1, HostType.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getHostType_DefaultHdd(), ecorePackage.getEInt(), "defaultHdd", null, 1, 1, HostType.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getHostType_Instances(), this.getHostInstance(), this.getHostInstance_Type(), "instances", null, + 0, -1, HostType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getHostType_Cost(), ecorePackage.getEInt(), "cost", null, 1, 1, HostType.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(requestEClass, Request.class, "Request", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getRequest_Requirements(), this.getRequirement(), this.getRequirement_Request(), "requirements", + null, 0, -1, Request.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(requirementEClass, Requirement.class, "Requirement", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getRequirement_Request(), this.getRequest(), this.getRequest_Requirements(), "request", null, 1, + 1, Requirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getRequirement_Count(), ecorePackage.getEInt(), "count", null, 1, 1, Requirement.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getRequirement_Type(), this.getApplicationType(), null, "type", null, 0, 1, Requirement.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getRequirement_Instances(), this.getApplicationInstance(), + this.getApplicationInstance_Requirement(), "instances", null, 0, -1, Requirement.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, + IS_ORDERED); + + initEClass(applicationInstanceEClass, ApplicationInstance.class, "ApplicationInstance", !IS_ABSTRACT, + !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getApplicationInstance_Requirement(), this.getRequirement(), this.getRequirement_Instances(), + "requirement", null, 0, 1, ApplicationInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getApplicationInstance_Type(), this.getApplicationType(), this.getApplicationType_Instances(), + "type", null, 1, 1, ApplicationInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getApplicationInstance_AllocatedTo(), this.getHostInstance(), + this.getHostInstance_Applications(), "allocatedTo", null, 1, 1, ApplicationInstance.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(resourceRequirementEClass, ResourceRequirement.class, "ResourceRequirement", !IS_ABSTRACT, + !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getResourceRequirement_RequiredMemory(), ecorePackage.getEInt(), "requiredMemory", null, 1, 1, + ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getResourceRequirement_RequiredHdd(), ecorePackage.getEInt(), "requiredHdd", null, 1, 1, + ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getResourceRequirement_HostType(), this.getHostType(), null, "hostType", null, 1, 1, + ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, + IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(hostInstanceEClass, HostInstance.class, "HostInstance", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getHostInstance_Type(), this.getHostType(), this.getHostType_Instances(), "type", null, 1, 1, + HostInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_AvailableMemory(), ecorePackage.getEInt(), "availableMemory", null, 0, 1, + HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_AvailableHdd(), ecorePackage.getEInt(), "availableHdd", null, 0, 1, + HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_TotalMemory(), ecorePackage.getEInt(), "totalMemory", null, 0, 1, + HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_TotalHdd(), ecorePackage.getEInt(), "totalHdd", null, 0, 1, HostInstance.class, + IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getHostInstance_Applications(), this.getApplicationInstance(), + this.getApplicationInstance_AllocatedTo(), "applications", null, 0, -1, HostInstance.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http://www.eclipse.org/emf/2002/Ecore + createEcoreAnnotations(); + // org.eclipse.viatra.query.querybasedfeature + createOrgAnnotations(); + } + + /** + * Initializes the annotations for http://www.eclipse.org/emf/2002/Ecore. + * + * + * @generated + */ + protected void createEcoreAnnotations() { + String source = "http://www.eclipse.org/emf/2002/Ecore"; + addAnnotation(this, source, new String[] { "settingDelegates", "org.eclipse.viatra.query.querybasedfeature" }); + } + + /** + * Initializes the annotations for org.eclipse.viatra.query.querybasedfeature. + * + * + * @generated + */ + protected void createOrgAnnotations() { + String source = "org.eclipse.viatra.query.querybasedfeature"; + addAnnotation(getCyberPhysicalSystem_Hosts(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts" }); + addAnnotation(getCyberPhysicalSystem_Applications(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications" }); + addAnnotation(getHostInstance_AvailableMemory(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory" }); + addAnnotation(getHostInstance_AvailableHdd(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd" }); + addAnnotation(getHostInstance_TotalMemory(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory" }); + addAnnotation(getHostInstance_TotalHdd(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd" }); + } + +} //CpsPackageImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java new file mode 100644 index 00000000..4d254f25 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java @@ -0,0 +1,289 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Cyber Physical System'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getRequests Requests}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplicationTypes Application Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHostTypes Host Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHosts Hosts}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplications Applications}
  • + *
+ * + * @generated + */ +public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implements CyberPhysicalSystem { + /** + * The cached value of the '{@link #getRequests() Requests}' containment reference list. + * + * + * @see #getRequests() + * @generated + * @ordered + */ + protected EList requests; + + /** + * The cached value of the '{@link #getApplicationTypes() Application Types}' containment reference list. + * + * + * @see #getApplicationTypes() + * @generated + * @ordered + */ + protected EList applicationTypes; + + /** + * The cached value of the '{@link #getHostTypes() Host Types}' containment reference list. + * + * + * @see #getHostTypes() + * @generated + * @ordered + */ + protected EList hostTypes; + + /** + * The cached setting delegate for the '{@link #getHosts() Hosts}' reference list. + * + * + * @see #getHosts() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate HOSTS__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM__HOSTS) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getApplications() Applications}' reference list. + * + * + * @see #getApplications() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate APPLICATIONS__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM__APPLICATIONS) + .getSettingDelegate(); + + /** + * + * + * @generated + */ + protected CyberPhysicalSystemImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM; + } + + /** + * + * + * @generated + */ + @Override + public EList getRequests() { + if (requests == null) { + requests = new EObjectContainmentEList(Request.class, this, + CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS); + } + return requests; + } + + /** + * + * + * @generated + */ + @Override + public EList getApplicationTypes() { + if (applicationTypes == null) { + applicationTypes = new EObjectContainmentEList(ApplicationType.class, this, + CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); + } + return applicationTypes; + } + + /** + * + * + * @generated + */ + @Override + public EList getHostTypes() { + if (hostTypes == null) { + hostTypes = new EObjectContainmentEList(HostType.class, this, + CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES); + } + return hostTypes; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public EList getHosts() { + return (EList) HOSTS__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public EList getApplications() { + return (EList) APPLICATIONS__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + return ((InternalEList) getRequests()).basicRemove(otherEnd, msgs); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + return ((InternalEList) getApplicationTypes()).basicRemove(otherEnd, msgs); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + return ((InternalEList) getHostTypes()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + return getRequests(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + return getApplicationTypes(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + return getHostTypes(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOSTS: + return getHosts(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATIONS: + return getApplications(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + getRequests().clear(); + getRequests().addAll((Collection) newValue); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + getApplicationTypes().clear(); + getApplicationTypes().addAll((Collection) newValue); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + getHostTypes().clear(); + getHostTypes().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + getRequests().clear(); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + getApplicationTypes().clear(); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + getHostTypes().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + return requests != null && !requests.isEmpty(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + return applicationTypes != null && !applicationTypes.isEmpty(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + return hostTypes != null && !hostTypes.isEmpty(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOSTS: + return HOSTS__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATIONS: + return APPLICATIONS__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + } + return super.eIsSet(featureID); + } + +} //CyberPhysicalSystemImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java new file mode 100644 index 00000000..bbaca59c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java @@ -0,0 +1,355 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Host Instance'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getAvailableMemory Available Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getAvailableHdd Available Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getTotalMemory Total Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getTotalHdd Total Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getApplications Applications}
  • + *
+ * + * @generated + */ +public class HostInstanceImpl extends MinimalEObjectImpl.Container implements HostInstance { + /** + * The cached setting delegate for the '{@link #getAvailableMemory() Available Memory}' attribute. + * + * + * @see #getAvailableMemory() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate AVAILABLE_MEMORY__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__AVAILABLE_MEMORY) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getAvailableHdd() Available Hdd}' attribute. + * + * + * @see #getAvailableHdd() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate AVAILABLE_HDD__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__AVAILABLE_HDD) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getTotalMemory() Total Memory}' attribute. + * + * + * @see #getTotalMemory() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate TOTAL_MEMORY__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__TOTAL_MEMORY) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getTotalHdd() Total Hdd}' attribute. + * + * + * @see #getTotalHdd() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate TOTAL_HDD__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__TOTAL_HDD) + .getSettingDelegate(); + + /** + * The cached value of the '{@link #getApplications() Applications}' reference list. + * + * + * @see #getApplications() + * @generated + * @ordered + */ + protected EList applications; + + /** + * + * + * @generated + */ + protected HostInstanceImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.HOST_INSTANCE; + } + + /** + * + * + * @generated + */ + @Override + public HostType getType() { + if (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE) + return null; + return (HostType) eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetType(HostType newType, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.HOST_INSTANCE__TYPE, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setType(HostType newType) { + if (newType != eInternalContainer() + || (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE && newType != null)) { + if (EcoreUtil.isAncestor(this, newType)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newType != null) + msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, + msgs); + msgs = basicSetType(newType, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_INSTANCE__TYPE, newType, newType)); + } + + /** + * + * + * @generated + */ + @Override + public int getAvailableMemory() { + return (Integer) AVAILABLE_MEMORY__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public int getAvailableHdd() { + return (Integer) AVAILABLE_HDD__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public int getTotalMemory() { + return (Integer) TOTAL_MEMORY__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public int getTotalHdd() { + return (Integer) TOTAL_HDD__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public EList getApplications() { + if (applications == null) { + applications = new EObjectWithInverseResolvingEList(ApplicationInstance.class, this, + CpsPackage.HOST_INSTANCE__APPLICATIONS, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO); + } + return applications; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetType((HostType) otherEnd, msgs); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return ((InternalEList) (InternalEList) getApplications()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + return basicSetType(null, msgs); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return ((InternalEList) getApplications()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case CpsPackage.HOST_INSTANCE__TYPE: + return eInternalContainer().eInverseRemove(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + return getType(); + case CpsPackage.HOST_INSTANCE__AVAILABLE_MEMORY: + return getAvailableMemory(); + case CpsPackage.HOST_INSTANCE__AVAILABLE_HDD: + return getAvailableHdd(); + case CpsPackage.HOST_INSTANCE__TOTAL_MEMORY: + return getTotalMemory(); + case CpsPackage.HOST_INSTANCE__TOTAL_HDD: + return getTotalHdd(); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return getApplications(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + setType((HostType) newValue); + return; + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + getApplications().clear(); + getApplications().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + setType((HostType) null); + return; + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + getApplications().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + return getType() != null; + case CpsPackage.HOST_INSTANCE__AVAILABLE_MEMORY: + return AVAILABLE_MEMORY__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__AVAILABLE_HDD: + return AVAILABLE_HDD__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__TOTAL_MEMORY: + return TOTAL_MEMORY__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__TOTAL_HDD: + return TOTAL_HDD__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return applications != null && !applications.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //HostInstanceImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java new file mode 100644 index 00000000..c3d5b3dc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java @@ -0,0 +1,356 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Host Type'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getDefaultMemory Default Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getDefaultHdd Default Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getCost Cost}
  • + *
+ * + * @generated + */ +public class HostTypeImpl extends MinimalEObjectImpl.Container implements HostType { + /** + * The default value of the '{@link #getDefaultMemory() Default Memory}' attribute. + * + * + * @see #getDefaultMemory() + * @generated + * @ordered + */ + protected static final int DEFAULT_MEMORY_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getDefaultMemory() Default Memory}' attribute. + * + * + * @see #getDefaultMemory() + * @generated + * @ordered + */ + protected int defaultMemory = DEFAULT_MEMORY_EDEFAULT; + + /** + * The default value of the '{@link #getDefaultHdd() Default Hdd}' attribute. + * + * + * @see #getDefaultHdd() + * @generated + * @ordered + */ + protected static final int DEFAULT_HDD_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getDefaultHdd() Default Hdd}' attribute. + * + * + * @see #getDefaultHdd() + * @generated + * @ordered + */ + protected int defaultHdd = DEFAULT_HDD_EDEFAULT; + + /** + * The cached value of the '{@link #getInstances() Instances}' containment reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * The default value of the '{@link #getCost() Cost}' attribute. + * + * + * @see #getCost() + * @generated + * @ordered + */ + protected static final int COST_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getCost() Cost}' attribute. + * + * + * @see #getCost() + * @generated + * @ordered + */ + protected int cost = COST_EDEFAULT; + + /** + * + * + * @generated + */ + protected HostTypeImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.HOST_TYPE; + } + + /** + * + * + * @generated + */ + @Override + public int getDefaultMemory() { + return defaultMemory; + } + + /** + * + * + * @generated + */ + @Override + public void setDefaultMemory(int newDefaultMemory) { + int oldDefaultMemory = defaultMemory; + defaultMemory = newDefaultMemory; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__DEFAULT_MEMORY, + oldDefaultMemory, defaultMemory)); + } + + /** + * + * + * @generated + */ + @Override + public int getDefaultHdd() { + return defaultHdd; + } + + /** + * + * + * @generated + */ + @Override + public void setDefaultHdd(int newDefaultHdd) { + int oldDefaultHdd = defaultHdd; + defaultHdd = newDefaultHdd; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__DEFAULT_HDD, oldDefaultHdd, + defaultHdd)); + } + + /** + * + * + * @generated + */ + @Override + public EList getInstances() { + if (instances == null) { + instances = new EObjectContainmentWithInverseEList(HostInstance.class, this, + CpsPackage.HOST_TYPE__INSTANCES, CpsPackage.HOST_INSTANCE__TYPE); + } + return instances; + } + + /** + * + * + * @generated + */ + @Override + public int getCost() { + return cost; + } + + /** + * + * + * @generated + */ + @Override + public void setCost(int newCost) { + int oldCost = cost; + cost = newCost; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__COST, oldCost, cost)); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_TYPE__INSTANCES: + return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_TYPE__INSTANCES: + return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + return getDefaultMemory(); + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + return getDefaultHdd(); + case CpsPackage.HOST_TYPE__INSTANCES: + return getInstances(); + case CpsPackage.HOST_TYPE__COST: + return getCost(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + setDefaultMemory((Integer) newValue); + return; + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + setDefaultHdd((Integer) newValue); + return; + case CpsPackage.HOST_TYPE__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection) newValue); + return; + case CpsPackage.HOST_TYPE__COST: + setCost((Integer) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + setDefaultMemory(DEFAULT_MEMORY_EDEFAULT); + return; + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + setDefaultHdd(DEFAULT_HDD_EDEFAULT); + return; + case CpsPackage.HOST_TYPE__INSTANCES: + getInstances().clear(); + return; + case CpsPackage.HOST_TYPE__COST: + setCost(COST_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + return defaultMemory != DEFAULT_MEMORY_EDEFAULT; + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + return defaultHdd != DEFAULT_HDD_EDEFAULT; + case CpsPackage.HOST_TYPE__INSTANCES: + return instances != null && !instances.isEmpty(); + case CpsPackage.HOST_TYPE__COST: + return cost != COST_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (defaultMemory: "); + result.append(defaultMemory); + result.append(", defaultHdd: "); + result.append(defaultHdd); + result.append(", cost: "); + result.append(cost); + result.append(')'); + return result.toString(); + } + +} //HostTypeImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java new file mode 100644 index 00000000..72b4c732 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java @@ -0,0 +1,169 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Request'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl#getRequirements Requirements}
  • + *
+ * + * @generated + */ +public class RequestImpl extends MinimalEObjectImpl.Container implements Request { + /** + * The cached value of the '{@link #getRequirements() Requirements}' containment reference list. + * + * + * @see #getRequirements() + * @generated + * @ordered + */ + protected EList requirements; + + /** + * + * + * @generated + */ + protected RequestImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.REQUEST; + } + + /** + * + * + * @generated + */ + @Override + public EList getRequirements() { + if (requirements == null) { + requirements = new EObjectContainmentWithInverseEList(Requirement.class, this, + CpsPackage.REQUEST__REQUIREMENTS, CpsPackage.REQUIREMENT__REQUEST); + } + return requirements; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return ((InternalEList) (InternalEList) getRequirements()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return ((InternalEList) getRequirements()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return getRequirements(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + getRequirements().clear(); + getRequirements().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + getRequirements().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return requirements != null && !requirements.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //RequestImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java new file mode 100644 index 00000000..79dc4f62 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java @@ -0,0 +1,387 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Requirement'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getRequest Request}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getCount Count}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getInstances Instances}
  • + *
+ * + * @generated + */ +public class RequirementImpl extends MinimalEObjectImpl.Container implements Requirement { + /** + * The default value of the '{@link #getCount() Count}' attribute. + * + * + * @see #getCount() + * @generated + * @ordered + */ + protected static final int COUNT_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getCount() Count}' attribute. + * + * + * @see #getCount() + * @generated + * @ordered + */ + protected int count = COUNT_EDEFAULT; + + /** + * The cached value of the '{@link #getType() Type}' reference. + * + * + * @see #getType() + * @generated + * @ordered + */ + protected ApplicationType type; + + /** + * The cached value of the '{@link #getInstances() Instances}' reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * + * + * @generated + */ + protected RequirementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.REQUIREMENT; + } + + /** + * + * + * @generated + */ + @Override + public Request getRequest() { + if (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST) + return null; + return (Request) eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetRequest(Request newRequest, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject) newRequest, CpsPackage.REQUIREMENT__REQUEST, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setRequest(Request newRequest) { + if (newRequest != eInternalContainer() + || (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST && newRequest != null)) { + if (EcoreUtil.isAncestor(this, newRequest)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newRequest != null) + msgs = ((InternalEObject) newRequest).eInverseAdd(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, + msgs); + msgs = basicSetRequest(newRequest, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__REQUEST, newRequest, + newRequest)); + } + + /** + * + * + * @generated + */ + @Override + public int getCount() { + return count; + } + + /** + * + * + * @generated + */ + @Override + public void setCount(int newCount) { + int oldCount = count; + count = newCount; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__COUNT, oldCount, count)); + } + + /** + * + * + * @generated + */ + @Override + public ApplicationType getType() { + if (type != null && type.eIsProxy()) { + InternalEObject oldType = (InternalEObject) type; + type = (ApplicationType) eResolveProxy(oldType); + if (type != oldType) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, CpsPackage.REQUIREMENT__TYPE, oldType, + type)); + } + } + return type; + } + + /** + * + * + * @generated + */ + public ApplicationType basicGetType() { + return type; + } + + /** + * + * + * @generated + */ + @Override + public void setType(ApplicationType newType) { + ApplicationType oldType = type; + type = newType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__TYPE, oldType, type)); + } + + /** + * + * + * @generated + */ + @Override + public EList getInstances() { + if (instances == null) { + instances = new EObjectWithInverseResolvingEList(ApplicationInstance.class, this, + CpsPackage.REQUIREMENT__INSTANCES, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT); + } + return instances; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetRequest((Request) otherEnd, msgs); + case CpsPackage.REQUIREMENT__INSTANCES: + return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + return basicSetRequest(null, msgs); + case CpsPackage.REQUIREMENT__INSTANCES: + return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case CpsPackage.REQUIREMENT__REQUEST: + return eInternalContainer().eInverseRemove(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + return getRequest(); + case CpsPackage.REQUIREMENT__COUNT: + return getCount(); + case CpsPackage.REQUIREMENT__TYPE: + if (resolve) + return getType(); + return basicGetType(); + case CpsPackage.REQUIREMENT__INSTANCES: + return getInstances(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + setRequest((Request) newValue); + return; + case CpsPackage.REQUIREMENT__COUNT: + setCount((Integer) newValue); + return; + case CpsPackage.REQUIREMENT__TYPE: + setType((ApplicationType) newValue); + return; + case CpsPackage.REQUIREMENT__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + setRequest((Request) null); + return; + case CpsPackage.REQUIREMENT__COUNT: + setCount(COUNT_EDEFAULT); + return; + case CpsPackage.REQUIREMENT__TYPE: + setType((ApplicationType) null); + return; + case CpsPackage.REQUIREMENT__INSTANCES: + getInstances().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + return getRequest() != null; + case CpsPackage.REQUIREMENT__COUNT: + return count != COUNT_EDEFAULT; + case CpsPackage.REQUIREMENT__TYPE: + return type != null; + case CpsPackage.REQUIREMENT__INSTANCES: + return instances != null && !instances.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (count: "); + result.append(count); + result.append(')'); + return result.toString(); + } + +} //RequirementImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java new file mode 100644 index 00000000..f4deb575 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java @@ -0,0 +1,291 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Resource Requirement'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getRequiredMemory Required Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getRequiredHdd Required Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getHostType Host Type}
  • + *
+ * + * @generated + */ +public class ResourceRequirementImpl extends MinimalEObjectImpl.Container implements ResourceRequirement { + /** + * The default value of the '{@link #getRequiredMemory() Required Memory}' attribute. + * + * + * @see #getRequiredMemory() + * @generated + * @ordered + */ + protected static final int REQUIRED_MEMORY_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getRequiredMemory() Required Memory}' attribute. + * + * + * @see #getRequiredMemory() + * @generated + * @ordered + */ + protected int requiredMemory = REQUIRED_MEMORY_EDEFAULT; + + /** + * The default value of the '{@link #getRequiredHdd() Required Hdd}' attribute. + * + * + * @see #getRequiredHdd() + * @generated + * @ordered + */ + protected static final int REQUIRED_HDD_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getRequiredHdd() Required Hdd}' attribute. + * + * + * @see #getRequiredHdd() + * @generated + * @ordered + */ + protected int requiredHdd = REQUIRED_HDD_EDEFAULT; + + /** + * The cached value of the '{@link #getHostType() Host Type}' reference. + * + * + * @see #getHostType() + * @generated + * @ordered + */ + protected HostType hostType; + + /** + * + * + * @generated + */ + protected ResourceRequirementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.RESOURCE_REQUIREMENT; + } + + /** + * + * + * @generated + */ + @Override + public int getRequiredMemory() { + return requiredMemory; + } + + /** + * + * + * @generated + */ + @Override + public void setRequiredMemory(int newRequiredMemory) { + int oldRequiredMemory = requiredMemory; + requiredMemory = newRequiredMemory; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY, + oldRequiredMemory, requiredMemory)); + } + + /** + * + * + * @generated + */ + @Override + public int getRequiredHdd() { + return requiredHdd; + } + + /** + * + * + * @generated + */ + @Override + public void setRequiredHdd(int newRequiredHdd) { + int oldRequiredHdd = requiredHdd; + requiredHdd = newRequiredHdd; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD, + oldRequiredHdd, requiredHdd)); + } + + /** + * + * + * @generated + */ + @Override + public HostType getHostType() { + if (hostType != null && hostType.eIsProxy()) { + InternalEObject oldHostType = (InternalEObject) hostType; + hostType = (HostType) eResolveProxy(oldHostType); + if (hostType != oldHostType) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, + CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE, oldHostType, hostType)); + } + } + return hostType; + } + + /** + * + * + * @generated + */ + public HostType basicGetHostType() { + return hostType; + } + + /** + * + * + * @generated + */ + @Override + public void setHostType(HostType newHostType) { + HostType oldHostType = hostType; + hostType = newHostType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE, + oldHostType, hostType)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + return getRequiredMemory(); + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + return getRequiredHdd(); + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + if (resolve) + return getHostType(); + return basicGetHostType(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + setRequiredMemory((Integer) newValue); + return; + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + setRequiredHdd((Integer) newValue); + return; + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + setHostType((HostType) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + setRequiredMemory(REQUIRED_MEMORY_EDEFAULT); + return; + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + setRequiredHdd(REQUIRED_HDD_EDEFAULT); + return; + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + setHostType((HostType) null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + return requiredMemory != REQUIRED_MEMORY_EDEFAULT; + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + return requiredHdd != REQUIRED_HDD_EDEFAULT; + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + return hostType != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (requiredMemory: "); + result.append(requiredMemory); + result.append(", requiredHdd: "); + result.append(requiredHdd); + result.append(')'); + return result.toString(); + } + +} //ResourceRequirementImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java new file mode 100644 index 00000000..83e984a6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java @@ -0,0 +1,252 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.util; + +import hu.bme.mit.inf.dslreasoner.domains.cps.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage + * @generated + */ +public class CpsAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static CpsPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public CpsAdapterFactory() { + if (modelPackage == null) { + modelPackage = CpsPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject) object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected CpsSwitch modelSwitch = new CpsSwitch() { + @Override + public Adapter caseCyberPhysicalSystem(CyberPhysicalSystem object) { + return createCyberPhysicalSystemAdapter(); + } + + @Override + public Adapter caseApplicationType(ApplicationType object) { + return createApplicationTypeAdapter(); + } + + @Override + public Adapter caseHostType(HostType object) { + return createHostTypeAdapter(); + } + + @Override + public Adapter caseRequest(Request object) { + return createRequestAdapter(); + } + + @Override + public Adapter caseRequirement(Requirement object) { + return createRequirementAdapter(); + } + + @Override + public Adapter caseApplicationInstance(ApplicationInstance object) { + return createApplicationInstanceAdapter(); + } + + @Override + public Adapter caseResourceRequirement(ResourceRequirement object) { + return createResourceRequirementAdapter(); + } + + @Override + public Adapter caseHostInstance(HostInstance object) { + return createHostInstanceAdapter(); + } + + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject) target); + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem Cyber Physical System}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem + * @generated + */ + public Adapter createCyberPhysicalSystemAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType Application Type}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType + * @generated + */ + public Adapter createApplicationTypeAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType Host Type}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType + * @generated + */ + public Adapter createHostTypeAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request Request}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request + * @generated + */ + public Adapter createRequestAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement Requirement}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement + * @generated + */ + public Adapter createRequirementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance Application Instance}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance + * @generated + */ + public Adapter createApplicationInstanceAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement Resource Requirement}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement + * @generated + */ + public Adapter createResourceRequirementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance Host Instance}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance + * @generated + */ + public Adapter createHostInstanceAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //CpsAdapterFactory diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java new file mode 100644 index 00000000..28b630a9 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java @@ -0,0 +1,266 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.util; + +import hu.bme.mit.inf.dslreasoner.domains.cps.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage + * @generated + */ +public class CpsSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static CpsPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public CpsSwitch() { + if (modelPackage == null) { + modelPackage = CpsPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM: { + CyberPhysicalSystem cyberPhysicalSystem = (CyberPhysicalSystem) theEObject; + T result = caseCyberPhysicalSystem(cyberPhysicalSystem); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.APPLICATION_TYPE: { + ApplicationType applicationType = (ApplicationType) theEObject; + T result = caseApplicationType(applicationType); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.HOST_TYPE: { + HostType hostType = (HostType) theEObject; + T result = caseHostType(hostType); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.REQUEST: { + Request request = (Request) theEObject; + T result = caseRequest(request); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.REQUIREMENT: { + Requirement requirement = (Requirement) theEObject; + T result = caseRequirement(requirement); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.APPLICATION_INSTANCE: { + ApplicationInstance applicationInstance = (ApplicationInstance) theEObject; + T result = caseApplicationInstance(applicationInstance); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.RESOURCE_REQUIREMENT: { + ResourceRequirement resourceRequirement = (ResourceRequirement) theEObject; + T result = caseResourceRequirement(resourceRequirement); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.HOST_INSTANCE: { + HostInstance hostInstance = (HostInstance) theEObject; + T result = caseHostInstance(hostInstance); + if (result == null) + result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Cyber Physical System'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Cyber Physical System'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseCyberPhysicalSystem(CyberPhysicalSystem object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Application Type'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Application Type'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseApplicationType(ApplicationType object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Host Type'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Host Type'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseHostType(HostType object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Request'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Request'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseRequest(Request object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Requirement'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Requirement'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseRequirement(Requirement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Application Instance'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Application Instance'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseApplicationInstance(ApplicationInstance object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Resource Requirement'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Resource Requirement'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseResourceRequirement(ResourceRequirement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Host Instance'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Host Instance'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseHostInstance(HostInstance object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //CpsSwitch diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird index d94d68b4..3f1b0301 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird @@ -3,6 +3,991 @@ cps.ecore cps.genmodel + ../src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + http://www.eclipse.org/emf/2002/Ecore + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch + java:/Objects/java.lang.Object + java:/Objects/org.eclipse.viatra.query.runtime.api.IPatternMatch + java:/Primitives + java:/Objects/java.lang.SafeVarargs + java:/Objects/java.util.List + java:/Objects/java.lang.String + java:/Objects/java.lang.CloneNotSupportedException + java:/Objects/java.lang.Throwable + java:/Objects/java.lang.Class + java:/Objects/java.lang.InterruptedException + java:/Objects/java.lang.Exception + java:/Objects/java.io.Serializable + java:/Objects/java.io.PrintWriter + java:/Objects/java.io.PrintStream + java:/Objects/java.lang.StackTraceElement + java:/Objects/java.util.Set + java:/Objects/java.io.ObjectInputStream + java:/Objects/java.io.IOException + java:/Objects/java.lang.ClassNotFoundException + java:/Objects/java.io.ObjectOutputStream + java:/Objects/java.io.Writer + java:/Objects/java.io.OutputStream + java:/Objects/java.io.FileNotFoundException + java:/Objects/java.io.File + java:/Objects/java.nio.charset.Charset + java:/Objects/java.io.UnsupportedEncodingException + java:/Objects/java.lang.CharSequence + java:/Objects/java.util.Locale + java:/Objects/java.util.Formatter + java:/Objects/java.lang.Appendable + java:/Objects/java.io.Closeable + java:/Objects/java.io.Flushable + java:/Objects/java.lang.AutoCloseable + java:/Objects/java.lang.Comparable + java:/Objects/java.security.SecureRandom + java:/Objects/java.lang.Enum + java:/Objects/java.net.URI + java:/Objects/java.io.FilenameFilter + java:/Objects/java.io.FileFilter + java:/Objects/java.nio.file.Path + java:/Objects/java.lang.Deprecated + java:/Objects/java.net.MalformedURLException + java:/Objects/java.net.URL + java:/Objects/sun.misc.Unsafe + java:/Objects/java.io.FileSystem + java:/Objects/java.util.Random + java:/Objects/java.util.regex.Pattern + java:/Objects/java.security.SecureRandomSpi + java:/Objects/java.security.Provider + java:/Objects/java.security.NoSuchAlgorithmException + java:/Objects/java.security.NoSuchProviderException + java:/Objects/java.security.MessageDigest + java:/Objects/sun.security.util.Debug + java:/Objects/java.util.Spliterator + java:/Objects/java.util.function.DoubleConsumer + java:/Objects/java.util.function.LongConsumer + java:/Objects/java.util.function.IntConsumer + java:/Objects/java.util.stream.DoubleStream + java:/Objects/java.util.stream.IntStream + java:/Objects/java.util.stream.LongStream + java:/Objects/java.util.concurrent.atomic.AtomicLong + java:/Objects/java.io.ObjectStreamField + java:/Objects/java.lang.Double + java:/Objects/java.util.function.Consumer + java:/Objects/java.lang.Long + java:/Objects/java.lang.Integer + java:/Objects/java.util.Comparator + java:/Objects/java.lang.Number + java:/Objects/java.lang.NumberFormatException + java:/Objects/java.lang.IllegalArgumentException + java:/Objects/java.lang.RuntimeException + java:/Objects/java.lang.FunctionalInterface + java:/Objects/java.lang.annotation.Target + java:/Objects/java.lang.annotation.ElementType + java:/Objects/java.lang.annotation.Retention + java:/Objects/java.lang.annotation.RetentionPolicy + java:/Objects/java.lang.annotation.Documented + java:/Objects/java.lang.annotation.Annotation + java:/Objects/java.math.BigInteger + java:/Objects/java.lang.StringBuilder + java:/Objects/java.lang.AbstractStringBuilder + java:/Objects/java.lang.StringBuffer + java:/Objects/java.util.function.Function + java:/Objects/java.util.function.ToDoubleFunction + java:/Objects/java.util.function.ToIntFunction + java:/Objects/java.util.function.ToLongFunction + java:/Objects/java.util.stream.BaseStream + java:/Objects/java.util.function.DoublePredicate + java:/Objects/java.util.OptionalDouble + java:/Objects/java.util.stream.Stream + java:/Objects/java.util.function.Supplier + java:/Objects/java.util.function.ObjDoubleConsumer + java:/Objects/java.util.function.BiConsumer + java:/Objects/java.util.function.DoubleFunction + java:/Objects/java.util.function.DoubleSupplier + java:/Objects/java.util.function.DoubleUnaryOperator + java:/Objects/java.util.PrimitiveIterator + java:/Objects/java.util.function.DoubleToIntFunction + java:/Objects/java.util.function.DoubleToLongFunction + java:/Objects/java.util.function.DoubleBinaryOperator + java:/Objects/java.util.DoubleSummaryStatistics + java:/Objects/java.util.Iterator + java:/Objects/java.lang.Runnable + java:/Objects/java.util.function.Predicate + java:/Objects/java.util.stream.Collector + java:/Objects/java.util.Optional + java:/Objects/java.util.function.UnaryOperator + java:/Objects/java.util.function.BinaryOperator + java:/Objects/java.util.function.BiFunction + java:/Objects/java.util.function.IntFunction + java:/Objects/java.util.function.IntPredicate + java:/Objects/java.util.function.ObjIntConsumer + java:/Objects/java.util.OptionalInt + java:/Objects/java.util.function.IntSupplier + java:/Objects/java.util.function.IntUnaryOperator + java:/Objects/java.util.function.IntToDoubleFunction + java:/Objects/java.util.function.IntToLongFunction + java:/Objects/java.util.function.IntBinaryOperator + java:/Objects/java.util.IntSummaryStatistics + java:/Objects/java.util.function.LongPredicate + java:/Objects/java.util.function.ObjLongConsumer + java:/Objects/java.util.OptionalLong + java:/Objects/java.util.function.LongFunction + java:/Objects/java.util.function.LongSupplier + java:/Objects/java.util.function.LongUnaryOperator + java:/Objects/java.util.function.LongToDoubleFunction + java:/Objects/java.util.function.LongToIntFunction + java:/Objects/java.util.function.LongBinaryOperator + java:/Objects/java.util.LongSummaryStatistics + java:/Objects/java.lang.reflect.Field + java:/Objects/sun.reflect.CallerSensitive + java:/Objects/java.lang.reflect.AccessibleObject + java:/Objects/java.lang.reflect.Member + java:/Objects/sun.reflect.FieldAccessor + java:/Objects/java.util.Map + java:/Objects/java.lang.IllegalAccessException + java:/Objects/java.lang.reflect.AnnotatedType + java:/Objects/sun.reflect.generics.factory.GenericsFactory + java:/Objects/sun.reflect.generics.repository.FieldRepository + java:/Objects/java.lang.reflect.Type + java:/Objects/java.lang.reflect.AnnotatedElement + java:/Objects/java.lang.SecurityException + java:/Objects/java.security.Permission + java:/Objects/sun.reflect.ReflectionFactory + java:/Objects/java.security.Guard + java:/Objects/java.security.PermissionCollection + java:/Objects/java.util.Enumeration + java:/Objects/java.security.PrivilegedAction + java:/Objects/java.lang.reflect.Constructor + java:/Objects/java.lang.reflect.Method + java:/Objects/java.lang.invoke.MethodHandle + java:/Objects/sun.reflect.ConstructorAccessor + java:/Objects/java.lang.reflect.Executable + java:/Objects/sun.reflect.MethodAccessor + java:/Objects/sun.reflect.LangReflectAccess + java:/Objects/java.io.OptionalDataException + java:/Objects/sun.reflect.generics.repository.ConstructorRepository + java:/Objects/java.lang.reflect.TypeVariable + java:/Objects/java.lang.InstantiationException + java:/Objects/java.lang.reflect.InvocationTargetException + java:/Objects/sun.reflect.generics.repository.GenericDeclRepository + java:/Objects/sun.reflect.generics.tree.MethodTypeSignature + java:/Objects/sun.reflect.generics.repository.AbstractRepository + java:/Objects/sun.reflect.generics.tree.Signature + java:/Objects/sun.reflect.generics.visitor.Reifier + java:/Objects/sun.reflect.generics.tree.Tree + java:/Objects/sun.reflect.generics.visitor.TypeTreeVisitor + java:/Objects/sun.reflect.generics.tree.TypeArgument + java:/Objects/sun.reflect.generics.tree.ArrayTypeSignature + java:/Objects/sun.reflect.generics.tree.BooleanSignature + java:/Objects/sun.reflect.generics.tree.BottomSignature + java:/Objects/sun.reflect.generics.tree.ByteSignature + java:/Objects/sun.reflect.generics.tree.CharSignature + java:/Objects/sun.reflect.generics.tree.ClassTypeSignature + java:/Objects/sun.reflect.generics.tree.DoubleSignature + java:/Objects/sun.reflect.generics.tree.FloatSignature + java:/Objects/sun.reflect.generics.tree.FormalTypeParameter + java:/Objects/sun.reflect.generics.tree.IntSignature + java:/Objects/sun.reflect.generics.tree.LongSignature + java:/Objects/sun.reflect.generics.tree.ShortSignature + java:/Objects/sun.reflect.generics.tree.SimpleClassTypeSignature + java:/Objects/sun.reflect.generics.tree.TypeVariableSignature + java:/Objects/sun.reflect.generics.tree.VoidDescriptor + java:/Objects/sun.reflect.generics.tree.Wildcard + java:/Objects/sun.reflect.generics.tree.TypeTree + java:/Objects/sun.reflect.generics.tree.FieldTypeSignature + java:/Objects/sun.reflect.generics.tree.TypeSignature + java:/Objects/sun.reflect.generics.tree.BaseType + java:/Objects/sun.reflect.generics.tree.ReturnType + java:/Objects/sun.reflect.generics.visitor.Visitor + java:/Objects/sun.reflect.generics.tree.ClassSignature + java:/Objects/java.lang.reflect.GenericDeclaration + java:/Objects/java.lang.ReflectiveOperationException + java:/Objects/sun.reflect.generics.repository.MethodRepository + java:/Objects/java.lang.invoke.MethodType + java:/Objects/java.lang.invoke.LambdaForm + java:/Objects/java.lang.invoke.BoundMethodHandle + java:/Objects/java.lang.invoke.MemberName + java:/Objects/java.lang.invoke.MethodHandleImpl + java:/Objects/java.lang.ref.WeakReference + java:/Objects/java.lang.ref.ReferenceQueue + java:/Objects/java.util.concurrent.ConcurrentMap + java:/Objects/java.lang.invoke.MethodTypeForm + java:/Objects/java.lang.ClassLoader + java:/Objects/java.lang.TypeNotPresentException + java:/Objects/java.lang.invoke.Invokers + java:/Objects/java.lang.IndexOutOfBoundsException + java:/Objects/java.lang.invoke.Stable + java:/Objects/java.lang.ref.Reference + java:/Objects/java.lang.Thread + java:/Objects/java.lang.ThreadGroup + java:/Objects/java.lang.Boolean + java:/Objects/java.security.AccessControlContext + java:/Objects/sun.nio.ch.Interruptible + java:/Objects/java.lang.RuntimePermission + java:/Objects/java.lang.ThreadLocal + java:/Objects/sun.misc.Contended + java:/Objects/java.security.ProtectionDomain + java:/Objects/java.security.DomainCombiner + java:/Objects/java.security.AccessControlException + java:/Objects/sun.misc.JavaSecurityAccess + java:/Objects/java.security.CodeSource + java:/Objects/java.security.Principal + java:/Objects/java.security.cert.Certificate + java:/Objects/java.security.CodeSigner + java:/Objects/java.security.cert.CertificateFactory + java:/Objects/java.net.SocketPermission + java:/Objects/java.io.ObjectStreamException + java:/Objects/java.security.cert.CertificateEncodingException + java:/Objects/java.security.PublicKey + java:/Objects/java.security.cert.CertificateException + java:/Objects/java.security.InvalidKeyException + java:/Objects/java.security.SignatureException + java:/Objects/java.security.Key + java:/Objects/java.security.GeneralSecurityException + java:/Objects/java.security.KeyException + java:/Objects/java.security.cert.CertPath + java:/Objects/java.security.Timestamp + java:/Objects/java.util.Date + java:/Objects/java.lang.Cloneable + java:/Objects/java.time.Instant + java:/Objects/sun.util.calendar.BaseCalendar + java:/Objects/java.time.temporal.Temporal + java:/Objects/java.time.temporal.TemporalAdjuster + java:/Objects/java.time.ZoneOffset + java:/Objects/java.time.OffsetDateTime + java:/Objects/java.time.ZoneId + java:/Objects/java.time.ZonedDateTime + java:/Objects/java.time.temporal.TemporalAccessor + java:/Objects/java.time.temporal.TemporalField + java:/Objects/java.time.temporal.TemporalUnit + java:/Objects/java.time.temporal.TemporalAmount + java:/Objects/java.time.Clock + java:/Objects/java.time.temporal.TemporalQuery + java:/Objects/java.time.temporal.ValueRange + java:/Objects/java.io.DataInput + java:/Objects/java.io.InvalidObjectException + java:/Objects/java.io.DataOutput + java:/Objects/java.time.zone.ZoneRules + java:/Objects/java.time.zone.ZoneOffsetTransition + java:/Objects/java.time.zone.ZoneOffsetTransitionRule + java:/Objects/java.time.LocalDateTime + java:/Objects/java.time.Duration + java:/Objects/java.time.Month + java:/Objects/java.time.DayOfWeek + java:/Objects/java.time.LocalTime + java:/Objects/java.time.format.TextStyle + java:/Objects/java.time.LocalDate + java:/Objects/java.time.OffsetTime + java:/Objects/java.time.format.DateTimeFormatter + java:/Objects/java.time.chrono.ChronoLocalDate + java:/Objects/java.time.chrono.IsoChronology + java:/Objects/java.time.chrono.Era + java:/Objects/java.time.Period + java:/Objects/java.time.chrono.ChronoLocalDateTime + java:/Objects/java.time.chrono.Chronology + java:/Objects/java.time.chrono.ChronoPeriod + java:/Objects/java.time.chrono.ChronoZonedDateTime + java:/Objects/java.time.temporal.ChronoField + java:/Objects/java.time.format.ResolverStyle + java:/Objects/java.time.chrono.AbstractChronology + java:/Objects/java.time.chrono.IsoEra + java:/Objects/java.util.concurrent.ConcurrentHashMap + java:/Objects/java.util.AbstractMap + java:/Objects/java.util.function.ToIntBiFunction + java:/Objects/java.util.function.ToLongBiFunction + java:/Objects/java.util.function.ToDoubleBiFunction + java:/Objects/java.util.concurrent.atomic.AtomicReference + java:/Objects/java.lang.Void + java:/Objects/java.util.concurrent.CountedCompleter + java:/Objects/java.util.Collection + java:/Objects/java.util.concurrent.locks.ReentrantLock + java:/Objects/java.util.concurrent.ForkJoinTask + java:/Objects/java.util.concurrent.Future + java:/Objects/java.util.concurrent.RunnableFuture + java:/Objects/java.util.concurrent.Callable + java:/Objects/java.util.concurrent.ExecutionException + java:/Objects/java.util.concurrent.TimeUnit + java:/Objects/java.util.concurrent.TimeoutException + java:/Objects/java.util.concurrent.ForkJoinPool + java:/Objects/java.util.concurrent.AbstractExecutorService + java:/Objects/java.util.concurrent.ForkJoinWorkerThread + java:/Objects/java.util.concurrent.ExecutorService + java:/Objects/java.util.concurrent.Executor + java:/Objects/java.lang.Iterable + java:/Objects/java.util.concurrent.locks.Lock + java:/Objects/java.util.concurrent.locks.AbstractQueuedSynchronizer + java:/Objects/java.util.concurrent.locks.Condition + java:/Objects/java.util.concurrent.locks.AbstractOwnableSynchronizer + java:/Objects/java.lang.NullPointerException + java:/Objects/java.io.ObjectInput + java:/Objects/java.io.ObjectOutput + java:/Objects/java.text.Format + java:/Objects/java.text.FieldPosition + java:/Objects/java.text.ParseException + java:/Objects/java.text.ParsePosition + java:/Objects/java.time.format.DateTimeFormatterBuilder + java:/Objects/java.time.format.DecimalStyle + java:/Objects/java.time.format.DateTimeParseException + java:/Objects/java.time.format.FormatStyle + java:/Objects/java.time.format.DateTimeParseContext + java:/Objects/java.text.AttributedCharacterIterator + java:/Objects/java.text.CharacterIterator + java:/Objects/java.time.format.DateTimePrintContext + java:/Objects/java.lang.ref.SoftReference + java:/Objects/java.time.format.DateTimeTextProvider + java:/Objects/java.math.BigDecimal + java:/Objects/java.time.format.SignStyle + java:/Objects/java.lang.Character + java:/Objects/java.math.MathContext + java:/Objects/java.math.RoundingMode + java:/Objects/java.math.MutableBigInteger + java:/Objects/java.util.HashMap + java:/Objects/java.util.LinkedHashMap + java:/Objects/java.util.AbstractSet + java:/Objects/java.util.AbstractCollection + java:/Objects/java.time.DateTimeException + java:/Objects/java.time.format.Parsed + java:/Objects/java.util.ArrayList + java:/Objects/java.util.AbstractList + java:/Objects/java.util.RandomAccess + java:/Objects/java.util.ListIterator + java:/Objects/sun.util.calendar.AbstractCalendar + java:/Objects/sun.util.calendar.CalendarDate + java:/Objects/java.util.TimeZone + java:/Objects/sun.util.calendar.CalendarSystem + java:/Objects/sun.util.calendar.Era + java:/Objects/java.util.Properties + java:/Objects/sun.util.calendar.Gregorian + java:/Objects/java.util.Hashtable + java:/Objects/java.io.InputStream + java:/Objects/java.util.InvalidPropertiesFormatException + java:/Objects/sun.util.spi.XmlPropertiesProvider + java:/Objects/java.io.Reader + java:/Objects/java.io.BufferedWriter + java:/Objects/java.util.Dictionary + java:/Objects/java.io.StreamCorruptedException + java:/Objects/java.io.NotSerializableException + java:/Objects/java.lang.Readable + java:/Objects/java.nio.CharBuffer + java:/Objects/java.nio.Buffer + java:/Objects/java.nio.ByteOrder + java:/Objects/java.security.cert.CertificateFactorySpi + java:/Objects/java.security.cert.CRLException + java:/Objects/java.security.cert.CRL + java:/Objects/java.net.UnknownHostException + java:/Objects/java.net.InetAddress + java:/Objects/sun.net.spi.nameservice.NameService + java:/Objects/java.net.NetworkInterface + java:/Objects/java.net.InetAddressImpl + java:/Objects/java.net.SocketException + java:/Objects/java.net.InterfaceAddress + java:/Objects/java.net.Inet4Address + java:/Objects/javax.security.auth.Subject + java:/Objects/javax.security.auth.AuthPermission + java:/Objects/java.util.LinkedList + java:/Objects/java.security.PrivilegedExceptionAction + java:/Objects/java.security.PrivilegedActionException + java:/Objects/java.security.BasicPermission + java:/Objects/java.util.AbstractSequentialList + java:/Objects/java.util.Deque + java:/Objects/java.util.Queue + java:/Objects/java.util.concurrent.atomic.AtomicInteger + java:/Objects/java.lang.ClassFormatError + java:/Objects/java.nio.ByteBuffer + java:/Objects/java.lang.Package + java:/Objects/sun.misc.URLClassPath + java:/Objects/java.lang.AssertionStatusDirectives + java:/Objects/java.util.Vector + java:/Objects/java.util.Stack + java:/Objects/java.lang.LinkageError + java:/Objects/java.lang.Error + java:/Objects/java.nio.DoubleBuffer + java:/Objects/java.nio.FloatBuffer + java:/Objects/java.nio.IntBuffer + java:/Objects/java.nio.LongBuffer + java:/Objects/java.nio.ShortBuffer + java:/Objects/java.util.jar.Manifest + java:/Objects/java.io.FilterInputStream + java:/Objects/java.util.jar.JarVerifier + java:/Objects/java.util.jar.Attributes + java:/Objects/java.util.jar.JarEntry + java:/Objects/sun.security.util.ManifestEntryVerifier + java:/Objects/java.util.jar.JarFile + java:/Objects/java.util.zip.ZipEntry + java:/Objects/java.io.ByteArrayOutputStream + java:/Objects/sun.security.util.ManifestDigester + java:/Objects/sun.security.util.SignatureFileVerifier + java:/Objects/java.util.jar.JarException + java:/Objects/java.util.zip.ZipException + java:/Objects/java.util.zip.ZipFile + java:/Objects/java.util.zip.ZipConstants + java:/Objects/java.util.zip.InflaterInputStream + java:/Objects/java.util.zip.Inflater + java:/Objects/java.util.zip.ZipCoder + java:/Objects/java.util.zip.DataFormatException + java:/Objects/java.util.zip.ZStreamRef + java:/Objects/java.nio.charset.CharsetDecoder + java:/Objects/java.nio.charset.CharsetEncoder + java:/Objects/java.nio.charset.CharacterCodingException + java:/Objects/java.nio.charset.CoderResult + java:/Objects/java.nio.charset.CodingErrorAction + java:/Objects/java.nio.file.attribute.FileTime + java:/Objects/sun.security.pkcs.SignerInfo + java:/Objects/sun.security.pkcs.PKCS7 + java:/Objects/sun.security.util.DisabledAlgorithmConstraints + java:/Objects/sun.security.util.DerEncoder + java:/Objects/sun.security.util.DerInputStream + java:/Objects/sun.security.pkcs.ParsingException + java:/Objects/sun.security.x509.X500Name + java:/Objects/sun.security.x509.AlgorithmId + java:/Objects/sun.security.pkcs.PKCS9Attributes + java:/Objects/sun.security.util.DerOutputStream + java:/Objects/java.security.cert.X509Certificate + java:/Objects/sun.security.timestamp.TimestampToken + java:/Objects/java.security.CryptoPrimitive + java:/Objects/sun.security.util.DerInputBuffer + java:/Objects/sun.security.util.DerValue + java:/Objects/sun.security.util.ObjectIdentifier + java:/Objects/sun.security.util.BitArray + java:/Objects/java.io.ByteArrayInputStream + java:/Objects/java.lang.ArrayIndexOutOfBoundsException + java:/Objects/sun.security.x509.GeneralNameInterface + java:/Objects/sun.security.x509.RDN + java:/Objects/sun.security.x509.AVA + java:/Objects/javax.security.auth.x500.X500Principal + java:/Objects/java.lang.UnsupportedOperationException + java:/Objects/java.lang.Byte + java:/Objects/java.io.NotActiveException + java:/Objects/java.security.AlgorithmParameters + java:/Objects/java.security.AlgorithmParametersSpi + java:/Objects/java.security.spec.AlgorithmParameterSpec + java:/Objects/java.security.spec.InvalidParameterSpecException + java:/Objects/sun.security.pkcs.PKCS9Attribute + java:/Objects/sun.security.util.ByteArrayLexOrder + java:/Objects/sun.security.util.ByteArrayTagOrder + java:/Objects/java.security.cert.X509Extension + java:/Objects/java.security.cert.CertificateExpiredException + java:/Objects/java.security.cert.CertificateNotYetValidException + java:/Objects/java.security.cert.CertificateParsingException + java:/Objects/sun.security.pkcs.ContentInfo + java:/Objects/java.security.cert.X509CRL + java:/Objects/sun.security.timestamp.Timestamper + java:/Objects/java.security.cert.X509CRLEntry + java:/Objects/java.security.cert.CRLReason + java:/Objects/sun.security.timestamp.TSRequest + java:/Objects/sun.security.timestamp.TSResponse + java:/Objects/sun.security.util.AbstractAlgorithmConstraints + java:/Objects/sun.security.util.ConstraintsParameters + java:/Objects/java.security.cert.CertPathValidatorException + java:/Objects/java.text.SimpleDateFormat + java:/Objects/sun.security.util.AlgorithmDecomposer + java:/Objects/java.security.AlgorithmConstraints + java:/Objects/java.text.DateFormat + java:/Objects/java.text.DateFormatSymbols + java:/Objects/java.text.CalendarBuilder + java:/Objects/java.text.NumberFormat + java:/Objects/sun.util.locale.provider.LocaleProviderAdapter + java:/Objects/java.util.Calendar + java:/Objects/java.util.spi.LocaleServiceProvider + java:/Objects/java.text.spi.BreakIteratorProvider + java:/Objects/java.util.spi.CalendarDataProvider + java:/Objects/java.util.spi.CalendarNameProvider + java:/Objects/sun.util.spi.CalendarProvider + java:/Objects/java.text.spi.CollatorProvider + java:/Objects/java.util.spi.CurrencyNameProvider + java:/Objects/java.text.spi.DateFormatProvider + java:/Objects/java.text.spi.DateFormatSymbolsProvider + java:/Objects/java.text.spi.DecimalFormatSymbolsProvider + java:/Objects/java.util.spi.LocaleNameProvider + java:/Objects/sun.util.locale.provider.LocaleResources + java:/Objects/java.text.spi.NumberFormatProvider + java:/Objects/java.util.spi.TimeZoneNameProvider + java:/Objects/java.text.BreakIterator + java:/Objects/java.text.Collator + java:/Objects/java.text.CollationKey + java:/Objects/java.text.DecimalFormatSymbols + java:/Objects/java.util.Currency + java:/Objects/sun.util.locale.provider.LocaleServiceProviderPool + java:/Objects/java.io.DataInputStream + java:/Objects/java.util.HashSet + java:/Objects/sun.util.locale.provider.ResourceBundleBasedAdapter + java:/Objects/java.util.ResourceBundle + java:/Objects/sun.util.resources.LocaleData + java:/Objects/sun.util.locale.LocaleObjectCache + java:/Objects/sun.util.locale.BaseLocale + java:/Objects/java.util.spi.ResourceBundleControlProvider + java:/Objects/sun.util.resources.OpenListResourceBundle + java:/Objects/sun.util.resources.TimeZoneNamesBundle + java:/Objects/sun.util.resources.ParallelListResourceBundle + java:/Objects/java.util.concurrent.atomic.AtomicMarkableReference + java:/Objects/java.io.DataOutputStream + java:/Objects/java.io.FilterOutputStream + java:/Objects/sun.misc.Resource + java:/Objects/java.net.URLStreamHandler + java:/Objects/sun.misc.JarIndex + java:/Objects/sun.misc.MetaIndex + java:/Objects/sun.misc.JavaUtilZipFileAccess + java:/Objects/java.net.URLStreamHandlerFactory + java:/Objects/java.net.URLConnection + java:/Objects/java.net.Proxy + java:/Objects/java.net.UnknownServiceException + java:/Objects/java.net.ContentHandler + java:/Objects/java.net.FileNameMap + java:/Objects/java.net.ContentHandlerFactory + java:/Objects/sun.net.www.MessageHeader + java:/Objects/java.net.SocketAddress + java:/Objects/java.lang.invoke.ForceInline + java:/Objects/java.lang.invoke.DontInline + java:/Objects/java.lang.invoke.WrongMethodTypeException + java:/Objects/sun.invoke.util.Wrapper + java:/Objects/java.lang.invoke.LambdaFormEditor + java:/Objects/java.lang.ClassCastException + java:/Objects/java.lang.invoke.LambdaFormBuffer + java:/Objects/jdk.internal.org.objectweb.asm.MethodVisitor + java:/Objects/java.lang.invoke.MethodHandles + java:/Objects/jdk.internal.org.objectweb.asm.AnnotationVisitor + java:/Objects/jdk.internal.org.objectweb.asm.Attribute + java:/Objects/jdk.internal.org.objectweb.asm.TypePath + java:/Objects/jdk.internal.org.objectweb.asm.Handle + java:/Objects/jdk.internal.org.objectweb.asm.Label + java:/Objects/jdk.internal.org.objectweb.asm.ClassWriter + java:/Objects/jdk.internal.org.objectweb.asm.ByteVector + java:/Objects/jdk.internal.org.objectweb.asm.ClassReader + java:/Objects/jdk.internal.org.objectweb.asm.ClassVisitor + java:/Objects/jdk.internal.org.objectweb.asm.Item + java:/Objects/jdk.internal.org.objectweb.asm.FieldVisitor + java:/Objects/jdk.internal.org.objectweb.asm.AnnotationWriter + java:/Objects/jdk.internal.org.objectweb.asm.FieldWriter + java:/Objects/jdk.internal.org.objectweb.asm.MethodWriter + java:/Objects/jdk.internal.org.objectweb.asm.Frame + java:/Objects/jdk.internal.org.objectweb.asm.Handler + java:/Objects/jdk.internal.org.objectweb.asm.Type + java:/Objects/jdk.internal.org.objectweb.asm.Context + java:/Objects/jdk.internal.org.objectweb.asm.Edge + java:/Objects/java.lang.NoSuchMethodException + java:/Objects/java.lang.NoSuchFieldException + java:/Objects/java.lang.invoke.DirectMethodHandle + java:/Objects/java.lang.invoke.MethodHandleInfo + java:/Objects/java.lang.ClassValue + java:/Objects/java.util.WeakHashMap + java:/Objects/java.lang.invoke.DelegatingMethodHandle + java:/Objects/sun.invoke.empty.Empty + java:/Objects/java.lang.reflect.Parameter + java:/Objects/java.lang.reflect.ParameterizedType + java:/Objects/java.lang.reflect.WildcardType + java:/Objects/java.util.regex.Matcher + java:/Objects/java.util.regex.UnicodeProp + java:/Objects/java.util.regex.PatternSyntaxException + java:/Objects/java.util.regex.MatchResult + java:/Objects/java.security.MessageDigestSpi + java:/Objects/java.security.DigestException + java:/Objects/java.net.URISyntaxException + java:/Objects/java.nio.file.Watchable + java:/Objects/java.nio.file.FileSystem + java:/Objects/java.nio.file.WatchService + java:/Objects/java.nio.file.WatchEvent + java:/Objects/java.nio.file.WatchKey + java:/Objects/java.nio.file.LinkOption + java:/Objects/java.nio.file.FileStore + java:/Objects/java.nio.file.PathMatcher + java:/Objects/java.nio.file.attribute.UserPrincipalLookupService + java:/Objects/java.nio.file.spi.FileSystemProvider + java:/Objects/java.nio.file.attribute.FileStoreAttributeView + java:/Objects/java.nio.file.attribute.FileAttributeView + java:/Objects/java.nio.file.attribute.AttributeView + java:/Objects/java.nio.file.attribute.GroupPrincipal + java:/Objects/java.nio.file.attribute.UserPrincipal + java:/Objects/java.nio.file.AccessMode + java:/Objects/java.nio.file.CopyOption + java:/Objects/java.nio.file.attribute.FileAttribute + java:/Objects/java.nio.file.OpenOption + java:/Objects/java.nio.channels.AsynchronousFileChannel + java:/Objects/java.nio.channels.SeekableByteChannel + java:/Objects/java.nio.file.DirectoryStream + java:/Objects/java.nio.channels.FileChannel + java:/Objects/java.nio.file.attribute.BasicFileAttributes + java:/Objects/java.nio.channels.AsynchronousChannel + java:/Objects/java.nio.channels.FileLock + java:/Objects/java.nio.channels.CompletionHandler + java:/Objects/java.nio.channels.Channel + java:/Objects/java.nio.channels.ByteChannel + java:/Objects/java.nio.channels.ReadableByteChannel + java:/Objects/java.nio.channels.WritableByteChannel + java:/Objects/java.nio.channels.spi.AbstractInterruptibleChannel + java:/Objects/java.nio.channels.GatheringByteChannel + java:/Objects/java.nio.channels.ScatteringByteChannel + java:/Objects/java.nio.MappedByteBuffer + java:/Objects/java.nio.channels.InterruptibleChannel + java:/Objects/java.nio.channels.AsynchronousCloseException + java:/Objects/java.nio.channels.ClosedChannelException + java:/Objects/java.io.FileDescriptor + java:/Objects/java.io.SyncFailedException + java:/Objects/java.lang.SecurityManager + java:/Objects/java.net.UrlDeserializedState + java:/Objects/java.nio.charset.spi.CharsetProvider + java:/Objects/java.util.SortedMap + java:/Objects/sun.util.locale.InternalLocaleBuilder + java:/Objects/sun.util.locale.LocaleExtensions + java:/Objects/java.text.MessageFormat + java:/Objects/java.util.MissingResourceException + java:/Objects/sun.util.locale.LocaleSyntaxException + java:/Objects/sun.util.locale.LanguageTag + java:/Objects/sun.util.locale.ParseStatus + java:/Objects/sun.util.locale.StringTokenIterator + java:/Objects/sun.util.locale.Extension + java:/Objects/java.io.OutputStreamWriter + java:/Objects/sun.nio.cs.StreamEncoder + java:/Objects/java.io.ObjectStreamConstants + java:/Objects/sun.misc.ObjectInputFilter + java:/Objects/java.io.ObjectInputValidation + java:/Objects/java.io.ObjectStreamClass + java:/Objects/sun.util.logging.PlatformLogger + java:/Objects/java.io.InvalidClassException + java:/Objects/java.io.Externalizable + java:/Objects/sun.misc.ObjectStreamClassValidator + java:/Objects/java.io.SerialCallbackContext + java:/Objects/java.io.SerializablePermission + java:/Objects/sun.reflect.annotation.AnnotationType + java:/Objects/sun.reflect.ConstantPool + java:/Objects/sun.reflect.generics.repository.ClassRepository + java:/Objects/org.eclipse.viatra.query.runtime.api.IQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQueryHeader + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngine + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.QueryScope + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IInputKey + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PTraceable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PProblem + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.TypeJudgement + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PBody + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PVariable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IPosetComparator + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.Tuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.AbstractTuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.ITuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.VariableDeferredPConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.DeferredPConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.SubPlan + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.operations.POperation + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryHintOption + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IMatcherCapability + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendHintProvider + java:/Objects/org.apache.log4j.Logger + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.analysis.QueryAnalyzer + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryCacheContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryResultProviderAccess + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext + java:/Objects/org.apache.log4j.Category + java:/Objects/org.apache.log4j.spi.LoggerFactory + java:/Objects/org.apache.log4j.spi.AppenderAttachable + java:/Objects/org.apache.log4j.Appender + java:/Objects/org.apache.log4j.spi.LoggingEvent + java:/Objects/org.apache.log4j.Priority + java:/Objects/org.apache.log4j.spi.LoggerRepository + java:/Objects/org.apache.log4j.Level + java:/Objects/org.apache.log4j.helpers.AppenderAttachableImpl + java:/Objects/org.apache.log4j.spi.Filter + java:/Objects/org.apache.log4j.spi.ErrorHandler + java:/Objects/org.apache.log4j.Layout + java:/Objects/org.apache.log4j.spi.OptionHandler + java:/Objects/org.apache.log4j.spi.ThrowableInformation + java:/Objects/org.apache.log4j.spi.LocationInfo + java:/Objects/java.io.StringWriter + java:/Objects/org.apache.log4j.spi.HierarchyEventListener + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IUpdateable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask + java:/Objects/org.eclipse.viatra.query.runtime.matchers.util.Accuracy + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.IModifiableTuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IndexingService + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.ViatraQueryRuntimeException + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IBaseIndex + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.ViatraBaseIndexChangeListener + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IInstanceObserver + java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.EngineContextFactory + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IEngineContext + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseMatcher + java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification + java:/Objects/java.lang.ExceptionInInitializerError + java:/Objects/org.eclipse.viatra.query.runtime.exception.ViatraQueryException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQueryGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.IQueryGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineLifecycleListener + java:/Objects/org.eclipse.viatra.query.runtime.api.IMatchUpdateListener + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryModelUpdateListener + java:/Objects/java.lang.Override + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery + java:/Objects/org.eclipse.emf.ecore.EClassifier + java:/Objects/org.eclipse.emf.ecore.EEnumLiteral + java:/Objects/org.eclipse.emf.ecore.EStructuralFeature + java:/Objects/org.eclipse.emf.ecore.ENamedElement + java:/Objects/org.eclipse.emf.ecore.EPackage + java:/Objects/org.eclipse.emf.common.util.EList + java:/Objects/org.eclipse.emf.ecore.ETypeParameter + java:/Objects/org.eclipse.emf.ecore.EModelElement + java:/Objects/org.eclipse.emf.ecore.EObject + java:/Objects/org.eclipse.emf.ecore.EAnnotation + java:/Objects/org.eclipse.emf.common.notify.Notifier + java:/Objects/org.eclipse.emf.common.util.TreeIterator + java:/Objects/org.eclipse.emf.ecore.EClass + java:/Objects/org.eclipse.emf.ecore.EReference + java:/Objects/org.eclipse.emf.ecore.EOperation + java:/Objects/org.eclipse.emf.ecore.resource.Resource + java:/Objects/org.eclipse.emf.common.notify.Adapter + java:/Objects/org.eclipse.emf.common.notify.Notification + java:/Objects/org.eclipse.emf.ecore.EAttribute + java:/Objects/org.eclipse.emf.ecore.EGenericType + java:/Objects/org.eclipse.emf.ecore.EDataType + java:/Objects/org.eclipse.emf.ecore.InternalEObject + java:/Objects/org.eclipse.emf.common.CommonPlugin + java:/Objects/org.eclipse.emf.common.notify.NotificationChain + java:/Objects/org.eclipse.emf.common.util.URI + java:/Objects/org.eclipse.emf.common.util.Pool + java:/Objects/org.eclipse.emf.common.util.SegmentSequence + java:/Objects/org.eclipse.emf.common.util.CommonUtil + java:/Objects/org.eclipse.emf.common.util.WeakInterningHashSet + java:/Objects/java.util.concurrent.locks.ReentrantReadWriteLock + java:/Objects/org.eclipse.emf.common.util.InterningSet + java:/Objects/java.util.concurrent.locks.ReadWriteLock + java:/Objects/java.lang.IllegalMonitorStateException + java:/Objects/org.eclipse.emf.common.EMFPlugin + java:/Objects/org.osgi.framework.BundleActivator + java:/Objects/org.eclipse.emf.common.util.ResourceLocator + java:/Objects/org.eclipse.emf.common.util.DelegatingResourceLocator + java:/Objects/org.eclipse.emf.common.util.Logger + java:/Objects/org.eclipse.core.runtime.Plugin + java:/Objects/org.eclipse.core.runtime.IPluginDescriptor + java:/Objects/org.osgi.framework.Bundle + java:/Objects/org.eclipse.core.runtime.ILog + java:/Objects/org.osgi.framework.BundleContext + java:/Objects/org.eclipse.core.runtime.IPath + java:/Objects/org.eclipse.osgi.service.debug.DebugOptions + java:/Objects/org.eclipse.core.runtime.Preferences + java:/Objects/java.lang.IllegalStateException + java:/Objects/org.eclipse.core.runtime.CoreException + java:/Objects/org.osgi.util.tracker.ServiceTracker + java:/Objects/org.eclipse.osgi.service.debug.DebugTrace + java:/Objects/java.util.EventListener + java:/Objects/java.util.EventObject + java:/Objects/org.eclipse.core.runtime.IStatus + java:/Objects/org.eclipse.core.runtime.ListenerList + java:/Objects/org.osgi.util.tracker.ServiceTrackerCustomizer + java:/Objects/org.osgi.framework.AllServiceListener + java:/Objects/org.osgi.util.tracker.AbstractTracked + java:/Objects/org.osgi.framework.ServiceReference + java:/Objects/org.osgi.framework.ServiceEvent + java:/Objects/org.osgi.framework.ServiceListener + java:/Objects/org.osgi.framework.Filter + java:/Objects/org.osgi.framework.InvalidSyntaxException + java:/Objects/org.eclipse.core.runtime.IExtension + java:/Objects/org.eclipse.core.runtime.IExtensionPoint + java:/Objects/org.eclipse.core.runtime.IPluginPrerequisite + java:/Objects/org.eclipse.core.runtime.ILibrary + java:/Objects/org.eclipse.core.runtime.PluginVersionIdentifier + java:/Objects/org.eclipse.core.runtime.InvalidRegistryObjectException + java:/Objects/org.eclipse.core.runtime.IConfigurationElement + java:/Objects/org.eclipse.core.runtime.IContributor + java:/Objects/org.osgi.framework.Version + java:/Objects/org.osgi.framework.BundleException + java:/Objects/org.eclipse.core.runtime.ILogListener + java:/Objects/org.osgi.framework.BundleReference + java:/Objects/org.osgi.framework.BundleListener + java:/Objects/org.osgi.framework.FrameworkListener + java:/Objects/org.osgi.framework.ServiceObjects + java:/Objects/org.osgi.framework.ServiceRegistration + java:/Objects/org.osgi.framework.ServiceFactory + java:/Objects/org.osgi.framework.BundleEvent + java:/Objects/org.osgi.framework.FrameworkEvent + java:/Objects/org.eclipse.emf.ecore.ETypedElement + java:/Objects/org.eclipse.emf.ecore.EParameter + java:/Objects/org.eclipse.emf.ecore.resource.ResourceSet + java:/Objects/org.eclipse.emf.common.notify.AdapterFactory + java:/Objects/org.eclipse.emf.ecore.resource.URIConverter + java:/Objects/java.io.InputStreamReader + java:/Objects/org.eclipse.emf.ecore.resource.ContentHandler + java:/Objects/org.eclipse.emf.ecore.resource.URIHandler + java:/Objects/sun.nio.cs.StreamDecoder + java:/Objects/java.io.FileInputStream + java:/Objects/org.eclipse.emf.common.util.EMap + java:/Objects/org.eclipse.emf.ecore.EFactory + java:/Objects/org.eclipse.emf.common.util.Enumerator + java:/Objects/org.eclipse.emf.ecore.EEnum + java:/Objects/org.eclipse.emf.ecore.util.FeatureMap + java:/Objects/org.eclipse.emf.ecore.util.InternalEList + java:/Objects/org.eclipse.emf.ecore.util.EContentsEList + java:/Objects/org.eclipse.emf.ecore.util.AbstractSequentialInternalEList + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.HostType + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.Request + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.Requirement + java:/Objects/java.lang.SuppressWarnings + java:/Objects/javax.annotation.Generated + java:/Objects/org.eclipse.viatra.query.runtime.api.GenericPatternMatcher + java:/Objects/org.eclipse.viatra.query.runtime.api.GenericPatternMatch + java:/Objects/org.eclipse.viatra.query.runtime.api.GenericQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.sum + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.AggregatorType + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IAggregatorFactory + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.BoundAggregator + java:/Objects/java.lang.annotation.Inherited + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator + java:/Objects/org.eclipse.xtext.xbase.lib.ArrayLiterals + java:/Objects/com.google.common.annotations.GwtCompatible + java:/Objects/org.eclipse.xtext.xbase.lib.Pure + java:/Objects/org.eclipse.xtext.xbase.lib.Inline + java:/Objects/com.google.common.annotations.Beta + java:/Objects/org.eclipse.xtext.xbase.lib.CollectionLiterals + java:/Objects/org.eclipse.xtext.xbase.lib.Pair + java:/Objects/java.util.LinkedHashSet + java:/Objects/java.util.TreeMap + java:/Objects/java.util.TreeSet + java:/Objects/java.util.NavigableMap + java:/Objects/java.util.NavigableSet + java:/Objects/java.util.SortedSet + java:/Objects/org.eclipse.xtext.xbase.lib.InputOutput + java:/Objects/org.eclipse.xtext.xbase.lib.ArrayExtensions + java:/Objects/com.google.common.annotations.GwtIncompatible + java:/Objects/org.eclipse.xtext.xbase.lib.BigDecimalExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BigIntegerExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BooleanExtensions + java:/Objects/com.google.common.primitives.Booleans + java:/Objects/org.eclipse.xtext.xbase.lib.ByteExtensions + java:/Objects/java.lang.Math + java:/Objects/org.eclipse.xtext.xbase.lib.CharacterExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.CollectionExtensions + java:/Objects/com.google.common.collect.Iterables + java:/Objects/com.google.common.collect.ImmutableList + java:/Objects/com.google.common.collect.ImmutableSet + java:/Objects/com.google.common.collect.ImmutableSortedSet + java:/Objects/com.google.common.collect.ImmutableMap + java:/Objects/com.google.common.collect.ImmutableSortedMap + java:/Objects/java.util.Collections + java:/Objects/com.google.common.collect.FluentIterable + java:/Objects/com.google.common.base.Predicate + java:/Objects/com.google.common.base.Function + java:/Objects/com.google.common.base.Optional + java:/Objects/com.google.common.collect.ImmutableCollection + java:/Objects/com.google.common.collect.ImmutableListMultimap + java:/Objects/com.google.common.base.Joiner + java:/Objects/com.google.common.collect.ImmutableMultiset + java:/Objects/com.google.common.collect.ImmutableMultimap + java:/Objects/com.google.common.collect.ListMultimap + java:/Objects/com.google.common.collect.Multimap + java:/Objects/com.google.common.collect.AbstractMultimap + java:/Objects/com.google.common.collect.UnmodifiableIterator + java:/Objects/com.google.common.collect.Serialization + java:/Objects/com.google.common.collect.ImmutableSetMultimap + java:/Objects/com.google.common.collect.Multiset + java:/Objects/com.google.common.collect.Multimaps + java:/Objects/com.google.common.collect.Maps + java:/Objects/com.google.common.collect.AbstractListMultimap + java:/Objects/com.google.common.base.Supplier + java:/Objects/com.google.common.collect.AbstractMapBasedMultimap + java:/Objects/com.google.common.collect.AbstractSetMultimap + java:/Objects/com.google.common.collect.AbstractSortedSetMultimap + java:/Objects/com.google.common.collect.AbstractMultiset + java:/Objects/com.google.common.collect.Multisets + java:/Objects/com.google.common.collect.SetMultimap + java:/Objects/com.google.common.collect.ForwardingMultimap + java:/Objects/com.google.common.collect.SortedSetMultimap + java:/Objects/com.google.common.collect.FilteredMultimap + java:/Objects/com.google.common.collect.FilteredSetMultimap + java:/Objects/java.util.EnumMap + java:/Objects/com.google.common.base.Converter + java:/Objects/com.google.common.collect.BiMap + java:/Objects/com.google.common.collect.ForwardingMap + java:/Objects/com.google.common.collect.Ordering + java:/Objects/com.google.common.collect.Sets + java:/Objects/com.google.common.collect.ForwardingSet + java:/Objects/com.google.common.collect.AbstractNavigableMap + java:/Objects/com.google.common.collect.MapDifference + java:/Objects/com.google.common.collect.SortedMapDifference + java:/Objects/com.google.common.collect.ForwardingCollection + java:/Objects/com.google.common.collect.ForwardingSortedMap + java:/Objects/com.google.common.base.Equivalence + java:/Objects/java.util.IdentityHashMap + java:/Objects/com.google.common.collect.Range + java:/Objects/com.google.common.collect.ForwardingObject + java:/Objects/com.google.common.annotations.VisibleForTesting + java:/Objects/java.util.EnumSet + java:/Objects/com.google.common.collect.CartesianList + java:/Objects/com.google.common.collect.ForwardingNavigableSet + java:/Objects/com.google.common.collect.Collections2 + java:/Objects/com.google.common.collect.ForwardingSortedSet + java:/Objects/java.util.concurrent.CopyOnWriteArraySet + java:/Objects/com.google.common.collect.AbstractIterator + java:/Objects/java.util.concurrent.CopyOnWriteArrayList + java:/Objects/java.util.function.BiPredicate + java:/Objects/com.google.common.collect.Cut + java:/Objects/com.google.common.collect.DiscreteDomain + java:/Objects/com.google.common.collect.BoundType + java:/Objects/com.google.common.collect.ForwardingMultiset + java:/Objects/com.google.common.collect.SortedMultiset + java:/Objects/com.google.common.collect.SortedMultisetBridge + java:/Objects/com.google.common.collect.SortedIterable + java:/Objects/com.google.common.collect.UnmodifiableListIterator + java:/Objects/com.google.common.collect.ImmutableSortedSetFauxverideShim + java:/Objects/com.google.common.collect.RegularImmutableSortedSet + java:/Objects/com.google.common.collect.ImmutableMapEntry + java:/Objects/com.google.common.collect.ImmutableEntry + java:/Objects/com.google.common.collect.AbstractMapEntry + java:/Objects/com.google.common.collect.ImmutableSortedMapFauxverideShim + java:/Objects/java.util.AbstractQueue + java:/Objects/org.eclipse.xtext.xbase.lib.ComparableExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.DoubleExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.FloatExtensions + java:/Objects/java.lang.Float + java:/Objects/org.eclipse.xtext.xbase.lib.FunctionExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.Functions + java:/Objects/org.eclipse.xtext.xbase.lib.Procedures + java:/Objects/org.eclipse.xtext.xbase.lib.IntegerExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.ExclusiveRange + java:/Objects/org.eclipse.xtext.xbase.lib.IntegerRange + java:/Objects/org.eclipse.xtext.xbase.lib.IterableExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.IteratorExtensions + java:/Objects/com.google.common.collect.Iterators + java:/Objects/com.google.common.collect.MultitransformedIterator + java:/Objects/com.google.common.collect.PeekingIterator + java:/Objects/org.eclipse.xtext.xbase.lib.ListExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.LongExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.MapExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.internal.UnmodifiableMergingMapView + java:/Objects/org.eclipse.xtext.xbase.lib.ObjectExtensions + java:/Objects/com.google.common.base.Objects + java:/Objects/com.google.common.base.ExtraObjectsMethodsForWeb + java:/Objects/org.eclipse.xtext.xbase.lib.ProcedureExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.ShortExtensions + java:/Objects/java.lang.Short + java:/Objects/org.eclipse.xtext.xbase.lib.StringExtensions + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.count + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.avg @@ -62,6 +1047,17 @@ + + + + bold + + + + bold + + + @@ -95,6 +1091,10 @@ + + + + @@ -383,70 +1383,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -460,7 +1396,7 @@ - + KEEP_LOCATION @@ -471,13 +1407,13 @@ - + KEEP_LOCATION KEEP_SIZE KEEP_RATIO - + @@ -497,6 +1433,14 @@ + + + + + bold + + + @@ -528,7 +1472,7 @@ - + KEEP_LOCATION @@ -603,7 +1547,7 @@ - + @@ -648,7 +1592,7 @@ - + KEEP_LOCATION @@ -693,14 +1637,17 @@ - + - - - - + + + bold + + + bold + @@ -748,76 +1695,6 @@ - - - - - strokeColor - - - labelFormat - labelSize - labelColor - - - labelFormat - labelSize - labelColor - - - - - - - - - strokeColor - - - labelSize - labelColor - - - labelSize - labelColor - - - - - - - - - strokeColor - - - labelSize - labelColor - - - labelSize - labelColor - - - - - - - - - strokeColor - - - labelSize - labelColor - - - labelSize - labelColor - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore index bcf0ed99..36db23be 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore @@ -1,6 +1,9 @@ + +
+ @@ -10,18 +13,24 @@ eType="#//HostType" containment="true"/> + derived="true"> + +
+ + + derived="true"> + +
+ + - - + - + - - + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel index 679e2c49..a0ccec7f 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel @@ -21,13 +21,12 @@ - - + @@ -42,7 +41,6 @@ - @@ -56,7 +54,6 @@ - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties new file mode 100644 index 00000000..aa7cf04c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = hu.bme.mit.inf.dslreasoner.domains.cps +providerName = www.example.org diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml new file mode 100644 index 00000000..256b967d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore new file mode 100644 index 00000000..bd8f7d9f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore @@ -0,0 +1,16 @@ +/.CpsApplications.java._trace +/.CpsQueries.java._trace +/.CpsHosts.java._trace +/.TotalMemory.java._trace +/.TotalHdd.java._trace +/.AvailableMemory.java._trace +/.AvailableHdd.java._trace +/.AllocationWithoutResourceRequirement.java._trace +/.NotEnoughAvailableMemory.java._trace +/.NotEnoughAvailableHdd.java._trace +/.InstanceDoesNotSatisfyRequirement.java._trace +/.RequirementNotSatisfied.java._trace +/.AverageFreeMemoryMetric.java._trace +/.AverageFreeHddMetric.java._trace +/.CostMetric.java._trace +/.CpsCost.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java new file mode 100644 index 00000000..be7488b6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java @@ -0,0 +1,717 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(severity = "error", key = {Host, App},
+ *         	message = "Application instance must be allocated to a supported host type.")
+ *         pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) {
+ *         	ApplicationInstance.allocatedTo(App, Host);
+ *         	neg find resourceRequirement(Host, App, _);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AllocationWithoutResourceRequirement extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private ApplicationInstance fApp; + + private static List parameterNames = makeImmutableList("Host", "App"); + + private Match(final HostInstance pHost, final ApplicationInstance pApp) { + this.fHost = pHost; + this.fApp = pApp; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("App".equals(parameterName)) return this.fApp; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"; + } + + @Override + public List parameterNames() { + return AllocationWithoutResourceRequirement.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fApp}; + } + + @Override + public AllocationWithoutResourceRequirement.Match toImmutable() { + return isMutable() ? newMatch(fHost, fApp) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"App\"=" + prettyPrintValue(fApp)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fApp); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AllocationWithoutResourceRequirement.Match)) { + AllocationWithoutResourceRequirement.Match other = (AllocationWithoutResourceRequirement.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fApp, other.fApp); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public AllocationWithoutResourceRequirement specification() { + return AllocationWithoutResourceRequirement.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static AllocationWithoutResourceRequirement.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AllocationWithoutResourceRequirement.Match newMutableMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return new Mutable(pHost, pApp); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public static AllocationWithoutResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return new Immutable(pHost, pApp); + } + + private static final class Mutable extends AllocationWithoutResourceRequirement.Match { + Mutable(final HostInstance pHost, final ApplicationInstance pApp) { + super(pHost, pApp); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AllocationWithoutResourceRequirement.Match { + Immutable(final HostInstance pHost, final ApplicationInstance pApp) { + super(pHost, pApp); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(severity = "error", key = {Host, App},
+   * 	message = "Application instance must be allocated to a supported host type.")
+   * pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) {
+   * 	ApplicationInstance.allocatedTo(App, Host);
+   * 	neg find resourceRequirement(Host, App, _);
+   * }
+   * 
+ * + * @see Match + * @see AllocationWithoutResourceRequirement + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static AllocationWithoutResourceRequirement.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static AllocationWithoutResourceRequirement.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_APP = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AllocationWithoutResourceRequirement.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pHost, pApp}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pHost, pApp}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pApp}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return rawHasMatch(new Object[]{pHost, pApp}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final ApplicationInstance pApp) { + return rawCountMatches(new Object[]{pHost, pApp}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pApp}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public AllocationWithoutResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return AllocationWithoutResourceRequirement.Match.newMatch(pHost, pApp); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final ApplicationInstance pApp) { + return rawStreamAllValuesOfHost(new Object[]{null, pApp}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final ApplicationInstance pApp) { + return rawStreamAllValuesOfHost(new Object[]{null, pApp}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final HostInstance pHost) { + return rawStreamAllValuesOfApp(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final HostInstance pHost) { + return rawStreamAllValuesOfApp(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected AllocationWithoutResourceRequirement.Match tupleToMatch(final Tuple t) { + try { + return AllocationWithoutResourceRequirement.Match.newMatch((HostInstance) t.get(POSITION_HOST), (ApplicationInstance) t.get(POSITION_APP)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AllocationWithoutResourceRequirement.Match arrayToMatch(final Object[] match) { + try { + return AllocationWithoutResourceRequirement.Match.newMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AllocationWithoutResourceRequirement.Match arrayToMatchMutable(final Object[] match) { + try { + return AllocationWithoutResourceRequirement.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return AllocationWithoutResourceRequirement.instance(); + } + } + + private AllocationWithoutResourceRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AllocationWithoutResourceRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AllocationWithoutResourceRequirement.Matcher instantiate(final ViatraQueryEngine engine) { + return AllocationWithoutResourceRequirement.Matcher.on(engine); + } + + @Override + public AllocationWithoutResourceRequirement.Matcher instantiate() { + return AllocationWithoutResourceRequirement.Matcher.create(); + } + + @Override + public AllocationWithoutResourceRequirement.Match newEmptyMatch() { + return AllocationWithoutResourceRequirement.Match.newEmptyMatch(); + } + + @Override + public AllocationWithoutResourceRequirement.Match newMatch(final Object... parameters) { + return AllocationWithoutResourceRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement (visibility: PUBLIC, simpleName: AllocationWithoutResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement (visibility: PUBLIC, simpleName: AllocationWithoutResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AllocationWithoutResourceRequirement INSTANCE = new AllocationWithoutResourceRequirement(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final AllocationWithoutResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App) + )); + // ApplicationInstance.allocatedTo(App, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var_Host); + // neg find resourceRequirement(Host, App, _) + new NegativePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var___0_), ResourceRequirement.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Host"), + new ParameterReference("App") + })); + annotation.addAttribute("message", "Application instance must be allocated to a supported host type."); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java new file mode 100644 index 00000000..22821c4a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java @@ -0,0 +1,743 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}QueryBasedFeature(feature = "availableHdd")
+ *         pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
+ *         	find totalHdd(Host, TotalHdd);
+ *         	RequiredHdd == sum find hddRequirement(Host, _, #_);
+ *         	Hdd == eval(TotalHdd - RequiredHdd);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AvailableHdd extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private Integer fHdd; + + private static List parameterNames = makeImmutableList("Host", "Hdd"); + + private Match(final HostInstance pHost, final Integer pHdd) { + this.fHost = pHost; + this.fHdd = pHdd; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Hdd".equals(parameterName)) return this.fHdd; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getHdd() { + return this.fHdd; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Hdd".equals(parameterName) ) { + this.fHdd = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setHdd(final Integer pHdd) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHdd = pHdd; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; + } + + @Override + public List parameterNames() { + return AvailableHdd.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fHdd}; + } + + @Override + public AvailableHdd.Match toImmutable() { + return isMutable() ? newMatch(fHost, fHdd) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Hdd\"=" + prettyPrintValue(fHdd)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fHdd); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AvailableHdd.Match)) { + AvailableHdd.Match other = (AvailableHdd.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public AvailableHdd specification() { + return AvailableHdd.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static AvailableHdd.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AvailableHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) { + return new Mutable(pHost, pHdd); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public static AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return new Immutable(pHost, pHdd); + } + + private static final class Mutable extends AvailableHdd.Match { + Mutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AvailableHdd.Match { + Immutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}QueryBasedFeature(feature = "availableHdd")
+   * pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
+   * 	find totalHdd(Host, TotalHdd);
+   * 	RequiredHdd == sum find hddRequirement(Host, _, #_);
+   * 	Hdd == eval(TotalHdd - RequiredHdd);
+   * }
+   * 
+ * + * @see Match + * @see AvailableHdd + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static AvailableHdd.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static AvailableHdd.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_HDD = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableHdd.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pHdd) { + return rawHasMatch(new Object[]{pHost, pHdd}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pHdd) { + return rawCountMatches(new Object[]{pHost, pHdd}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final Integer pHdd, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return AvailableHdd.Match.newMatch(pHost, pHdd); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHdd(final Object[] parameters) { + return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected AvailableHdd.Match tupleToMatch(final Tuple t) { + try { + return AvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AvailableHdd.Match arrayToMatch(final Object[] match) { + try { + return AvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AvailableHdd.Match arrayToMatchMutable(final Object[] match) { + try { + return AvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return AvailableHdd.instance(); + } + } + + private AvailableHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AvailableHdd instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) { + return AvailableHdd.Matcher.on(engine); + } + + @Override + public AvailableHdd.Matcher instantiate() { + return AvailableHdd.Matcher.create(); + } + + @Override + public AvailableHdd.Match newEmptyMatch() { + return AvailableHdd.Match.newEmptyMatch(); + } + + @Override + public AvailableHdd.Match newMatch(final Object... parameters) { + return AvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AvailableHdd INSTANCE = new AvailableHdd(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final AvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Hdd"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + PVariable var_TotalHdd = body.getOrCreateVariableByName("TotalHdd"); + PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Hdd), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // find totalHdd(Host, TotalHdd) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalHdd), TotalHdd.instance().getInternalQueryRepresentation()); + // RequiredHdd == sum find hddRequirement(Host, _, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), HddRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); + new Equality(body, var_RequiredHdd, var__virtual_0_); + // Hdd == eval(TotalHdd - RequiredHdd) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern availableHdd"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("RequiredHdd", "TotalHdd");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); + Integer TotalHdd = (Integer) provider.getValue("TotalHdd"); + return evaluateExpression_1_1(RequiredHdd, TotalHdd); + } + }, var__virtual_1_ ); + new Equality(body, var_Hdd, var__virtual_1_); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "availableHdd"); + addAnnotation(annotation); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer RequiredHdd, final Integer TotalHdd) { + return ((TotalHdd).intValue() - (RequiredHdd).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java new file mode 100644 index 00000000..930a24ba --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java @@ -0,0 +1,743 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}QueryBasedFeature(feature = "availableMemory")
+ *         pattern availableMemory(Host : HostInstance, Memory : java Integer) {
+ *         	find totalMemory(Host, TotalMemory);
+ *         	RequiredMemory == sum find memoryRequirement(Host, _, #_);
+ *         	Memory == eval(TotalMemory - RequiredMemory);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AvailableMemory extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private Integer fMemory; + + private static List parameterNames = makeImmutableList("Host", "Memory"); + + private Match(final HostInstance pHost, final Integer pMemory) { + this.fHost = pHost; + this.fMemory = pMemory; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Memory".equals(parameterName)) return this.fMemory; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getMemory() { + return this.fMemory; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Memory".equals(parameterName) ) { + this.fMemory = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setMemory(final Integer pMemory) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fMemory = pMemory; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; + } + + @Override + public List parameterNames() { + return AvailableMemory.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fMemory}; + } + + @Override + public AvailableMemory.Match toImmutable() { + return isMutable() ? newMatch(fHost, fMemory) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Memory\"=" + prettyPrintValue(fMemory)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fMemory); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AvailableMemory.Match)) { + AvailableMemory.Match other = (AvailableMemory.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public AvailableMemory specification() { + return AvailableMemory.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static AvailableMemory.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AvailableMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) { + return new Mutable(pHost, pMemory); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public static AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return new Immutable(pHost, pMemory); + } + + private static final class Mutable extends AvailableMemory.Match { + Mutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AvailableMemory.Match { + Immutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}QueryBasedFeature(feature = "availableMemory")
+   * pattern availableMemory(Host : HostInstance, Memory : java Integer) {
+   * 	find totalMemory(Host, TotalMemory);
+   * 	RequiredMemory == sum find memoryRequirement(Host, _, #_);
+   * 	Memory == eval(TotalMemory - RequiredMemory);
+   * }
+   * 
+ * + * @see Match + * @see AvailableMemory + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static AvailableMemory.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static AvailableMemory.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_MEMORY = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableMemory.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pMemory) { + return rawHasMatch(new Object[]{pHost, pMemory}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pMemory) { + return rawCountMatches(new Object[]{pHost, pMemory}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final Integer pMemory, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return AvailableMemory.Match.newMatch(pHost, pMemory); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfMemory(final Object[] parameters) { + return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected AvailableMemory.Match tupleToMatch(final Tuple t) { + try { + return AvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AvailableMemory.Match arrayToMatch(final Object[] match) { + try { + return AvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AvailableMemory.Match arrayToMatchMutable(final Object[] match) { + try { + return AvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return AvailableMemory.instance(); + } + } + + private AvailableMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AvailableMemory instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) { + return AvailableMemory.Matcher.on(engine); + } + + @Override + public AvailableMemory.Matcher instantiate() { + return AvailableMemory.Matcher.create(); + } + + @Override + public AvailableMemory.Match newEmptyMatch() { + return AvailableMemory.Match.newEmptyMatch(); + } + + @Override + public AvailableMemory.Match newMatch(final Object... parameters) { + return AvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AvailableMemory INSTANCE = new AvailableMemory(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final AvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Memory"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + PVariable var_TotalMemory = body.getOrCreateVariableByName("TotalMemory"); + PVariable var_RequiredMemory = body.getOrCreateVariableByName("RequiredMemory"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Memory), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // find totalMemory(Host, TotalMemory) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalMemory), TotalMemory.instance().getInternalQueryRepresentation()); + // RequiredMemory == sum find memoryRequirement(Host, _, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), MemoryRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); + new Equality(body, var_RequiredMemory, var__virtual_0_); + // Memory == eval(TotalMemory - RequiredMemory) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern availableMemory"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("RequiredMemory", "TotalMemory");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer RequiredMemory = (Integer) provider.getValue("RequiredMemory"); + Integer TotalMemory = (Integer) provider.getValue("TotalMemory"); + return evaluateExpression_1_1(RequiredMemory, TotalMemory); + } + }, var__virtual_1_ ); + new Equality(body, var_Memory, var__virtual_1_); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "availableMemory"); + addAnnotation(annotation); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer RequiredMemory, final Integer TotalMemory) { + return ((TotalMemory).intValue() - (RequiredMemory).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java new file mode 100644 index 00000000..59d4ad27 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java @@ -0,0 +1,540 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.avg; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern averageFreeHddMetric(Average : java Double) {
+ *         	Average == avg find freeHddPercentage(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Double fAverage; + + private static List parameterNames = makeImmutableList("Average"); + + private Match(final Double pAverage) { + this.fAverage = pAverage; + } + + @Override + public Object get(final String parameterName) { + if ("Average".equals(parameterName)) return this.fAverage; + return null; + } + + public Double getAverage() { + return this.fAverage; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Average".equals(parameterName) ) { + this.fAverage = (Double) newValue; + return true; + } + return false; + } + + public void setAverage(final Double pAverage) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fAverage = pAverage; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"; + } + + @Override + public List parameterNames() { + return AverageFreeHddMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fAverage}; + } + + @Override + public AverageFreeHddMetric.Match toImmutable() { + return isMutable() ? newMatch(fAverage) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Average\"=" + prettyPrintValue(fAverage)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fAverage); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AverageFreeHddMetric.Match)) { + AverageFreeHddMetric.Match other = (AverageFreeHddMetric.Match) obj; + return Objects.equals(fAverage, other.fAverage); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public AverageFreeHddMetric specification() { + return AverageFreeHddMetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static AverageFreeHddMetric.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AverageFreeHddMetric.Match newMutableMatch(final Double pAverage) { + return new Mutable(pAverage); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public static AverageFreeHddMetric.Match newMatch(final Double pAverage) { + return new Immutable(pAverage); + } + + private static final class Mutable extends AverageFreeHddMetric.Match { + Mutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AverageFreeHddMetric.Match { + Immutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern averageFreeHddMetric(Average : java Double) {
+   * 	Average == avg find freeHddPercentage(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see AverageFreeHddMetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static AverageFreeHddMetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static AverageFreeHddMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_AVERAGE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeHddMetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Double pAverage) { + return rawGetOneArbitraryMatch(new Object[]{pAverage}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pAverage) { + return rawHasMatch(new Object[]{pAverage}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pAverage) { + return rawCountMatches(new Object[]{pAverage}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Double pAverage, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pAverage}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public AverageFreeHddMetric.Match newMatch(final Double pAverage) { + return AverageFreeHddMetric.Match.newMatch(pAverage); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfAverage(final Object[] parameters) { + return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()); + } + + @Override + protected AverageFreeHddMetric.Match tupleToMatch(final Tuple t) { + try { + return AverageFreeHddMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeHddMetric.Match arrayToMatch(final Object[] match) { + try { + return AverageFreeHddMetric.Match.newMatch((Double) match[POSITION_AVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeHddMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return AverageFreeHddMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return AverageFreeHddMetric.instance(); + } + } + + private AverageFreeHddMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AverageFreeHddMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AverageFreeHddMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return AverageFreeHddMetric.Matcher.on(engine); + } + + @Override + public AverageFreeHddMetric.Matcher instantiate() { + return AverageFreeHddMetric.Matcher.create(); + } + + @Override + public AverageFreeHddMetric.Match newEmptyMatch() { + return AverageFreeHddMetric.Match.newEmptyMatch(); + } + + @Override + public AverageFreeHddMetric.Match newMatch(final Object... parameters) { + return AverageFreeHddMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric (visibility: PUBLIC, simpleName: AverageFreeHddMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric (visibility: PUBLIC, simpleName: AverageFreeHddMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AverageFreeHddMetric INSTANCE = new AverageFreeHddMetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final AverageFreeHddMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Average); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Average"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Average = body.getOrCreateVariableByName("Average"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Average, parameter_Average) + )); + // Average == avg find freeHddPercentage(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeHddPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Average, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java new file mode 100644 index 00000000..a0d087f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java @@ -0,0 +1,540 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.avg; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern averageFreeMemoryMetric(Average : java Double) {
+ *         	Average == avg find freeMemoryPercentage(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Double fAverage; + + private static List parameterNames = makeImmutableList("Average"); + + private Match(final Double pAverage) { + this.fAverage = pAverage; + } + + @Override + public Object get(final String parameterName) { + if ("Average".equals(parameterName)) return this.fAverage; + return null; + } + + public Double getAverage() { + return this.fAverage; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Average".equals(parameterName) ) { + this.fAverage = (Double) newValue; + return true; + } + return false; + } + + public void setAverage(final Double pAverage) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fAverage = pAverage; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"; + } + + @Override + public List parameterNames() { + return AverageFreeMemoryMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fAverage}; + } + + @Override + public AverageFreeMemoryMetric.Match toImmutable() { + return isMutable() ? newMatch(fAverage) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Average\"=" + prettyPrintValue(fAverage)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fAverage); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AverageFreeMemoryMetric.Match)) { + AverageFreeMemoryMetric.Match other = (AverageFreeMemoryMetric.Match) obj; + return Objects.equals(fAverage, other.fAverage); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public AverageFreeMemoryMetric specification() { + return AverageFreeMemoryMetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static AverageFreeMemoryMetric.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AverageFreeMemoryMetric.Match newMutableMatch(final Double pAverage) { + return new Mutable(pAverage); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public static AverageFreeMemoryMetric.Match newMatch(final Double pAverage) { + return new Immutable(pAverage); + } + + private static final class Mutable extends AverageFreeMemoryMetric.Match { + Mutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AverageFreeMemoryMetric.Match { + Immutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern averageFreeMemoryMetric(Average : java Double) {
+   * 	Average == avg find freeMemoryPercentage(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see AverageFreeMemoryMetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static AverageFreeMemoryMetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static AverageFreeMemoryMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_AVERAGE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeMemoryMetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Double pAverage) { + return rawGetOneArbitraryMatch(new Object[]{pAverage}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pAverage) { + return rawHasMatch(new Object[]{pAverage}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pAverage) { + return rawCountMatches(new Object[]{pAverage}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Double pAverage, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pAverage}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public AverageFreeMemoryMetric.Match newMatch(final Double pAverage) { + return AverageFreeMemoryMetric.Match.newMatch(pAverage); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfAverage(final Object[] parameters) { + return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()); + } + + @Override + protected AverageFreeMemoryMetric.Match tupleToMatch(final Tuple t) { + try { + return AverageFreeMemoryMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeMemoryMetric.Match arrayToMatch(final Object[] match) { + try { + return AverageFreeMemoryMetric.Match.newMatch((Double) match[POSITION_AVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeMemoryMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return AverageFreeMemoryMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return AverageFreeMemoryMetric.instance(); + } + } + + private AverageFreeMemoryMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AverageFreeMemoryMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AverageFreeMemoryMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return AverageFreeMemoryMetric.Matcher.on(engine); + } + + @Override + public AverageFreeMemoryMetric.Matcher instantiate() { + return AverageFreeMemoryMetric.Matcher.create(); + } + + @Override + public AverageFreeMemoryMetric.Match newEmptyMatch() { + return AverageFreeMemoryMetric.Match.newEmptyMatch(); + } + + @Override + public AverageFreeMemoryMetric.Match newMatch(final Object... parameters) { + return AverageFreeMemoryMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric (visibility: PUBLIC, simpleName: AverageFreeMemoryMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric (visibility: PUBLIC, simpleName: AverageFreeMemoryMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AverageFreeMemoryMetric INSTANCE = new AverageFreeMemoryMetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final AverageFreeMemoryMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Average); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Average"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Average = body.getOrCreateVariableByName("Average"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Average, parameter_Average) + )); + // Average == avg find freeMemoryPercentage(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeMemoryPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Average, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java new file mode 100644 index 00000000..4d8ca4cc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java @@ -0,0 +1,540 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern costMetric(Cost : java Integer) {
+ *         	Cost == sum find cpsCost(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CostMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Integer fCost; + + private static List parameterNames = makeImmutableList("Cost"); + + private Match(final Integer pCost) { + this.fCost = pCost; + } + + @Override + public Object get(final String parameterName) { + if ("Cost".equals(parameterName)) return this.fCost; + return null; + } + + public Integer getCost() { + return this.fCost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cost".equals(parameterName) ) { + this.fCost = (Integer) newValue; + return true; + } + return false; + } + + public void setCost(final Integer pCost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCost = pCost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric"; + } + + @Override + public List parameterNames() { + return CostMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCost}; + } + + @Override + public CostMetric.Match toImmutable() { + return isMutable() ? newMatch(fCost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cost\"=" + prettyPrintValue(fCost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CostMetric.Match)) { + CostMetric.Match other = (CostMetric.Match) obj; + return Objects.equals(fCost, other.fCost); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public CostMetric specification() { + return CostMetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static CostMetric.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CostMetric.Match newMutableMatch(final Integer pCost) { + return new Mutable(pCost); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public static CostMetric.Match newMatch(final Integer pCost) { + return new Immutable(pCost); + } + + private static final class Mutable extends CostMetric.Match { + Mutable(final Integer pCost) { + super(pCost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CostMetric.Match { + Immutable(final Integer pCost) { + super(pCost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern costMetric(Cost : java Integer) {
+   * 	Cost == sum find cpsCost(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see CostMetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static CostMetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static CostMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_COST = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CostMetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Integer pCost) { + return rawStreamAllMatches(new Object[]{pCost}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Integer pCost) { + return rawStreamAllMatches(new Object[]{pCost}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Integer pCost) { + return rawGetOneArbitraryMatch(new Object[]{pCost}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Integer pCost) { + return rawHasMatch(new Object[]{pCost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Integer pCost) { + return rawCountMatches(new Object[]{pCost}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Integer pCost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCost}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public CostMetric.Match newMatch(final Integer pCost) { + return CostMetric.Match.newMatch(pCost); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCost(final Object[] parameters) { + return rawStreamAllValues(POSITION_COST, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCost() { + return rawStreamAllValuesOfCost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost() { + return rawStreamAllValuesOfCost(emptyArray()); + } + + @Override + protected CostMetric.Match tupleToMatch(final Tuple t) { + try { + return CostMetric.Match.newMatch((Integer) t.get(POSITION_COST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CostMetric.Match arrayToMatch(final Object[] match) { + try { + return CostMetric.Match.newMatch((Integer) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CostMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return CostMetric.Match.newMutableMatch((Integer) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return CostMetric.instance(); + } + } + + private CostMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CostMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CostMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return CostMetric.Matcher.on(engine); + } + + @Override + public CostMetric.Matcher instantiate() { + return CostMetric.Matcher.create(); + } + + @Override + public CostMetric.Match newEmptyMatch() { + return CostMetric.Match.newEmptyMatch(); + } + + @Override + public CostMetric.Match newMatch(final Object... parameters) { + return CostMetric.Match.newMatch((java.lang.Integer) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CostMetric INSTANCE = new CostMetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final CostMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.costMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // Cost == sum find cpsCost(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___0_, var___1_), CpsCost.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Cost, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java new file mode 100644 index 00000000..2c20b38e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java @@ -0,0 +1,705 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}QueryBasedFeature(feature = "applications")
+ *         pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
+ *         	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CpsApplications extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private CyberPhysicalSystem fCps; + + private ApplicationInstance fAppInstance; + + private static List parameterNames = makeImmutableList("Cps", "AppInstance"); + + private Match(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + this.fCps = pCps; + this.fAppInstance = pAppInstance; + } + + @Override + public Object get(final String parameterName) { + if ("Cps".equals(parameterName)) return this.fCps; + if ("AppInstance".equals(parameterName)) return this.fAppInstance; + return null; + } + + public CyberPhysicalSystem getCps() { + return this.fCps; + } + + public ApplicationInstance getAppInstance() { + return this.fAppInstance; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cps".equals(parameterName) ) { + this.fCps = (CyberPhysicalSystem) newValue; + return true; + } + if ("AppInstance".equals(parameterName) ) { + this.fAppInstance = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setCps(final CyberPhysicalSystem pCps) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCps = pCps; + } + + public void setAppInstance(final ApplicationInstance pAppInstance) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fAppInstance = pAppInstance; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; + } + + @Override + public List parameterNames() { + return CpsApplications.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCps, fAppInstance}; + } + + @Override + public CpsApplications.Match toImmutable() { + return isMutable() ? newMatch(fCps, fAppInstance) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); + result.append("\"AppInstance\"=" + prettyPrintValue(fAppInstance)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCps, fAppInstance); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CpsApplications.Match)) { + CpsApplications.Match other = (CpsApplications.Match) obj; + return Objects.equals(fCps, other.fCps) && Objects.equals(fAppInstance, other.fAppInstance); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public CpsApplications specification() { + return CpsApplications.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static CpsApplications.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CpsApplications.Match newMutableMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return new Mutable(pCps, pAppInstance); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public static CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return new Immutable(pCps, pAppInstance); + } + + private static final class Mutable extends CpsApplications.Match { + Mutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + super(pCps, pAppInstance); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CpsApplications.Match { + Immutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + super(pCps, pAppInstance); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}QueryBasedFeature(feature = "applications")
+   * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
+   * 	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
+   * }
+   * 
+ * + * @see Match + * @see CpsApplications + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static CpsApplications.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static CpsApplications.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_CPS = 0; + + private static final int POSITION_APPINSTANCE = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsApplications.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawStreamAllMatches(new Object[]{pCps, pAppInstance}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawStreamAllMatches(new Object[]{pCps, pAppInstance}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawGetOneArbitraryMatch(new Object[]{pCps, pAppInstance}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawHasMatch(new Object[]{pCps, pAppInstance}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawCountMatches(new Object[]{pCps, pAppInstance}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCps, pAppInstance}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return CpsApplications.Match.newMatch(pCps, pAppInstance); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { + return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final ApplicationInstance pAppInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final ApplicationInstance pAppInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfAppInstance(final Object[] parameters) { + return rawStreamAllValues(POSITION_APPINSTANCE, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAppInstance() { + return rawStreamAllValuesOfAppInstance(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAppInstance() { + return rawStreamAllValuesOfAppInstance(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAppInstance(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfAppInstance(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAppInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAppInstance(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfAppInstance(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAppInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}).collect(Collectors.toSet()); + } + + @Override + protected CpsApplications.Match tupleToMatch(final Tuple t) { + try { + return CpsApplications.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (ApplicationInstance) t.get(POSITION_APPINSTANCE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CpsApplications.Match arrayToMatch(final Object[] match) { + try { + return CpsApplications.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CpsApplications.Match arrayToMatchMutable(final Object[] match) { + try { + return CpsApplications.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return CpsApplications.instance(); + } + } + + private CpsApplications() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsApplications instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CpsApplications.Matcher instantiate(final ViatraQueryEngine engine) { + return CpsApplications.Matcher.on(engine); + } + + @Override + public CpsApplications.Matcher instantiate() { + return CpsApplications.Matcher.create(); + } + + @Override + public CpsApplications.Match newEmptyMatch() { + return CpsApplications.Match.newEmptyMatch(); + } + + @Override + public CpsApplications.Match newMatch(final Object... parameters) { + return CpsApplications.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CpsApplications INSTANCE = new CpsApplications(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_AppInstance = new PParameter("AppInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_AppInstance); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","AppInstance"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_AppInstance, parameter_AppInstance) + )); + // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance) + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_1_, var_AppInstance); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "applications"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java new file mode 100644 index 00000000..169a30e5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java @@ -0,0 +1,738 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) {
+ *         	AppCount == count find cpsApplications(Cps, _);
+ *         	HostCost == sum find hostInstanceCost(Cps, _, #_);
+ *         	Cost == eval(5  AppCount + HostCost);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CpsCost extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private CyberPhysicalSystem fCps; + + private Integer fCost; + + private static List parameterNames = makeImmutableList("Cps", "Cost"); + + private Match(final CyberPhysicalSystem pCps, final Integer pCost) { + this.fCps = pCps; + this.fCost = pCost; + } + + @Override + public Object get(final String parameterName) { + if ("Cps".equals(parameterName)) return this.fCps; + if ("Cost".equals(parameterName)) return this.fCost; + return null; + } + + public CyberPhysicalSystem getCps() { + return this.fCps; + } + + public Integer getCost() { + return this.fCost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cps".equals(parameterName) ) { + this.fCps = (CyberPhysicalSystem) newValue; + return true; + } + if ("Cost".equals(parameterName) ) { + this.fCost = (Integer) newValue; + return true; + } + return false; + } + + public void setCps(final CyberPhysicalSystem pCps) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCps = pCps; + } + + public void setCost(final Integer pCost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCost = pCost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"; + } + + @Override + public List parameterNames() { + return CpsCost.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCps, fCost}; + } + + @Override + public CpsCost.Match toImmutable() { + return isMutable() ? newMatch(fCps, fCost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); + result.append("\"Cost\"=" + prettyPrintValue(fCost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCps, fCost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CpsCost.Match)) { + CpsCost.Match other = (CpsCost.Match) obj; + return Objects.equals(fCps, other.fCps) && Objects.equals(fCost, other.fCost); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public CpsCost specification() { + return CpsCost.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static CpsCost.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CpsCost.Match newMutableMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return new Mutable(pCps, pCost); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public static CpsCost.Match newMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return new Immutable(pCps, pCost); + } + + private static final class Mutable extends CpsCost.Match { + Mutable(final CyberPhysicalSystem pCps, final Integer pCost) { + super(pCps, pCost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CpsCost.Match { + Immutable(final CyberPhysicalSystem pCps, final Integer pCost) { + super(pCps, pCost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) {
+   * 	AppCount == count find cpsApplications(Cps, _);
+   * 	HostCost == sum find hostInstanceCost(Cps, _, #_);
+   * 	Cost == eval(5  AppCount + HostCost);
+   * }
+   * 
+ * + * @see Match + * @see CpsCost + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static CpsCost.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static CpsCost.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_CPS = 0; + + private static final int POSITION_COST = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsCost.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final CyberPhysicalSystem pCps, final Integer pCost) { + return rawStreamAllMatches(new Object[]{pCps, pCost}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final CyberPhysicalSystem pCps, final Integer pCost) { + return rawStreamAllMatches(new Object[]{pCps, pCost}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return rawGetOneArbitraryMatch(new Object[]{pCps, pCost}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return rawHasMatch(new Object[]{pCps, pCost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final CyberPhysicalSystem pCps, final Integer pCost) { + return rawCountMatches(new Object[]{pCps, pCost}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final Integer pCost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCps, pCost}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public CpsCost.Match newMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return CpsCost.Match.newMatch(pCps, pCost); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { + return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final Integer pCost) { + return rawStreamAllValuesOfCps(new Object[]{null, pCost}); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final Integer pCost) { + return rawStreamAllValuesOfCps(new Object[]{null, pCost}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCost(final Object[] parameters) { + return rawStreamAllValues(POSITION_COST, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCost() { + return rawStreamAllValuesOfCost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost() { + return rawStreamAllValuesOfCost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfCost(new Object[]{pCps, null}); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCost(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCost(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfCost(new Object[]{pCps, null}).collect(Collectors.toSet()); + } + + @Override + protected CpsCost.Match tupleToMatch(final Tuple t) { + try { + return CpsCost.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (Integer) t.get(POSITION_COST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CpsCost.Match arrayToMatch(final Object[] match) { + try { + return CpsCost.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (Integer) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CpsCost.Match arrayToMatchMutable(final Object[] match) { + try { + return CpsCost.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (Integer) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return CpsCost.instance(); + } + } + + private CpsCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CpsCost.Matcher instantiate(final ViatraQueryEngine engine) { + return CpsCost.Matcher.on(engine); + } + + @Override + public CpsCost.Matcher instantiate() { + return CpsCost.Matcher.create(); + } + + @Override + public CpsCost.Match newEmptyMatch() { + return CpsCost.Match.newEmptyMatch(); + } + + @Override + public CpsCost.Match newMatch(final Object... parameters) { + return CpsCost.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost (visibility: PUBLIC, simpleName: CpsCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost (visibility: PUBLIC, simpleName: CpsCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CpsCost INSTANCE = new CpsCost(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final CpsCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var_AppCount = body.getOrCreateVariableByName("AppCount"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_HostCost = body.getOrCreateVariableByName("HostCost"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + PVariable var___2_ = body.getOrCreateVariableByName("_<2>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // AppCount == count find cpsApplications(Cps, _) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var_Cps, var___0_), CpsApplications.instance().getInternalQueryRepresentation(), var__virtual_0_); + new Equality(body, var_AppCount, var__virtual_0_); + // HostCost == sum find hostInstanceCost(Cps, _, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Cps, var___1_, var___2_), HostInstanceCost.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); + new Equality(body, var_HostCost, var__virtual_1_); + // Cost == eval(5 * AppCount + HostCost) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern cpsCost"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("AppCount", "HostCost");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer AppCount = (Integer) provider.getValue("AppCount"); + Integer HostCost = (Integer) provider.getValue("HostCost"); + return evaluateExpression_1_1(AppCount, HostCost); + } + }, var__virtual_2_ ); + new Equality(body, var_Cost, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer AppCount, final Integer HostCost) { + return ((5 * (AppCount).intValue()) + (HostCost).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java new file mode 100644 index 00000000..e1abf758 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java @@ -0,0 +1,705 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}QueryBasedFeature(feature = "hosts")
+ *         pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
+ *         	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CpsHosts extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private CyberPhysicalSystem fCps; + + private HostInstance fHostInstance; + + private static List parameterNames = makeImmutableList("Cps", "HostInstance"); + + private Match(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + this.fCps = pCps; + this.fHostInstance = pHostInstance; + } + + @Override + public Object get(final String parameterName) { + if ("Cps".equals(parameterName)) return this.fCps; + if ("HostInstance".equals(parameterName)) return this.fHostInstance; + return null; + } + + public CyberPhysicalSystem getCps() { + return this.fCps; + } + + public HostInstance getHostInstance() { + return this.fHostInstance; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cps".equals(parameterName) ) { + this.fCps = (CyberPhysicalSystem) newValue; + return true; + } + if ("HostInstance".equals(parameterName) ) { + this.fHostInstance = (HostInstance) newValue; + return true; + } + return false; + } + + public void setCps(final CyberPhysicalSystem pCps) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCps = pCps; + } + + public void setHostInstance(final HostInstance pHostInstance) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHostInstance = pHostInstance; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; + } + + @Override + public List parameterNames() { + return CpsHosts.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCps, fHostInstance}; + } + + @Override + public CpsHosts.Match toImmutable() { + return isMutable() ? newMatch(fCps, fHostInstance) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); + result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCps, fHostInstance); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CpsHosts.Match)) { + CpsHosts.Match other = (CpsHosts.Match) obj; + return Objects.equals(fCps, other.fCps) && Objects.equals(fHostInstance, other.fHostInstance); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public CpsHosts specification() { + return CpsHosts.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static CpsHosts.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CpsHosts.Match newMutableMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return new Mutable(pCps, pHostInstance); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public static CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return new Immutable(pCps, pHostInstance); + } + + private static final class Mutable extends CpsHosts.Match { + Mutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + super(pCps, pHostInstance); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CpsHosts.Match { + Immutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + super(pCps, pHostInstance); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}QueryBasedFeature(feature = "hosts")
+   * pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
+   * 	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
+   * }
+   * 
+ * + * @see Match + * @see CpsHosts + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static CpsHosts.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static CpsHosts.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_CPS = 0; + + private static final int POSITION_HOSTINSTANCE = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsHosts.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawStreamAllMatches(new Object[]{pCps, pHostInstance}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawStreamAllMatches(new Object[]{pCps, pHostInstance}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawGetOneArbitraryMatch(new Object[]{pCps, pHostInstance}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawHasMatch(new Object[]{pCps, pHostInstance}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawCountMatches(new Object[]{pCps, pHostInstance}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCps, pHostInstance}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return CpsHosts.Match.newMatch(pCps, pHostInstance); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { + return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final HostInstance pHostInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final HostInstance pHostInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHostInstance(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOSTINSTANCE, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance() { + return rawStreamAllValuesOfHostInstance(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance() { + return rawStreamAllValuesOfHostInstance(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfHostInstance(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfHostInstance(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}).collect(Collectors.toSet()); + } + + @Override + protected CpsHosts.Match tupleToMatch(final Tuple t) { + try { + return CpsHosts.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (HostInstance) t.get(POSITION_HOSTINSTANCE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CpsHosts.Match arrayToMatch(final Object[] match) { + try { + return CpsHosts.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CpsHosts.Match arrayToMatchMutable(final Object[] match) { + try { + return CpsHosts.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return CpsHosts.instance(); + } + } + + private CpsHosts() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsHosts instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CpsHosts.Matcher instantiate(final ViatraQueryEngine engine) { + return CpsHosts.Matcher.on(engine); + } + + @Override + public CpsHosts.Matcher instantiate() { + return CpsHosts.Matcher.create(); + } + + @Override + public CpsHosts.Match newEmptyMatch() { + return CpsHosts.Match.newEmptyMatch(); + } + + @Override + public CpsHosts.Match newMatch(final Object... parameters) { + return CpsHosts.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CpsHosts INSTANCE = new CpsHosts(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final CpsHosts.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_HostInstance); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","HostInstance"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_HostInstance, parameter_HostInstance) + )); + // CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance) + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "hostTypes"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_1_, var_HostInstance); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "hosts"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java new file mode 100644 index 00000000..4442718b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java @@ -0,0 +1,207 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; + +/** + * A pattern group formed of all public patterns defined in CpsQueries.vql. + * + *

Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare + * a VIATRA Query engine for matching all patterns originally defined in file CpsQueries.vql, + * in order to achieve better performance than one-by-one on-demand matcher initialization. + * + *

From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns:

    + *
  • cpsApplications
  • + *
  • cpsHosts
  • + *
  • totalMemory
  • + *
  • totalHdd
  • + *
  • availableMemory
  • + *
  • availableHdd
  • + *
  • allocationWithoutResourceRequirement
  • + *
  • notEnoughAvailableMemory
  • + *
  • notEnoughAvailableHdd
  • + *
  • instanceDoesNotSatisfyRequirement
  • + *
  • requirementNotSatisfied
  • + *
  • averageFreeMemoryMetric
  • + *
  • averageFreeHddMetric
  • + *
  • costMetric
  • + *
  • cpsCost
  • + *
+ * + * @see IQueryGroup + * + */ +@SuppressWarnings("all") +public final class CpsQueries extends BaseGeneratedPatternGroup { + /** + * Access the pattern group. + * + * @return the singleton instance of the group + * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications + * + */ + public static CpsQueries instance() { + if (INSTANCE == null) { + INSTANCE = new CpsQueries(); + } + return INSTANCE; + } + + private static CpsQueries INSTANCE; + + private CpsQueries() { + querySpecifications.add(CpsApplications.instance()); + querySpecifications.add(CpsHosts.instance()); + querySpecifications.add(TotalMemory.instance()); + querySpecifications.add(TotalHdd.instance()); + querySpecifications.add(AvailableMemory.instance()); + querySpecifications.add(AvailableHdd.instance()); + querySpecifications.add(AllocationWithoutResourceRequirement.instance()); + querySpecifications.add(NotEnoughAvailableMemory.instance()); + querySpecifications.add(NotEnoughAvailableHdd.instance()); + querySpecifications.add(InstanceDoesNotSatisfyRequirement.instance()); + querySpecifications.add(RequirementNotSatisfied.instance()); + querySpecifications.add(AverageFreeMemoryMetric.instance()); + querySpecifications.add(AverageFreeHddMetric.instance()); + querySpecifications.add(CostMetric.instance()); + querySpecifications.add(CpsCost.instance()); + } + + public CpsApplications getCpsApplications() { + return CpsApplications.instance(); + } + + public CpsApplications.Matcher getCpsApplications(final ViatraQueryEngine engine) { + return CpsApplications.Matcher.on(engine); + } + + public CpsHosts getCpsHosts() { + return CpsHosts.instance(); + } + + public CpsHosts.Matcher getCpsHosts(final ViatraQueryEngine engine) { + return CpsHosts.Matcher.on(engine); + } + + public TotalMemory getTotalMemory() { + return TotalMemory.instance(); + } + + public TotalMemory.Matcher getTotalMemory(final ViatraQueryEngine engine) { + return TotalMemory.Matcher.on(engine); + } + + public TotalHdd getTotalHdd() { + return TotalHdd.instance(); + } + + public TotalHdd.Matcher getTotalHdd(final ViatraQueryEngine engine) { + return TotalHdd.Matcher.on(engine); + } + + public AvailableMemory getAvailableMemory() { + return AvailableMemory.instance(); + } + + public AvailableMemory.Matcher getAvailableMemory(final ViatraQueryEngine engine) { + return AvailableMemory.Matcher.on(engine); + } + + public AvailableHdd getAvailableHdd() { + return AvailableHdd.instance(); + } + + public AvailableHdd.Matcher getAvailableHdd(final ViatraQueryEngine engine) { + return AvailableHdd.Matcher.on(engine); + } + + public AllocationWithoutResourceRequirement getAllocationWithoutResourceRequirement() { + return AllocationWithoutResourceRequirement.instance(); + } + + public AllocationWithoutResourceRequirement.Matcher getAllocationWithoutResourceRequirement(final ViatraQueryEngine engine) { + return AllocationWithoutResourceRequirement.Matcher.on(engine); + } + + public NotEnoughAvailableMemory getNotEnoughAvailableMemory() { + return NotEnoughAvailableMemory.instance(); + } + + public NotEnoughAvailableMemory.Matcher getNotEnoughAvailableMemory(final ViatraQueryEngine engine) { + return NotEnoughAvailableMemory.Matcher.on(engine); + } + + public NotEnoughAvailableHdd getNotEnoughAvailableHdd() { + return NotEnoughAvailableHdd.instance(); + } + + public NotEnoughAvailableHdd.Matcher getNotEnoughAvailableHdd(final ViatraQueryEngine engine) { + return NotEnoughAvailableHdd.Matcher.on(engine); + } + + public InstanceDoesNotSatisfyRequirement getInstanceDoesNotSatisfyRequirement() { + return InstanceDoesNotSatisfyRequirement.instance(); + } + + public InstanceDoesNotSatisfyRequirement.Matcher getInstanceDoesNotSatisfyRequirement(final ViatraQueryEngine engine) { + return InstanceDoesNotSatisfyRequirement.Matcher.on(engine); + } + + public RequirementNotSatisfied getRequirementNotSatisfied() { + return RequirementNotSatisfied.instance(); + } + + public RequirementNotSatisfied.Matcher getRequirementNotSatisfied(final ViatraQueryEngine engine) { + return RequirementNotSatisfied.Matcher.on(engine); + } + + public AverageFreeMemoryMetric getAverageFreeMemoryMetric() { + return AverageFreeMemoryMetric.instance(); + } + + public AverageFreeMemoryMetric.Matcher getAverageFreeMemoryMetric(final ViatraQueryEngine engine) { + return AverageFreeMemoryMetric.Matcher.on(engine); + } + + public AverageFreeHddMetric getAverageFreeHddMetric() { + return AverageFreeHddMetric.instance(); + } + + public AverageFreeHddMetric.Matcher getAverageFreeHddMetric(final ViatraQueryEngine engine) { + return AverageFreeHddMetric.Matcher.on(engine); + } + + public CostMetric getCostMetric() { + return CostMetric.instance(); + } + + public CostMetric.Matcher getCostMetric(final ViatraQueryEngine engine) { + return CostMetric.Matcher.on(engine); + } + + public CpsCost getCpsCost() { + return CpsCost.instance(); + } + + public CpsCost.Matcher getCpsCost(final ViatraQueryEngine engine) { + return CpsCost.Matcher.on(engine); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java new file mode 100644 index 00000000..14deb337 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java @@ -0,0 +1,716 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(severity = "error", key = {Req, App},
+ *         	message = "Requirement must be satisfied by the required application type.")
+ *         pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) {
+ *         	Requirement.instances(Req, App);
+ *         	neg find satisfyingInstance(Req, App);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class InstanceDoesNotSatisfyRequirement extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Requirement fReq; + + private ApplicationInstance fApp; + + private static List parameterNames = makeImmutableList("Req", "App"); + + private Match(final Requirement pReq, final ApplicationInstance pApp) { + this.fReq = pReq; + this.fApp = pApp; + } + + @Override + public Object get(final String parameterName) { + if ("Req".equals(parameterName)) return this.fReq; + if ("App".equals(parameterName)) return this.fApp; + return null; + } + + public Requirement getReq() { + return this.fReq; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Req".equals(parameterName) ) { + this.fReq = (Requirement) newValue; + return true; + } + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setReq(final Requirement pReq) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fReq = pReq; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"; + } + + @Override + public List parameterNames() { + return InstanceDoesNotSatisfyRequirement.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fReq, fApp}; + } + + @Override + public InstanceDoesNotSatisfyRequirement.Match toImmutable() { + return isMutable() ? newMatch(fReq, fApp) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Req\"=" + prettyPrintValue(fReq) + ", "); + result.append("\"App\"=" + prettyPrintValue(fApp)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fReq, fApp); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof InstanceDoesNotSatisfyRequirement.Match)) { + InstanceDoesNotSatisfyRequirement.Match other = (InstanceDoesNotSatisfyRequirement.Match) obj; + return Objects.equals(fReq, other.fReq) && Objects.equals(fApp, other.fApp); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public InstanceDoesNotSatisfyRequirement specification() { + return InstanceDoesNotSatisfyRequirement.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static InstanceDoesNotSatisfyRequirement.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static InstanceDoesNotSatisfyRequirement.Match newMutableMatch(final Requirement pReq, final ApplicationInstance pApp) { + return new Mutable(pReq, pApp); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public static InstanceDoesNotSatisfyRequirement.Match newMatch(final Requirement pReq, final ApplicationInstance pApp) { + return new Immutable(pReq, pApp); + } + + private static final class Mutable extends InstanceDoesNotSatisfyRequirement.Match { + Mutable(final Requirement pReq, final ApplicationInstance pApp) { + super(pReq, pApp); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends InstanceDoesNotSatisfyRequirement.Match { + Immutable(final Requirement pReq, final ApplicationInstance pApp) { + super(pReq, pApp); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(severity = "error", key = {Req, App},
+   * 	message = "Requirement must be satisfied by the required application type.")
+   * pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) {
+   * 	Requirement.instances(Req, App);
+   * 	neg find satisfyingInstance(Req, App);
+   * }
+   * 
+ * + * @see Match + * @see InstanceDoesNotSatisfyRequirement + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static InstanceDoesNotSatisfyRequirement.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static InstanceDoesNotSatisfyRequirement.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_REQ = 0; + + private static final int POSITION_APP = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(InstanceDoesNotSatisfyRequirement.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Requirement pReq, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pReq, pApp}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Requirement pReq, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pReq, pApp}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Requirement pReq, final ApplicationInstance pApp) { + return rawGetOneArbitraryMatch(new Object[]{pReq, pApp}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Requirement pReq, final ApplicationInstance pApp) { + return rawHasMatch(new Object[]{pReq, pApp}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Requirement pReq, final ApplicationInstance pApp) { + return rawCountMatches(new Object[]{pReq, pApp}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Requirement pReq, final ApplicationInstance pApp, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pReq, pApp}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public InstanceDoesNotSatisfyRequirement.Match newMatch(final Requirement pReq, final ApplicationInstance pApp) { + return InstanceDoesNotSatisfyRequirement.Match.newMatch(pReq, pApp); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfReq(final Object[] parameters) { + return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfReq(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq(final ApplicationInstance pApp) { + return rawStreamAllValuesOfReq(new Object[]{null, pApp}); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfReq(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq(final ApplicationInstance pApp) { + return rawStreamAllValuesOfReq(new Object[]{null, pApp}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final Requirement pReq) { + return rawStreamAllValuesOfApp(new Object[]{pReq, null}); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final Requirement pReq) { + return rawStreamAllValuesOfApp(new Object[]{pReq, null}).collect(Collectors.toSet()); + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Match tupleToMatch(final Tuple t) { + try { + return InstanceDoesNotSatisfyRequirement.Match.newMatch((Requirement) t.get(POSITION_REQ), (ApplicationInstance) t.get(POSITION_APP)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Match arrayToMatch(final Object[] match) { + try { + return InstanceDoesNotSatisfyRequirement.Match.newMatch((Requirement) match[POSITION_REQ], (ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Match arrayToMatchMutable(final Object[] match) { + try { + return InstanceDoesNotSatisfyRequirement.Match.newMutableMatch((Requirement) match[POSITION_REQ], (ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return InstanceDoesNotSatisfyRequirement.instance(); + } + } + + private InstanceDoesNotSatisfyRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static InstanceDoesNotSatisfyRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Matcher instantiate(final ViatraQueryEngine engine) { + return InstanceDoesNotSatisfyRequirement.Matcher.on(engine); + } + + @Override + public InstanceDoesNotSatisfyRequirement.Matcher instantiate() { + return InstanceDoesNotSatisfyRequirement.Matcher.create(); + } + + @Override + public InstanceDoesNotSatisfyRequirement.Match newEmptyMatch() { + return InstanceDoesNotSatisfyRequirement.Match.newEmptyMatch(); + } + + @Override + public InstanceDoesNotSatisfyRequirement.Match newMatch(final Object... parameters) { + return InstanceDoesNotSatisfyRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement (visibility: PUBLIC, simpleName: InstanceDoesNotSatisfyRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement (visibility: PUBLIC, simpleName: InstanceDoesNotSatisfyRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final InstanceDoesNotSatisfyRequirement INSTANCE = new InstanceDoesNotSatisfyRequirement(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final InstanceDoesNotSatisfyRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req, parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req","App"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_App = body.getOrCreateVariableByName("App"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req), + new ExportedParameter(body, var_App, parameter_App) + )); + // Requirement.instances(Req, App) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_0_, var_App); + // neg find satisfyingInstance(Req, App) + new NegativePatternCall(body, Tuples.flatTupleOf(var_Req, var_App), SatisfyingInstance.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Req"), + new ParameterReference("App") + })); + annotation.addAttribute("message", "Requirement must be satisfied by the required application type."); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java new file mode 100644 index 00000000..41615598 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java @@ -0,0 +1,579 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(severity = "error", key = {Host},
+ *         	message = "Insufficient HDD available on host.")
+ *         pattern notEnoughAvailableHdd(Host : HostInstance) {
+ *         	find availableHdd(Host, Hdd);
+ *         	check(Hdd {@literal <} 0);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class NotEnoughAvailableHdd extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private static List parameterNames = makeImmutableList("Host"); + + private Match(final HostInstance pHost) { + this.fHost = pHost; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"; + } + + @Override + public List parameterNames() { + return NotEnoughAvailableHdd.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost}; + } + + @Override + public NotEnoughAvailableHdd.Match toImmutable() { + return isMutable() ? newMatch(fHost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof NotEnoughAvailableHdd.Match)) { + NotEnoughAvailableHdd.Match other = (NotEnoughAvailableHdd.Match) obj; + return Objects.equals(fHost, other.fHost); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public NotEnoughAvailableHdd specification() { + return NotEnoughAvailableHdd.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static NotEnoughAvailableHdd.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static NotEnoughAvailableHdd.Match newMutableMatch(final HostInstance pHost) { + return new Mutable(pHost); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public static NotEnoughAvailableHdd.Match newMatch(final HostInstance pHost) { + return new Immutable(pHost); + } + + private static final class Mutable extends NotEnoughAvailableHdd.Match { + Mutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends NotEnoughAvailableHdd.Match { + Immutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(severity = "error", key = {Host},
+   * 	message = "Insufficient HDD available on host.")
+   * pattern notEnoughAvailableHdd(Host : HostInstance) {
+   * 	find availableHdd(Host, Hdd);
+   * 	check(Hdd {@literal <} 0);
+   * }
+   * 
+ * + * @see Match + * @see NotEnoughAvailableHdd + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static NotEnoughAvailableHdd.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static NotEnoughAvailableHdd.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableHdd.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost) { + return rawGetOneArbitraryMatch(new Object[]{pHost}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost) { + return rawHasMatch(new Object[]{pHost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost) { + return rawCountMatches(new Object[]{pHost}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public NotEnoughAvailableHdd.Match newMatch(final HostInstance pHost) { + return NotEnoughAvailableHdd.Match.newMatch(pHost); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + @Override + protected NotEnoughAvailableHdd.Match tupleToMatch(final Tuple t) { + try { + return NotEnoughAvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableHdd.Match arrayToMatch(final Object[] match) { + try { + return NotEnoughAvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableHdd.Match arrayToMatchMutable(final Object[] match) { + try { + return NotEnoughAvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return NotEnoughAvailableHdd.instance(); + } + } + + private NotEnoughAvailableHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static NotEnoughAvailableHdd instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected NotEnoughAvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) { + return NotEnoughAvailableHdd.Matcher.on(engine); + } + + @Override + public NotEnoughAvailableHdd.Matcher instantiate() { + return NotEnoughAvailableHdd.Matcher.create(); + } + + @Override + public NotEnoughAvailableHdd.Match newEmptyMatch() { + return NotEnoughAvailableHdd.Match.newEmptyMatch(); + } + + @Override + public NotEnoughAvailableHdd.Match newMatch(final Object... parameters) { + return NotEnoughAvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd (visibility: PUBLIC, simpleName: NotEnoughAvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd (visibility: PUBLIC, simpleName: NotEnoughAvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final NotEnoughAvailableHdd INSTANCE = new NotEnoughAvailableHdd(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final NotEnoughAvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host) + )); + // find availableHdd(Host, Hdd) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Hdd), AvailableHdd.instance().getInternalQueryRepresentation()); + // check(Hdd < 0) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern notEnoughAvailableHdd"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Hdd");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Hdd = (Integer) provider.getValue("Hdd"); + return evaluateExpression_1_1(Hdd); + } + }, null); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Host") + })); + annotation.addAttribute("message", "Insufficient HDD available on host."); + addAnnotation(annotation); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer Hdd) { + return ((Hdd).intValue() < 0); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java new file mode 100644 index 00000000..4803ec3a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java @@ -0,0 +1,579 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(severity = "error", key = {Host},
+ *         	message = "Insufficient memory available on host.")
+ *         pattern notEnoughAvailableMemory(Host : HostInstance) {
+ *         	find availableMemory(Host, Memory);
+ *         	check(Memory {@literal <} 0);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class NotEnoughAvailableMemory extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private static List parameterNames = makeImmutableList("Host"); + + private Match(final HostInstance pHost) { + this.fHost = pHost; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"; + } + + @Override + public List parameterNames() { + return NotEnoughAvailableMemory.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost}; + } + + @Override + public NotEnoughAvailableMemory.Match toImmutable() { + return isMutable() ? newMatch(fHost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof NotEnoughAvailableMemory.Match)) { + NotEnoughAvailableMemory.Match other = (NotEnoughAvailableMemory.Match) obj; + return Objects.equals(fHost, other.fHost); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public NotEnoughAvailableMemory specification() { + return NotEnoughAvailableMemory.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static NotEnoughAvailableMemory.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static NotEnoughAvailableMemory.Match newMutableMatch(final HostInstance pHost) { + return new Mutable(pHost); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public static NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) { + return new Immutable(pHost); + } + + private static final class Mutable extends NotEnoughAvailableMemory.Match { + Mutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends NotEnoughAvailableMemory.Match { + Immutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(severity = "error", key = {Host},
+   * 	message = "Insufficient memory available on host.")
+   * pattern notEnoughAvailableMemory(Host : HostInstance) {
+   * 	find availableMemory(Host, Memory);
+   * 	check(Memory {@literal <} 0);
+   * }
+   * 
+ * + * @see Match + * @see NotEnoughAvailableMemory + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static NotEnoughAvailableMemory.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static NotEnoughAvailableMemory.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableMemory.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost) { + return rawGetOneArbitraryMatch(new Object[]{pHost}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost) { + return rawHasMatch(new Object[]{pHost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost) { + return rawCountMatches(new Object[]{pHost}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) { + return NotEnoughAvailableMemory.Match.newMatch(pHost); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + @Override + protected NotEnoughAvailableMemory.Match tupleToMatch(final Tuple t) { + try { + return NotEnoughAvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableMemory.Match arrayToMatch(final Object[] match) { + try { + return NotEnoughAvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableMemory.Match arrayToMatchMutable(final Object[] match) { + try { + return NotEnoughAvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return NotEnoughAvailableMemory.instance(); + } + } + + private NotEnoughAvailableMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static NotEnoughAvailableMemory instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected NotEnoughAvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) { + return NotEnoughAvailableMemory.Matcher.on(engine); + } + + @Override + public NotEnoughAvailableMemory.Matcher instantiate() { + return NotEnoughAvailableMemory.Matcher.create(); + } + + @Override + public NotEnoughAvailableMemory.Match newEmptyMatch() { + return NotEnoughAvailableMemory.Match.newEmptyMatch(); + } + + @Override + public NotEnoughAvailableMemory.Match newMatch(final Object... parameters) { + return NotEnoughAvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory (visibility: PUBLIC, simpleName: NotEnoughAvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory (visibility: PUBLIC, simpleName: NotEnoughAvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final NotEnoughAvailableMemory INSTANCE = new NotEnoughAvailableMemory(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final NotEnoughAvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host) + )); + // find availableMemory(Host, Memory) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Memory), AvailableMemory.instance().getInternalQueryRepresentation()); + // check(Memory < 0) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern notEnoughAvailableMemory"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Memory");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Memory = (Integer) provider.getValue("Memory"); + return evaluateExpression_1_1(Memory); + } + }, null); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Host") + })); + annotation.addAttribute("message", "Insufficient memory available on host."); + addAnnotation(annotation); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer Memory) { + return ((Memory).intValue() < 0); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java new file mode 100644 index 00000000..04066c50 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java @@ -0,0 +1,597 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}Constraint(severity = "error", key = {Req},
+ *         	message = "Requirement is not satisfied by enough application instances.")
+ *         pattern requirementNotSatisfied(Req : Requirement) {
+ *         	Instances == count find satisfyingInstance(Req, _);
+ *         	Requirement.count(Req, RequiredCount);
+ *         	check(Instances {@literal <} RequiredCount);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class RequirementNotSatisfied extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Requirement fReq; + + private static List parameterNames = makeImmutableList("Req"); + + private Match(final Requirement pReq) { + this.fReq = pReq; + } + + @Override + public Object get(final String parameterName) { + if ("Req".equals(parameterName)) return this.fReq; + return null; + } + + public Requirement getReq() { + return this.fReq; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Req".equals(parameterName) ) { + this.fReq = (Requirement) newValue; + return true; + } + return false; + } + + public void setReq(final Requirement pReq) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fReq = pReq; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"; + } + + @Override + public List parameterNames() { + return RequirementNotSatisfied.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fReq}; + } + + @Override + public RequirementNotSatisfied.Match toImmutable() { + return isMutable() ? newMatch(fReq) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Req\"=" + prettyPrintValue(fReq)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fReq); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof RequirementNotSatisfied.Match)) { + RequirementNotSatisfied.Match other = (RequirementNotSatisfied.Match) obj; + return Objects.equals(fReq, other.fReq); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public RequirementNotSatisfied specification() { + return RequirementNotSatisfied.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static RequirementNotSatisfied.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static RequirementNotSatisfied.Match newMutableMatch(final Requirement pReq) { + return new Mutable(pReq); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the (partial) match object. + * + */ + public static RequirementNotSatisfied.Match newMatch(final Requirement pReq) { + return new Immutable(pReq); + } + + private static final class Mutable extends RequirementNotSatisfied.Match { + Mutable(final Requirement pReq) { + super(pReq); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends RequirementNotSatisfied.Match { + Immutable(final Requirement pReq) { + super(pReq); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}Constraint(severity = "error", key = {Req},
+   * 	message = "Requirement is not satisfied by enough application instances.")
+   * pattern requirementNotSatisfied(Req : Requirement) {
+   * 	Instances == count find satisfyingInstance(Req, _);
+   * 	Requirement.count(Req, RequiredCount);
+   * 	check(Instances {@literal <} RequiredCount);
+   * }
+   * 
+ * + * @see Match + * @see RequirementNotSatisfied + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static RequirementNotSatisfied.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static RequirementNotSatisfied.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_REQ = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RequirementNotSatisfied.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Requirement pReq) { + return rawStreamAllMatches(new Object[]{pReq}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Requirement pReq) { + return rawStreamAllMatches(new Object[]{pReq}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Requirement pReq) { + return rawGetOneArbitraryMatch(new Object[]{pReq}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Requirement pReq) { + return rawHasMatch(new Object[]{pReq}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Requirement pReq) { + return rawCountMatches(new Object[]{pReq}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Requirement pReq, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pReq}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the (partial) match object. + * + */ + public RequirementNotSatisfied.Match newMatch(final Requirement pReq) { + return RequirementNotSatisfied.Match.newMatch(pReq); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfReq(final Object[] parameters) { + return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()); + } + + @Override + protected RequirementNotSatisfied.Match tupleToMatch(final Tuple t) { + try { + return RequirementNotSatisfied.Match.newMatch((Requirement) t.get(POSITION_REQ)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected RequirementNotSatisfied.Match arrayToMatch(final Object[] match) { + try { + return RequirementNotSatisfied.Match.newMatch((Requirement) match[POSITION_REQ]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected RequirementNotSatisfied.Match arrayToMatchMutable(final Object[] match) { + try { + return RequirementNotSatisfied.Match.newMutableMatch((Requirement) match[POSITION_REQ]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return RequirementNotSatisfied.instance(); + } + } + + private RequirementNotSatisfied() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static RequirementNotSatisfied instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected RequirementNotSatisfied.Matcher instantiate(final ViatraQueryEngine engine) { + return RequirementNotSatisfied.Matcher.on(engine); + } + + @Override + public RequirementNotSatisfied.Matcher instantiate() { + return RequirementNotSatisfied.Matcher.create(); + } + + @Override + public RequirementNotSatisfied.Match newEmptyMatch() { + return RequirementNotSatisfied.Match.newEmptyMatch(); + } + + @Override + public RequirementNotSatisfied.Match newMatch(final Object... parameters) { + return RequirementNotSatisfied.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied (visibility: PUBLIC, simpleName: RequirementNotSatisfied, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied (visibility: PUBLIC, simpleName: RequirementNotSatisfied, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final RequirementNotSatisfied INSTANCE = new RequirementNotSatisfied(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final RequirementNotSatisfied.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_Instances = body.getOrCreateVariableByName("Instances"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_RequiredCount = body.getOrCreateVariableByName("RequiredCount"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req) + )); + // Instances == count find satisfyingInstance(Req, _) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var_Req, var___0_), SatisfyingInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); + new Equality(body, var_Instances, var__virtual_0_); + // Requirement.count(Req, RequiredCount) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "count"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_RequiredCount); + // check(Instances < RequiredCount) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern requirementNotSatisfied"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Instances", "RequiredCount");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Instances = (Integer) provider.getValue("Instances"); + Integer RequiredCount = (Integer) provider.getValue("RequiredCount"); + return evaluateExpression_1_1(Instances, RequiredCount); + } + }, null); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Req") + })); + annotation.addAttribute("message", "Requirement is not satisfied by enough application instances."); + addAnnotation(annotation); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer Instances, final Integer RequiredCount) { + boolean _lessThan = (Instances.compareTo(RequiredCount) < 0); + return _lessThan; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java new file mode 100644 index 00000000..f91853de --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java @@ -0,0 +1,706 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}QueryBasedFeature(feature = "totalHdd")
+ *         pattern totalHdd(Host : HostInstance, Hdd : EInt) {
+ *         	HostInstance.type.defaultHdd(Host, Hdd);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TotalHdd extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private Integer fHdd; + + private static List parameterNames = makeImmutableList("Host", "Hdd"); + + private Match(final HostInstance pHost, final Integer pHdd) { + this.fHost = pHost; + this.fHdd = pHdd; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Hdd".equals(parameterName)) return this.fHdd; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getHdd() { + return this.fHdd; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Hdd".equals(parameterName) ) { + this.fHdd = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setHdd(final Integer pHdd) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHdd = pHdd; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; + } + + @Override + public List parameterNames() { + return TotalHdd.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fHdd}; + } + + @Override + public TotalHdd.Match toImmutable() { + return isMutable() ? newMatch(fHost, fHdd) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Hdd\"=" + prettyPrintValue(fHdd)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fHdd); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TotalHdd.Match)) { + TotalHdd.Match other = (TotalHdd.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TotalHdd specification() { + return TotalHdd.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TotalHdd.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TotalHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) { + return new Mutable(pHost, pHdd); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public static TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return new Immutable(pHost, pHdd); + } + + private static final class Mutable extends TotalHdd.Match { + Mutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TotalHdd.Match { + Immutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}QueryBasedFeature(feature = "totalHdd")
+   * pattern totalHdd(Host : HostInstance, Hdd : EInt) {
+   * 	HostInstance.type.defaultHdd(Host, Hdd);
+   * }
+   * 
+ * + * @see Match + * @see TotalHdd + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TotalHdd.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TotalHdd.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_HDD = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalHdd.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pHdd) { + return rawHasMatch(new Object[]{pHost, pHdd}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pHdd) { + return rawCountMatches(new Object[]{pHost, pHdd}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final Integer pHdd, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return TotalHdd.Match.newMatch(pHost, pHdd); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHdd(final Object[] parameters) { + return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected TotalHdd.Match tupleToMatch(final Tuple t) { + try { + return TotalHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TotalHdd.Match arrayToMatch(final Object[] match) { + try { + return TotalHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TotalHdd.Match arrayToMatchMutable(final Object[] match) { + try { + return TotalHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TotalHdd.instance(); + } + } + + private TotalHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TotalHdd instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TotalHdd.Matcher instantiate(final ViatraQueryEngine engine) { + return TotalHdd.Matcher.on(engine); + } + + @Override + public TotalHdd.Matcher instantiate() { + return TotalHdd.Matcher.create(); + } + + @Override + public TotalHdd.Match newEmptyMatch() { + return TotalHdd.Match.newEmptyMatch(); + } + + @Override + public TotalHdd.Match newMatch(final Object... parameters) { + return TotalHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TotalHdd INSTANCE = new TotalHdd(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TotalHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Hdd"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // HostInstance.type.defaultHdd(Host, Hdd) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultHdd"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Hdd); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "totalHdd"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java new file mode 100644 index 00000000..e8a11e36 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java @@ -0,0 +1,706 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         {@literal @}QueryBasedFeature(feature = "totalMemory")
+ *         pattern totalMemory(Host : HostInstance, Memory : EInt) {
+ *         	HostInstance.type.defaultMemory(Host, Memory);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TotalMemory extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private HostInstance fHost; + + private Integer fMemory; + + private static List parameterNames = makeImmutableList("Host", "Memory"); + + private Match(final HostInstance pHost, final Integer pMemory) { + this.fHost = pHost; + this.fMemory = pMemory; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Memory".equals(parameterName)) return this.fMemory; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getMemory() { + return this.fMemory; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Memory".equals(parameterName) ) { + this.fMemory = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setMemory(final Integer pMemory) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fMemory = pMemory; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; + } + + @Override + public List parameterNames() { + return TotalMemory.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fMemory}; + } + + @Override + public TotalMemory.Match toImmutable() { + return isMutable() ? newMatch(fHost, fMemory) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Memory\"=" + prettyPrintValue(fMemory)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fMemory); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TotalMemory.Match)) { + TotalMemory.Match other = (TotalMemory.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TotalMemory specification() { + return TotalMemory.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TotalMemory.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TotalMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) { + return new Mutable(pHost, pMemory); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public static TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return new Immutable(pHost, pMemory); + } + + private static final class Mutable extends TotalMemory.Match { + Mutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TotalMemory.Match { + Immutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * {@literal @}QueryBasedFeature(feature = "totalMemory")
+   * pattern totalMemory(Host : HostInstance, Memory : EInt) {
+   * 	HostInstance.type.defaultMemory(Host, Memory);
+   * }
+   * 
+ * + * @see Match + * @see TotalMemory + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TotalMemory.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TotalMemory.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_MEMORY = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalMemory.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pMemory) { + return rawHasMatch(new Object[]{pHost, pMemory}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pMemory) { + return rawCountMatches(new Object[]{pHost, pMemory}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final HostInstance pHost, final Integer pMemory, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return TotalMemory.Match.newMatch(pHost, pMemory); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfMemory(final Object[] parameters) { + return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected TotalMemory.Match tupleToMatch(final Tuple t) { + try { + return TotalMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TotalMemory.Match arrayToMatch(final Object[] match) { + try { + return TotalMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TotalMemory.Match arrayToMatchMutable(final Object[] match) { + try { + return TotalMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TotalMemory.instance(); + } + } + + private TotalMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TotalMemory instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TotalMemory.Matcher instantiate(final ViatraQueryEngine engine) { + return TotalMemory.Matcher.on(engine); + } + + @Override + public TotalMemory.Matcher instantiate() { + return TotalMemory.Matcher.create(); + } + + @Override + public TotalMemory.Match newEmptyMatch() { + return TotalMemory.Match.newEmptyMatch(); + } + + @Override + public TotalMemory.Match newMatch(final Object... parameters) { + return TotalMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TotalMemory INSTANCE = new TotalMemory(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TotalMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Memory"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // HostInstance.type.defaultMemory(Host, Memory) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultMemory"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Memory); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "totalMemory"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore new file mode 100644 index 00000000..2f593811 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore @@ -0,0 +1,11 @@ +/.CpsQueriesAll.java._trace +/.ResourceRequirement.java._trace +/.MemoryRequirement.java._trace +/.HddRequirement.java._trace +/.AllocationWithoutResourceRequirement.java._trace +/.RequiredType.java._trace +/.SatisfyingInstance.java._trace +/.FreeMemoryPercentage.java._trace +/.FreeHddPercentage.java._trace +/.ApplicationInstance.java._trace +/.HostInstanceCost.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java new file mode 100644 index 00000000..5f6d161d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java @@ -0,0 +1,105 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; + +/** + * A pattern group formed of all patterns defined in CpsQueries.vql. + * + *

A private group that includes private patterns as well. Only intended use case is for pattern testing. + * + *

From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns:

    + *
  • cpsApplications
  • + *
  • cpsHosts
  • + *
  • totalMemory
  • + *
  • totalHdd
  • + *
  • availableMemory
  • + *
  • memoryRequirement
  • + *
  • availableHdd
  • + *
  • hddRequirement
  • + *
  • resourceRequirement
  • + *
  • allocationWithoutResourceRequirement
  • + *
  • notEnoughAvailableMemory
  • + *
  • notEnoughAvailableHdd
  • + *
  • instanceDoesNotSatisfyRequirement
  • + *
  • satisfyingInstance
  • + *
  • requirementNotSatisfied
  • + *
  • averageFreeMemoryMetric
  • + *
  • freeMemoryPercentage
  • + *
  • averageFreeHddMetric
  • + *
  • freeHddPercentage
  • + *
  • costMetric
  • + *
  • cpsCost
  • + *
  • hostInstanceCost
  • + *
+ * + * @see IQueryGroup + * + */ +@SuppressWarnings("all") +public final class CpsQueriesAll extends BaseGeneratedPatternGroup { + /** + * Access the pattern group. + * + * @return the singleton instance of the group + * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications + * + */ + public static CpsQueriesAll instance() { + if (INSTANCE == null) { + INSTANCE = new CpsQueriesAll(); + } + return INSTANCE; + } + + private static CpsQueriesAll INSTANCE; + + private CpsQueriesAll() { + querySpecifications.add(CpsApplications.instance()); + querySpecifications.add(CpsHosts.instance()); + querySpecifications.add(TotalMemory.instance()); + querySpecifications.add(TotalHdd.instance()); + querySpecifications.add(AvailableMemory.instance()); + querySpecifications.add(MemoryRequirement.instance()); + querySpecifications.add(AvailableHdd.instance()); + querySpecifications.add(HddRequirement.instance()); + querySpecifications.add(ResourceRequirement.instance()); + querySpecifications.add(AllocationWithoutResourceRequirement.instance()); + querySpecifications.add(NotEnoughAvailableMemory.instance()); + querySpecifications.add(NotEnoughAvailableHdd.instance()); + querySpecifications.add(InstanceDoesNotSatisfyRequirement.instance()); + querySpecifications.add(SatisfyingInstance.instance()); + querySpecifications.add(RequirementNotSatisfied.instance()); + querySpecifications.add(AverageFreeMemoryMetric.instance()); + querySpecifications.add(FreeMemoryPercentage.instance()); + querySpecifications.add(AverageFreeHddMetric.instance()); + querySpecifications.add(FreeHddPercentage.instance()); + querySpecifications.add(CostMetric.instance()); + querySpecifications.add(CpsCost.instance()); + querySpecifications.add(HostInstanceCost.instance()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java new file mode 100644 index 00000000..366677b5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java @@ -0,0 +1,172 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern freeHddPercentage(Host : HostInstance, Free : java Double) {
+ *         	find totalHdd(Host, Total);
+ *         	find availableHdd(Host, Available);
+ *         	Free == eval((Available as double) / Total);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class FreeHddPercentage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private FreeHddPercentage() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static FreeHddPercentage instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage (visibility: PUBLIC, simpleName: FreeHddPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage (visibility: PUBLIC, simpleName: FreeHddPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final FreeHddPercentage INSTANCE = new FreeHddPercentage(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final FreeHddPercentage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Free = new PParameter("Free", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Free); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.freeHddPercentage"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Free"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Free = body.getOrCreateVariableByName("Free"); + PVariable var_Total = body.getOrCreateVariableByName("Total"); + PVariable var_Available = body.getOrCreateVariableByName("Available"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Free), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Free, parameter_Free) + )); + // find totalHdd(Host, Total) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Total), TotalHdd.instance().getInternalQueryRepresentation()); + // find availableHdd(Host, Available) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Available), AvailableHdd.instance().getInternalQueryRepresentation()); + // Free == eval((Available as double) / Total) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern freeHddPercentage"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Available", "Total");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Available = (Integer) provider.getValue("Available"); + Integer Total = (Integer) provider.getValue("Total"); + return evaluateExpression_1_1(Available, Total); + } + }, var__virtual_0_ ); + new Equality(body, var_Free, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Integer Available, final Integer Total) { + return (((double) (Available).intValue()) / (Total).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java new file mode 100644 index 00000000..bd151ea6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java @@ -0,0 +1,172 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern freeMemoryPercentage(Host : HostInstance, Free : java Double) {
+ *         	find totalMemory(Host, Total);
+ *         	find availableMemory(Host, Available);
+ *         	Free == eval((Available as double) / Total);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class FreeMemoryPercentage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private FreeMemoryPercentage() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static FreeMemoryPercentage instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage (visibility: PUBLIC, simpleName: FreeMemoryPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage (visibility: PUBLIC, simpleName: FreeMemoryPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final FreeMemoryPercentage INSTANCE = new FreeMemoryPercentage(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final FreeMemoryPercentage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Free = new PParameter("Free", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Free); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.freeMemoryPercentage"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Free"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Free = body.getOrCreateVariableByName("Free"); + PVariable var_Total = body.getOrCreateVariableByName("Total"); + PVariable var_Available = body.getOrCreateVariableByName("Available"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Free), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Free, parameter_Free) + )); + // find totalMemory(Host, Total) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Total), TotalMemory.instance().getInternalQueryRepresentation()); + // find availableMemory(Host, Available) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Available), AvailableMemory.instance().getInternalQueryRepresentation()); + // Free == eval((Available as double) / Total) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern freeMemoryPercentage"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Available", "Total");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Available = (Integer) provider.getValue("Available"); + Integer Total = (Integer) provider.getValue("Total"); + return evaluateExpression_1_1(Available, Total); + } + }, var__virtual_0_ ); + new Equality(body, var_Free, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Integer Available, final Integer Total) { + return (((double) (Available).intValue()) / (Total).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java new file mode 100644 index 00000000..fbe7a46b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java @@ -0,0 +1,151 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern hddRequirement(Host : HostInstance, App : ApplicationInstance, Hdd : EInt) {
+ *         	find resourceRequirement(Host, App, Req);
+ *         	ResourceRequirement.requiredHdd(Req, Hdd);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class HddRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private HddRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static HddRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement (visibility: PUBLIC, simpleName: HddRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement (visibility: PUBLIC, simpleName: HddRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final HddRequirement INSTANCE = new HddRequirement(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final HddRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.hddRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Hdd"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // find resourceRequirement(Host, App, Req) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var_Req), ResourceRequirement.instance().getInternalQueryRepresentation()); + // ResourceRequirement.requiredHdd(Req, Hdd) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_0_, var_Hdd); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java new file mode 100644 index 00000000..767ca342 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java @@ -0,0 +1,153 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, Cost : EInt) {
+ *         	find cpsHosts(Cps, Host);
+ *         	HostInstance.type.cost(Host, Cost);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class HostInstanceCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private HostInstanceCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static HostInstanceCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost (visibility: PUBLIC, simpleName: HostInstanceCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost (visibility: PUBLIC, simpleName: HostInstanceCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final HostInstanceCost INSTANCE = new HostInstanceCost(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final HostInstanceCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_Host, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.hostInstanceCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","Host","Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cost), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // find cpsHosts(Cps, Host) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Cps, var_Host), CpsHosts.instance().getInternalQueryRepresentation()); + // HostInstance.type.cost(Host, Cost) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "cost"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Cost); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java new file mode 100644 index 00000000..0a24d105 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java @@ -0,0 +1,151 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern memoryRequirement(Host : HostInstance, App : ApplicationInstance, Memory : EInt) {
+ *         	find resourceRequirement(Host, App, Req);
+ *         	ResourceRequirement.requiredMemory(Req, Memory);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class MemoryRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private MemoryRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static MemoryRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement (visibility: PUBLIC, simpleName: MemoryRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement (visibility: PUBLIC, simpleName: MemoryRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final MemoryRequirement INSTANCE = new MemoryRequirement(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final MemoryRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.memoryRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Memory"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // find resourceRequirement(Host, App, Req) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var_Req), ResourceRequirement.instance().getInternalQueryRepresentation()); + // ResourceRequirement.requiredMemory(Req, Memory) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_0_, var_Memory); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java new file mode 100644 index 00000000..8c5bdefe --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java @@ -0,0 +1,168 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
+ *         	ApplicationInstance.allocatedTo(App, Host);
+ *         	ApplicationInstance.type.requirements(App, Req);
+ *         	HostInstance.type(Host, HostType);
+ *         	ResourceRequirement.hostType(Req, HostType);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private ResourceRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ResourceRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ResourceRequirement INSTANCE = new ResourceRequirement(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ResourceRequirement")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Req"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_HostType = body.getOrCreateVariableByName("HostType"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Req, parameter_Req) + )); + // ApplicationInstance.allocatedTo(App, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var_Host); + // ApplicationInstance.type.requirements(App, Req) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + new Equality(body, var__virtual_2_, var_Req); + // HostInstance.type(Host, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_3_, var_HostType); + // ResourceRequirement.hostType(Req, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_4_, var_HostType); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java new file mode 100644 index 00000000..4285101c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java @@ -0,0 +1,153 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

Original source: + *

+ *         private pattern satisfyingInstance(Req : Requirement, App : ApplicationInstance) {
+ *         	Requirement.instances(Req, App);
+ *         	Requirement.type(Req, Type);
+ *         	ApplicationInstance.type(App, Type);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class SatisfyingInstance extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private SatisfyingInstance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static SatisfyingInstance instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance (visibility: PUBLIC, simpleName: SatisfyingInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance (visibility: PUBLIC, simpleName: SatisfyingInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final SatisfyingInstance INSTANCE = new SatisfyingInstance(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final SatisfyingInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req, parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.satisfyingInstance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req","App"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Type = body.getOrCreateVariableByName("Type"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req), + new ExportedParameter(body, var_App, parameter_App) + )); + // Requirement.instances(Req, App) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_0_, var_App); + // Requirement.type(Req, Type) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + new Equality(body, var__virtual_1_, var_Type); + // ApplicationInstance.type(App, Type) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + new Equality(body, var__virtual_2_, var_Type); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql new file mode 100644 index 00000000..7f7cc5a4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql @@ -0,0 +1,132 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries + +import "http://www.eclipse.org/emf/2002/Ecore" +import "http://www.example.org/cps" + +@QueryBasedFeature(feature = "applications") +pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) { + CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance); +} + +@QueryBasedFeature(feature = "hosts") +pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { + CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance); +} + +@QueryBasedFeature(feature = "totalMemory") +pattern totalMemory(Host : HostInstance, Memory : EInt) { + HostInstance.type.defaultMemory(Host, Memory); +} + +@QueryBasedFeature(feature = "totalHdd") +pattern totalHdd(Host : HostInstance, Hdd : EInt) { + HostInstance.type.defaultHdd(Host, Hdd); +} + +@QueryBasedFeature(feature = "availableMemory") +pattern availableMemory(Host : HostInstance, Memory : java Integer) { + find totalMemory(Host, TotalMemory); + RequiredMemory == sum find memoryRequirement(Host, _, #_); + Memory == eval(TotalMemory - RequiredMemory); +} + +private pattern memoryRequirement(Host : HostInstance, App : ApplicationInstance, Memory : EInt) { + find resourceRequirement(Host, App, Req); + ResourceRequirement.requiredMemory(Req, Memory); +} + +@QueryBasedFeature(feature = "availableHdd") +pattern availableHdd(Host : HostInstance, Hdd : java Integer) { + find totalHdd(Host, TotalHdd); + RequiredHdd == sum find hddRequirement(Host, _, #_); + Hdd == eval(TotalHdd - RequiredHdd); +} + +private pattern hddRequirement(Host : HostInstance, App : ApplicationInstance, Hdd : EInt) { + find resourceRequirement(Host, App, Req); + ResourceRequirement.requiredHdd(Req, Hdd); +} + +private pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { + ApplicationInstance.allocatedTo(App, Host); + ApplicationInstance.type.requirements(App, Req); + HostInstance.type(Host, HostType); + ResourceRequirement.hostType(Req, HostType); +} + +@Constraint(severity = "error", key = {Host, App}, + message = "Application instance must be allocated to a supported host type.") +pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) { + ApplicationInstance.allocatedTo(App, Host); + neg find resourceRequirement(Host, App, _); +} + +@Constraint(severity = "error", key = {Host}, + message = "Insufficient memory available on host.") +pattern notEnoughAvailableMemory(Host : HostInstance) { + find availableMemory(Host, Memory); + check(Memory < 0); +} + +@Constraint(severity = "error", key = {Host}, + message = "Insufficient HDD available on host.") +pattern notEnoughAvailableHdd(Host : HostInstance) { + find availableHdd(Host, Hdd); + check(Hdd < 0); +} + +@Constraint(severity = "error", key = {Req, App}, + message = "Requirement must be satisfied by the required application type.") +pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) { + Requirement.instances(Req, App); + neg find satisfyingInstance(Req, App); +} + +private pattern satisfyingInstance(Req : Requirement, App : ApplicationInstance) { + Requirement.instances(Req, App); + Requirement.type(Req, Type); + ApplicationInstance.type(App, Type); +} + +@Constraint(severity = "error", key = {Req}, + message = "Requirement is not satisfied by enough application instances.") +pattern requirementNotSatisfied(Req : Requirement) { + Instances == count find satisfyingInstance(Req, _); + Requirement.count(Req, RequiredCount); + check(Instances < RequiredCount); +} + +pattern averageFreeMemoryMetric(Average : java Double) { + Average == avg find freeMemoryPercentage(_, #_); +} + +private pattern freeMemoryPercentage(Host : HostInstance, Free : java Double) { + find totalMemory(Host, Total); + find availableMemory(Host, Available); + Free == eval((Available as double) / Total); +} + +pattern averageFreeHddMetric(Average : java Double) { + Average == avg find freeHddPercentage(_, #_); +} + +private pattern freeHddPercentage(Host : HostInstance, Free : java Double) { + find totalHdd(Host, Total); + find availableHdd(Host, Available); + Free == eval((Available as double) / Total); +} + +pattern costMetric(Cost : java Integer) { + Cost == sum find cpsCost(_, #_); +} + +pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) { + AppCount == count find cpsApplications(Cps, _); + HostCost == sum find hostInstanceCost(Cps, _, #_); + Cost == eval(5 * AppCount + HostCost); +} + +private pattern hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, Cost : EInt) { + find cpsHosts(Cps, Host); + HostInstance.type.cost(Host, Cost); +} -- cgit v1.2.3-70-g09d2