Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r950 - in trunk: Engine/Control StandAlone
- Date: Wed, 22 Feb 2006 00:16:05 -0700 (MST)
Author: abe
Date: Wed Feb 22 00:16:05 2006
New Revision: 950
Modified:
trunk/Engine/Control/RTRT.cc
trunk/StandAlone/manta.cc
Log:
Changed the default scene path to either use MANTA_SCENEPATH or be empty.
(Was anyone actually using this??) The old code had a tendency to append a ./
to everything.
M StandAlone/manta.cc
Modified registerComponent to allow for re-registering default components.
Modified scene reading code to throw exceptions if an error occurs when
loading a scene. Previously it looked for other libraries to attempt to load
and then output an error that it couldn't find the specified scene instead of
indicating there was a problem loading the shared code.
M Engine/Control/RTRT.cc
Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc (original)
+++ trunk/Engine/Control/RTRT.cc Wed Feb 22 00:16:05 2006
@@ -1172,7 +1172,7 @@
if((suffix == "mo") || (suffix == "so") || (suffix == "dylib") ||
(suffix == "dll")) {
// Do this twice - once silently and once printing errors
- newScene = readMOScene(name, args, false);
+ newScene = readMOScene(name, args, true);
// if(!newScene)
// readMOScene(name, args, true);
} else {
@@ -1229,46 +1229,44 @@
Scene* RTRT::readMOScene(const string& name, const vector<string>& args,
bool printErrors)
{
+ // Determine which directories to search for the scene library.
+ string fullname = name;
vector<string> dirs = split_string(scenePath, ':');
for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
- string fullname = *dir + "/"+name;
+
+ fullname = *dir + "/" + name;
+
+ // Check to see if the file exists.
struct stat statbuf;
- if(stat(fullname.c_str(), &statbuf) != 0){
- if(printErrors){
- cerr << "Error reading " << fullname << ": " << strerror(errno) <<
'\n';
- }
- continue;
- }
- void* handle=dlopen(fullname.c_str(), RTLD_NOW);
- if(!handle){
- if(printErrors){
- cerr << "Error opening scene: " << fullname << '\n';
- cerr << dlerror() << '\n';
- }
- continue;
+ if(stat(fullname.c_str(), &statbuf) == 0){
+ break;
}
- void* scene_fn=dlsym(handle, "make_scene");
- if(!scene_fn){
- if(printErrors){
- cerr << "Scene file found, but make_scene() function not found\n";
- }
- // If we get here, we fail so that we don't keep searching the path
- // for another scene
- return 0;
- }
- typedef Scene* (*MakerType)(const ReadContext&, const vector<string>&);
- // MakerType make_scene = reinterpret_cast<MakerType>(scene_fn);
- MakerType make_scene = (MakerType)(scene_fn);
- ReadContext context(this);
- Scene* scene=(*make_scene)(context, args);
- if(!scene){
- if(printErrors)
- cerr << "scene " << name << " did not produce a scene\n";
- return 0;
- }
- return scene;
}
- return 0;
+
+ // Attempt to open the file name.
+ void* handle=dlopen(fullname.c_str(), RTLD_NOW);
+ if(!handle){
+ throw InputError( dlerror() );
+ }
+
+ // Look up the scene function.
+ void* scene_fn=dlsym(handle, "make_scene");
+ if(!scene_fn){
+ throw InputError( "Could not find \"make_scene\" function.\n" );
+ }
+
+ typedef Scene* (*MakerType)(const ReadContext&, const vector<string>&);
+ MakerType make_scene = (MakerType)(scene_fn);
+
+ // Call the make_scene function.
+ ReadContext context(this);
+ Scene* scene=(*make_scene)(context, args);
+ if(!scene){
+ throw InputError( "make_scene returned null" );
+ }
+
+ return scene;
+
}
///////////////////////////////////////////////////////////////////////////////
@@ -1338,9 +1336,10 @@
void RTRT::registerComponent(const string& name, UserInterfaceCreator
creator)
{
- UserInterfaceMapType::iterator iter = userInterfaces.find(name);
- if(iter != userInterfaces.end())
- throw IllegalValue<string>("Duplicate User Interface component", name);
+ // Allow components to be re-registered.
+ // UserInterfaceMapType::iterator iter = userInterfaces.find(name);
+ // if(iter != userInterfaces.end())
+ // throw IllegalValue<string>("Duplicate User Interface component",
name);
userInterfaces[name] = creator;
}
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Wed Feb 22 00:16:05 2006
@@ -182,7 +182,7 @@
if(getenv("MANTA_SCENEPATH"))
rtrt->setScenePath(getenv("MANTA_SCENEPATH"));
else
- rtrt->setScenePath(".:../scenes");
+ rtrt->setScenePath("");
// Use one worker by default.
rtrt->changeNumWorkers(1);
@@ -325,7 +325,7 @@
usage(rtrt);
if(!rtrt->readScene(scene)){
cerr << "Error reading scene: " <<
scene << '\n';
- throw IllegalArgument( scene, i, args
);
+ throw IllegalArgument( "-scene", i,
args );
}
}
else if (arg == "-stack") {
- [MANTA] r950 - in trunk: Engine/Control StandAlone, abe, 02/22/2006
Archive powered by MHonArc 2.6.16.