parserconfigurationfactory.java

来自「plugin for eclipse」· Java 代码 · 共 78 行

JAVA
78
字号
package isis.anp.config;

import isis.anp.common.ParserConfiguration;
import isis.commons.fs.SearchPath;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


public class ParserConfigurationFactory {
	/**
	 * Builds a parser configuration using preconfigured platform and
	 * sensorboard settings.
	 * 
	 * @param tosDir
	 *            the tos directory.
	 * @param platformProfile
	 *            the platform profile.
	 * @param sensorBoardProfile
	 *            the sensor board profile.
	 * @param userSearchPathList
	 *            the user search path list. It usually includes the application
	 *            directory and the lib directories.
	 * @param defines
	 *            defines and macros.
	 * @return the parser configuration.
	 * @throws IOException
	 *             if the configuration files cannot be read.
	 */
	public static ParserConfiguration create(String tosDir, String tmpDir,
			PlatformProfile platformProfile,
			SensorBoardProfile sensorBoardProfile,
			SearchPath userSearchPathList, Map defines) throws IOException {

		// Create a new parser configuration
		ParserConfiguration parserConfig = new ParserConfiguration();

		// set temp dir
		parserConfig.setTempDir(tmpDir);

		// set up search path
		SearchPath searchPathList;
		searchPathList = (SearchPath) userSearchPathList.clone();
		searchPathList.addAllWithPrefix(sensorBoardProfile.getSearchPathList(),
				tosDir + "/");
		searchPathList.addAllWithPrefix(platformProfile.getSearchPathList(),
				tosDir + "/");
		searchPathList
				.addAllWithPrefix(SearchPath
						.load("isis/anp/config/syspath/syspath.properties"),
						tosDir + "/");

		parserConfig.setSearchPath(searchPathList);

		// set cpp executable
		parserConfig.setCppExecutable(platformProfile.getCppExecutable());

		// set cpp options
		parserConfig.setCppOptions(platformProfile.getCppOptions());

		// add tos.h to nesc includes
		parserConfig.getNesCIncludes().add("tos.h");

		// set defines
		if(defines == null) {
			defines = new HashMap();
		}
		defines.put("NESC","110");
		parserConfig.setDefines(defines);

		return parserConfig;
	}

	private ParserConfigurationFactory() {
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?