summaryrefslogtreecommitdiffabout
path: root/lib/sitespace.cc
authorMichael Krelin <hacker@klever.net>2005-01-29 21:21:05 (UTC)
committer Michael Krelin <hacker@klever.net>2005-01-29 21:21:05 (UTC)
commitce1f37aae46ea95020d7b865f7a80e8abdfad0d8 (patch) (unidiff)
tree4964383ab8cd7e6d8ea821f1a615d1bbcf98dad8 /lib/sitespace.cc
parent3c75c860fc1ad5b3f5185e23ec6f438dd2528958 (diff)
downloadsitecing-ce1f37aae46ea95020d7b865f7a80e8abdfad0d8.zip
sitecing-ce1f37aae46ea95020d7b865f7a80e8abdfad0d8.tar.gz
sitecing-ce1f37aae46ea95020d7b865f7a80e8abdfad0d8.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'lib/sitespace.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/sitespace.cc52
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 @@
1#ifdef USE_PCH
2 #include "pch.h"
3#else
4 #include <cassert>
5 #include "sitecing/sitespace.h"
6 #include "sitecing/sitecing_util.h"
7#endif
8
9namespace sitecing {
10
11 sitespace::sitespace(configuration& c)
12 : config(c), factory(c) { }
13
14 sitespace::~sitespace() {
15 for(sentenced_t::iterator i = sentenced.begin();i!=sentenced.end();++i) {
16 assert((*i)->chickens_used.empty());
17 delete *i;
18 }
19 }
20
21 so_component sitespace::fetch(const string& c,sitecing_interface* scif) {
22 execute_sentenced();
23 string sobase = normalize_path(c);
24 string sopath = factory.root_so+sobase+".so";
25 config_options *co_build = config.lookup_config(sobase,config_options::flag_build);
26 if( (!co_build) || co_build->build )
27 factory.make(sopath);
28 components_t::iterator i = components.find(sopath);
29 if(i!=components.end()) {
30 if(i->second->is_uptodate())
31 return so_component(i->second,scif);
32 if(i->second->chickens_used.empty()) {
33 delete i->second;
34 }else{
35 sentenced.push_back(i->second);
36 }
37 components.erase(i);
38 }
39 pair<components_t::iterator,bool> ins = components.insert(components_t::value_type(sopath,new component_so(sopath)));
40 return so_component(ins.first->second,scif);
41 }
42
43 void sitespace::execute_sentenced() {
44 for(sentenced_t::iterator i = sentenced.begin();i!=sentenced.end();++i) {
45 if((*i)->chickens_used.empty()) {
46 delete *i;
47 sentenced.erase(i);
48 }
49 }
50 }
51
52}