Ejemplo n.º 1
0
/**
 * Build a new processor plugin.
 * @param name				Name of the plugin (may be full-qualified C++ name with "::"
 * 							or canonical name with "/").
 * @param version			Version of the plugin.
 * @param plugger_version	Version for the plugger interface (OTAWA_PROC_VERSION).
 */
ProcessorPlugin::ProcessorPlugin(
	cstring name,
	const elm::Version& version,
	const elm::Version& plugger_version)
:	elm::system::Plugin(makeCanonical(name), plugger_version, OTAWA_PROC_NAME) {
	_plugin_version = version;
}
Ejemplo n.º 2
0
//////////////////////////////////////////
//     Standard Material Test Models
//////////////////////////////////////////
std::shared_ptr<TriangleMesh> loadMaterialTestModel( AssetLoader & loader )
{
    std::string modelBasePath = "models";
    //auto mesh = loader.load( modelBasePath + "/dacunni/material_test1.obj" );
    //auto mesh = loader.load( modelBasePath + "/dacunni/material_test1.stl" );
    auto mesh = loader.load( modelBasePath + "/tf3dm.com/soccerball/untitled.ply" );
    //auto mesh = loader.load( modelBasePath + "/uvsphere.ply" );
    //auto mesh = loader.loadMultiPartMerged( modelBasePath + "/test_objects/mori/testObj.obj" );
#if 0
    auto mesh = loader.loadMultiPartMerged( modelBasePath + "/test_objects/mitsuba/mitsuba.obj" );
#endif
#if 0
    mesh->makeCanonical();
#endif
#if 1
    mesh->accelerator = new TMOctreeAccelerator( *mesh );
    mesh->accelerator->build();
#endif
    return mesh;
}
Ejemplo n.º 3
0
/**
 * Find a plugin by its name. The looked directories are, in order,
 * "$PWD/.otawa/proc", "$HOME/.otawa/proc" or "$OTAWA_INSTALL_DIRECTORY/lib/otawa/proc".
 * The full path name of the processor class must be passed in the name, something
 * composed of "comp1::comp2::...::compn". First, a module whose path is
 * by replacing in processor name "::" by "/" is looked. If not found, the last component
 * of  the path is removed and the obtained path is looked again for module. This process
 * continue until the module is found or the path becomes empty resulting in a linkage failure.
 *
 * @param name	Full-qualified name of the processor.
 * @return		Built processor or null if the processor cannot be found.
 */
ProcessorPlugin *ProcessorPlugin::get(string name) {
	if(!initialized_paths)
		init();

	// get canonical name
	string cname = makeCanonical(name);

	// iterates on components
	while(true) {
		int pos = cname.lastIndexOf('/');
		ProcessorPlugin *plugin = (ProcessorPlugin *)plugger.plug(cname);
		if(plugin) {
			base.onError(level_info, _ << "plugged " << plugin->name() << " (" << plugin->path() << ")");
			return plugin;
		}
		if(pos < 0) {
			base.onError(level_error, _ << "cannot resolve " << name);
			return 0;
		}
		cname = cname.substring(0, pos);
	}
	return 0;
}
Ejemplo n.º 4
0
bool readArguments(int argc, const char * argv[])
{
	bool pastFiles = false;
	for (int i = 1; i < argc; ++i)
	{
		// read argument from list
		std::string argument = argv[i];
		// check what it is
		if (argument == "-a")
		{
			if (!commonHeaderFilePath.empty() || !utilitiesFilePath.empty())
			{
				std::cout << "Error: Option -a can not be combined with -h or -u!" << std::endl;
				return false;
			}
			else if (createBinary)
			{
				std::cout << "Error: Option -a can not be combined with -b!" << std::endl;
				return false;
			}
			else if (combineResults)
			{
				std::cout << "Error: Option -a can not be combined with -1!" << std::endl;
				return false;
			}
			appendFile = true;
			pastFiles = true;
		}
		else if (argument == "-1")
		{
			// -u must be used for this to work. check if specified
			for (int j = 1; j < argc; ++j)
			{
				// read argument from list
				std::string argument = argv[j];
				if (argument == "-u")
				{
					combineResults = true;
					pastFiles = true;
					break;
				}
			}
			if (!combineResults)
			{
				// -u not specified. complain to user.
				std::cout << "Error: Option -1 has to be combined with -u!" << std::endl;
				return false;
			}
		}
		else if (argument == "-b")
		{
			if (!commonHeaderFilePath.empty() || !utilitiesFilePath.empty())
			{
				std::cout << "Error: Option -b can not be combined with -h or -u!" << std::endl;
				return false;
			}
			else if (appendFile)
			{
				std::cout << "Error: Option -b can not be combined with -a!" << std::endl;
				return false;
			}
			else if (combineResults)
			{
				std::cout << "Warning: Creating binary archive. Option -1 ignored!" << std::endl;
				return false;
			}
			createBinary = true;
			pastFiles = true;
		}
		else if (argument == "-c")
		{
			useC = true;
			pastFiles = true;
		}
		else if (argument == "-s")
		{
			useRecursion = true;
			pastFiles = true;
		}
		else if (argument == "-v")
		{
			beVerbose = true;
			pastFiles = true;
		}
		else if (argument == "-h")
		{
			if (createBinary)
			{
				std::cout << "Error: Option -h can not be combined with -b!" << std::endl;
				return false;
			}
			else if (appendFile)
			{
				std::cout << "Error: Option -h can not be combined with -a!" << std::endl;
				return false;
			}
			// try getting next argument as header file name
			i++;
			if (i < argc && argv[i] != nullptr)
			{
				if (!makeCanonical(commonHeaderFilePath, FS_NAMESPACE::path(argv[i])))
				{
					return false;
				}
			}
			else
			{
				std::cout << "Error: Option -h specified, but no file name found!" << std::endl;
				return false;
			}
			pastFiles = true;
		}
		else if (argument == "-u")
		{
			if (createBinary)
			{
				std::cout << "Error: Option -u can not be combined with -b!" << std::endl;
				return false;
			}
			else if (appendFile)
			{
				std::cout << "Error: Option -u can not be combined with -a!" << std::endl;
				return false;
			}
			// try getting next argument as utility file name
			i++;
			if (i < argc && argv[i] != nullptr)
			{
				if (!makeCanonical(utilitiesFilePath, FS_NAMESPACE::path(argv[i])))
				{
					return false;
				}
			}
			else
			{
				std::cout << "Error: Option -u specified, but no file name found!" << std::endl;
				return false;
			}
			if (!utilitiesFilePath.empty() && commonHeaderFilePath.empty())
			{
				std::cout << "Warning: -u does not make much sense without -h..." << std::endl;
			}
			pastFiles = true;
		}
		// none of the options was matched until here...
		else if (!pastFiles)
		{
			// if no files/directories have been found yet this is probably a file/directory
			if (inFilePath.empty())
			{
				if (!makeCanonical(inFilePath, FS_NAMESPACE::path(argument)))
				{
					return false;
				}
			}
			else if (outFilePath.empty())
			{
				if (!makeCanonical(outFilePath, FS_NAMESPACE::path(argument)))
				{
					return false;
				}
				pastFiles = true;
			}
		}
		else
		{
			std::cout << "Error: Unknown argument \"" << argument << "\"!" << std::endl;
			return false;
		}
	}
	return true;
}