author | Michael Krelin <hacker@klever.net> | 2005-01-29 21:21:05 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-01-29 21:21:05 (UTC) |
commit | ce1f37aae46ea95020d7b865f7a80e8abdfad0d8 (patch) (side-by-side diff) | |
tree | 4964383ab8cd7e6d8ea821f1a615d1bbcf98dad8 /lib/sitespace.cc | |
parent | 3c75c860fc1ad5b3f5185e23ec6f438dd2528958 (diff) | |
download | sitecing-ce1f37aae46ea95020d7b865f7a80e8abdfad0d8.zip sitecing-ce1f37aae46ea95020d7b865f7a80e8abdfad0d8.tar.gz sitecing-ce1f37aae46ea95020d7b865f7a80e8abdfad0d8.tar.bz2 |
initial commit into repository0.0
-rw-r--r-- | lib/sitespace.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/sitespace.cc b/lib/sitespace.cc new file mode 100644 index 0000000..0406d11 --- a/dev/null +++ b/lib/sitespace.cc @@ -0,0 +1,52 @@ +#ifdef USE_PCH + #include "pch.h" +#else + #include <cassert> + #include "sitecing/sitespace.h" + #include "sitecing/sitecing_util.h" +#endif + +namespace sitecing { + + sitespace::sitespace(configuration& c) + : config(c), factory(c) { } + + sitespace::~sitespace() { + for(sentenced_t::iterator i = sentenced.begin();i!=sentenced.end();++i) { + assert((*i)->chickens_used.empty()); + delete *i; + } + } + + so_component sitespace::fetch(const string& c,sitecing_interface* scif) { + execute_sentenced(); + string sobase = normalize_path(c); + string sopath = factory.root_so+sobase+".so"; + config_options *co_build = config.lookup_config(sobase,config_options::flag_build); + if( (!co_build) || co_build->build ) + factory.make(sopath); + components_t::iterator i = components.find(sopath); + if(i!=components.end()) { + if(i->second->is_uptodate()) + return so_component(i->second,scif); + if(i->second->chickens_used.empty()) { + delete i->second; + }else{ + sentenced.push_back(i->second); + } + components.erase(i); + } + pair<components_t::iterator,bool> ins = components.insert(components_t::value_type(sopath,new component_so(sopath))); + return so_component(ins.first->second,scif); + } + + void sitespace::execute_sentenced() { + for(sentenced_t::iterator i = sentenced.begin();i!=sentenced.end();++i) { + if((*i)->chickens_used.empty()) { + delete *i; + sentenced.erase(i); + } + } + } + +} |