/*
 * <copyright>
 *
 * Copyright (c) 2009 Marc Schlienger (http://www.innoq.com/blog/mrs) and others.
 * All rights reserved.  
 * This program and the accompanying materials are made available under the terms of 
 * the Eclipse Public License v1.0 available at http://www.eclipse.org/legal/epl-v10.html
 *
 * </copyright>
 */
package com.csg.cs.log.ifms.generator.oaw;

import org.openarchitectureware.type.emf.EmfMetaModel;
import org.openarchitectureware.xpand2.XpandExecutionContextImpl;
import org.openarchitectureware.xpand2.XpandFacade;

public class XpandCaller {
	
	private final XpandFacade facade;
	private final StringOutput out;

	public XpandCaller( final String mmFile ){
		
		out = new StringOutput();
		
	    XpandExecutionContextImpl contextImpl = new XpandExecutionContextImpl(out, null);
	    
	    EmfMetaModel mm = new EmfMetaModel();
	    mm.setMetaModelFile(mmFile);
	    contextImpl.registerMetaModel(mm);
	    
	    facade = XpandFacade.create(contextImpl);
	}

	public void evaluate(String definitionName, Object targetObject,
			Object... params) {
		facade.evaluate(definitionName, targetObject, params);
	}
	
	public String getOutput(){
		return out.toString();
	}
}

