blob: 28d5d9f4ff52cc88dfc215acfa69a6129b029f99 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.modelChecker.impl;
import org.eclipse.viatra2.core.IModelSpace;
import org.eclipse.viatra2.framework.IFramework;
import org.eclipse.viatra2.tags.ITagManager;
/**
* This class implements a model checker.
*
* @author Andras Schmidt
*
*/
public class ProblemManager
{
ProblemCounter pc;
ModelChecker mc;
IModelSpace ms;
ConsistencyListener cli;
ITagManager tm;
/**
* Initializes the problem manager. Builds the model for all problems.
*
* @param ms
*/
public void init(IFramework fw) {
try {
this.tm = fw.getTagManager();
this.ms = fw.getTopmodel();
// ms.getTransactionManager().beginTransaction();
mc = new ModelChecker();
if (fw.getProperties().getRuntimeProperty("Model checking", "On-the-fly model checking")!=null &&
fw.getProperties().getRuntimeProperty("Model checking", "On-the-fly model checking").equalsIgnoreCase("true"))
{
pc = new ProblemCounter(mc.checkAllModelElement(ms), this);
cli = new ConsistencyListener(pc);
ms.getNotificationManager().addAllListener(cli);
}
} finally {
// ms.getTransactionManager().commitTransaction();
}
}
public void fullCheck() {
if (pc==null)
{
pc = new ProblemCounter(mc.checkAllModelElement(ms), this);
}
else
{
pc.setProblems(mc.checkAllModelElement(ms));
}
}
public void deinit() {
if (cli!=null)
{
ms.getNotificationManager().removeAllListener(cli);
}
}
}