- Add copyright notices to existing builtin python policies

- Implement system to dinamically pass plugins and policies search paths to
the sgpemv2 binary and tests (class GlobalSettings)
- Drastically reduce usage of hardcoded paths in code except as 
default overridable values


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@514 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-03-09 10:49:41 +00:00
parent 24a0194368
commit 92e6f3be2b
9 changed files with 353 additions and 88 deletions

View file

@ -34,13 +34,16 @@
#include "backend/process.hh"
#include "backend/policy.hh"
#include "backend/policy_parameters.hh"
#include "backend/global_settings.hh"
#include "standard_io.hh"
#include "text_simulation.hh"
#include <glibmm/module.h>
#include <glibmm/ustring.h>
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
@ -50,6 +53,32 @@ using namespace sgpem;
using namespace memory;
using Glib::ustring;
static void load_pyloader_plugin() {
// FIXME: this will need to be moved to an
// appropriate PluginManager class in the backend,
// and the Makefile fixed accordingly (partly done).
using Glib::Module;
// Leaks willingly:
Module* pyloader = 0;
GlobalSettings::dir_iterator it = GlobalSettings::instance().modules_dir_begin();
while(it != GlobalSettings::instance().modules_dir_end()) {
std::string pyloader_path = Module::build_path(*it, "pyloader");
pyloader = new Module(pyloader_path);
if(*pyloader) break;
else delete pyloader;
it++;
}
if(!*pyloader)
std::cerr << Module::get_last_error() << std::endl;
// For the moment, we want to be sure it has been loaded:
assert(*pyloader);
}
int
main(int argc, char* argv[])
{
@ -59,20 +88,10 @@ main(int argc, char* argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
// FIXME: this will need to be moved to an
// appropriate PluginManager class in the backend,
// and the Makefile fixed accordingly
using Glib::Module;
std::string pyloader_path = Module::build_path(PLUGDIR, "pyloader");
Module pyloader(pyloader_path);
std::cerr << Module::get_last_error() << std::endl;
assert(pyloader);
// Set up Glib thread support
Glib::thread_init();
// Parses options and prepares vector with
// filenames of documents to be opened
vector<string> filenames;
@ -83,6 +102,7 @@ main(int argc, char* argv[])
filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count);
}
load_pyloader_plugin();
// Create an INITIAL STATE
Process p1("P1", 0,5,1);