32 |
using python::method; |
using python::method; |
33 |
using python::pool; |
using python::pool; |
34 |
|
|
35 |
std::map<const char*, python::script*> pool::Pool; |
std::map<std::string, python::script*> pool::Pool; |
36 |
|
|
37 |
void pool::init () |
void pool::init () |
38 |
{ |
{ |
40 |
|
|
41 |
void pool::cleanup () |
void pool::cleanup () |
42 |
{ |
{ |
43 |
std::map<const char*, python::script*>::iterator i; |
std::map<std::string, python::script*>::iterator i; |
44 |
|
|
45 |
for (i = Pool.begin (); i != Pool.end (); i++) |
for (i = Pool.begin (); i != Pool.end (); i++) |
46 |
delete (*i).second; |
delete (*i).second; |
47 |
|
|
48 |
|
Pool.clear (); |
49 |
} |
} |
50 |
|
|
51 |
method *pool::connect (const std::string & file, const std::string & classname, const std::string & callback) |
method *pool::connect (const std::string & file, const std::string & classname, const std::string & callback) |
58 |
|
|
59 |
python::script *pool::reconnect (const std::string & file, const std::string & classname) |
python::script *pool::reconnect (const std::string & file, const std::string & classname) |
60 |
{ |
{ |
61 |
std::map<const char*, python::script*>::iterator i; |
std::map<std::string, python::script*>::const_iterator i; |
62 |
std::string name = file + classname; |
std::string name = file + classname; |
63 |
|
|
64 |
// script not in pool yet |
// script not in pool yet |
65 |
if ((i = Pool.find (name.c_str ())) == Pool.end ()) |
if ((i = Pool.find (name)) == Pool.end ()) |
66 |
{ |
{ |
67 |
python::script *scrpt = new python::script (); |
python::script *scrpt = new python::script (); |
68 |
|
|
77 |
} |
} |
78 |
|
|
79 |
// add script to pool |
// add script to pool |
80 |
Pool[name.c_str ()] = scrpt; |
Pool[name] = scrpt; |
81 |
return scrpt; |
return scrpt; |
82 |
} |
} |
83 |
// script already in pool |
// script already in pool |