blob: c2262714a574c4757d5b5a22ab252ef7bafbaebe [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Andras Balogh 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 Balogh - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.imports.vtml;
import java.util.Stack;
import org.eclipse.viatra2.core.IEntity;
import org.eclipse.viatra2.core.IModelManager;
import org.eclipse.viatra2.core.IModelSpace;
import org.eclipse.viatra2.core.IRelation;
import org.eclipse.viatra2.errors.VPMRuntimeException;
import org.eclipse.viatra2.logger.Logger;
/**
* @author babo
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class VTMLMetaModelHelper {
private static VTMLMetaModelHelper instance;
private static Logger log = null;
private IModelSpace modsp;
private IModelManager mm;
public IModelSpace getMSpace() { return modsp;}
Stack conts = new Stack();
public void addContainer(IEntity e)
{
conts.push(e);
}
public IEntity currentContainer()
{
return (IEntity)conts.peek();
}
public IEntity removeContainer()
{
return (IEntity)conts.pop();
}
public static VTMLMetaModelHelper getInstance() {
if (instance==null) instance = new VTMLMetaModelHelper();
if (instance.log==null) return null;
return instance;
}
private VTMLMetaModelHelper()
{
}
public static void init(Logger l, IModelSpace ms, ASTBuilder a) throws VPMRuntimeException
{
log = l;
getInstance().modsp = ms;
getInstance().mm = ms.getModelManager();
getInstance().ab=a;
getInstance().loadMetaModel();
}
private IEntity ent(String fqn)
{
IEntity ret=mm.getEntityByName(fqn);
if(ret==null)
throw new RuntimeException("invalid model");
return ret;
}
private IRelation rel(String fqn)
{
IRelation ret=mm.getRelationByName(fqn);
if(ret==null)
throw new RuntimeException("invalid model");
return ret;
}
public static void deleteInstance()
{
instance = null;
}
private void loadMetaModel() throws VPMRuntimeException
{
}
IEntity machine;
ASTBuilder ab;
public ASTBuilder getASTBuilder()
{
return ab;
}
}